Closed
Description
I encountered incorrect code being produced by cargo fix
command.
Code
mod bakery_module {
pub struct Cheesecake;
#[derive(Debug)]
pub struct Cupcake;
}
use bakery_module::{self as moms_spaghetti, Cheesecake};
fn main() {
dbg!(moms_spaghetti::Cupcake);
}
Meta
stable rustc --version --verbose
:
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.1
nightly rustc --version --verbose
:
rustc 1.85.0-nightly (5e1440ae5 2024-12-01)
binary: rustc
commit-hash: 5e1440ae514d98ddfcbf1607acb64d41e07ef616
commit-date: 2024-12-01
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.4
Error output
warning: `test-field` (bin "test-field") generated 2 warnings (run `cargo fix --bin "test-field"` to apply 1 suggestion)
warning: failed to automatically apply fixes suggested by rustc to crate `test_field`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
<here I removed notice about making an issue into this repo>
The following errors were reported:
error[E0429]: `self` imports are only allowed within a { } list
--> src/main.rs:8:18
|
8 | use bakery_module::self as moms_spaghetti;
| ^^^^^^
|
help: consider importing the module directly
|
8 - use bakery_module::self as moms_spaghetti;
8 + use bakery_module as moms_spaghetti;
|
help: alternatively, use the multi-path `use` syntax to import `self`
|
8 | use bakery_module::{self as moms_spaghetti};
| + +
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0429`.
Original diagnostics will follow.
warning: `test-field` (bin "test-field" test) generated 2 warnings (2 duplicates)
Backtrace
No backtrace
Metadata
Metadata
Assignees
Labels
Area: Lints (warnings about flaws in source code) such as unused_mut.Area: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Lint: dead_codeRelevant to the compiler team, which will review and decide on the PR/issue.