-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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.F-decl_macro`#![feature(decl_macro)]``#![feature(decl_macro)]`T-langRelevant to the language teamRelevant to the language team
Description
Not sure if it is a bug or confusing error messages. Consider the following code:
Playground
#![feature(decl_macro)]
macro impl_mod($name:ident) {
pub mod $name {
pub struct Bar;
}
}
impl_mod!(foo);
use foo::Bar;
fn main() {}
Output:
error[E0432]: unresolved import `foo::Bar`
--> src/main.rs:11:5
|
11 | use foo::Bar;
| ^^^^^^^^ no `Bar` in `foo`. Did you mean to use `Bar`?
warning: unused import: `foo::Bar`
--> src/main.rs:11:5
|
11 | use foo::Bar;
| ^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
What is confusing:
- So is it unresolved or resolved and unused?
- "no 'Bar'. did you mean 'Bar'?" - feels like a bug.
- Path
foo
is accessible, why thenfoo::Bar
not?
rustc --version --verbose
:
rustc 1.24.0-nightly (560a5da9f 2017-11-27)
binary: rustc
commit-hash: 560a5da9f1cc7f67d2fc372925aef18c96c82629
commit-date: 2017-11-27
host: x86_64-unknown-linux-gnu
release: 1.24.0-nightly
LLVM version: 4.0
Metadata
Metadata
Assignees
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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.F-decl_macro`#![feature(decl_macro)]``#![feature(decl_macro)]`T-langRelevant to the language teamRelevant to the language team