Closed
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
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Name/path resolution done by `rustc_resolve` specificallyCategory: This is a bug.Diagnostics: Confusing error or lint that should be reworked.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.