Closed
Description
Code
#![allow(unused_imports)]
mod inner {
pub enum Example {
ExOne,
ExTwo,
}
}
mod reexports {
pub use crate::inner::{
Example as _,
};
}
use crate::reexports::*;
fn check() {
ExOne;
}
Current output
error[E0425]: cannot find value `ExOne` in this scope
--> src/lib.rs:19:5
|
19 | ExOne;
| ^^^^^ not found in this scope
|
help: consider importing this unit variant
|
16 + use crate::_::ExOne;
|
For more information about this error, try `rustc --explain E0425`.
Desired output
error[E0425]: cannot find value `ExOne` in this scope
--> src/lib.rs:19:5
|
19 | ExOne;
| ^^^^^ not found in this scope
|
help: consider importing this unit variant
|
16 + use crate::inner::ExOne;
|
For more information about this error, try `rustc --explain E0425`.
Rationale and extra context
The suggested fix doesn't work, since _
is a reserved identifier and items may not be imported through it:
error: expected identifier, found reserved identifier `_`
--> src/lib.rs:1:12
|
1 | use crate::_::ExOne;
| ^ expected identifier, found reserved identifier
The appropriate suggestion is to import the item via a valid path.
Other cases
No response
Anything else?
Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=013d5f59846dad0ae3add3c12d24c755
Came up as a result of triaging: obi1kenobi/cargo-semver-checks#536
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.