Skip to content

Commit 7c11bc6

Browse files
Add E0468 error explanation
1 parent 9ce94f2 commit 7c11bc6

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/librustc_metadata/diagnostics.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,34 @@ extern crate macros_for_good;
157157
```
158158
"##,
159159

160+
E0468: r##"
161+
A non-root module attempts to import macros from another crate.
162+
163+
Example of erroneous code:
164+
165+
```compile_fail,E0468
166+
mod foo {
167+
#[macro_use(helpful_macro)] // error: must be at crate root to import
168+
extern crate some_crate; // macros from another crate
169+
helpful_macro!(...)
170+
}
171+
```
172+
173+
Only `extern crate` imports at the crate root level are allowed to import
174+
macros.
175+
176+
Either move the macro import to crate root or do without the foreign macros.
177+
This will work:
178+
179+
```ignore
180+
#[macro_use(helpful_macro)]
181+
extern crate some_crate;
182+
183+
mod foo {
184+
helpful_macro!(...)
185+
}
186+
```
187+
"##,
160188
}
161189

162190
register_diagnostics! {
@@ -168,7 +196,6 @@ register_diagnostics! {
168196
E0462, // found staticlib `..` instead of rlib or dylib
169197
E0464, // multiple matching crates for `..`
170198
E0465, // multiple .. candidates for `..` found
171-
E0468, // an `extern crate` loading macros must be at the crate root
172199
E0469, // imported macro not found
173200
E0470, // reexported macro not found
174201
E0519, // local crate and dependency have same (crate-name, disambiguator)

0 commit comments

Comments
 (0)