-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
The following snippet fails to compile with the error [E0412]: cannot find type Foo in this scope
struct Foo; // line 1
mod foo {
use super::*; // line 4
// Commenting out the Debug derive makes it work
#[derive(Debug)] // line 7
pub struct Foo;
}
mod bar {
use super::foo::*;
fn bar(_: Foo) {}
}
Expected result: code compiles without issues
I can get it to compile by doing one of those:
- by removing
use super::*
on line 4 - by commenting
#[derive(Debug)]
at line 7 - by renaming
struct Foo
on line 1 toFoo2
- and curiously, by copy-pasting the generated Debug impl obtained with --pretty=expanded instead of using
#[derive(Debug)]
The same issue happens with other derives (Clone,Eq,etc.). Seems like #[derive()]
is confused when an item with the same name is visible?
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.