Give a better error message for duplicate built-in macros
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
This commit is contained in:
parent
022e1fe235
commit
be2947d0b7
8 changed files with 112 additions and 8 deletions
|
@ -454,6 +454,7 @@ E0768: include_str!("./error_codes/E0768.md"),
|
|||
E0769: include_str!("./error_codes/E0769.md"),
|
||||
E0770: include_str!("./error_codes/E0770.md"),
|
||||
E0771: include_str!("./error_codes/E0771.md"),
|
||||
E0773: include_str!("./error_codes/E0773.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
|
38
compiler/rustc_error_codes/src/error_codes/E0773.md
Normal file
38
compiler/rustc_error_codes/src/error_codes/E0773.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
A builtin-macro was defined more than once.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0773
|
||||
#![feature(decl_macro)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
pub macro test($item:item) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
|
||||
mod inner {
|
||||
#[rustc_builtin_macro]
|
||||
pub macro test($item:item) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To fix the issue, remove the duplicate declaration:
|
||||
|
||||
```
|
||||
#![feature(decl_macro)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_builtin_macro]
|
||||
pub macro test($item:item) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
```
|
||||
|
||||
In very rare edge cases, this may happen when loading `core` or `std` twice,
|
||||
once with `check` metadata and once with `build` metadata.
|
||||
For more information, see [#75176].
|
||||
|
||||
[#75176]: https://github.com/rust-lang/rust/pull/75176#issuecomment-683234468
|
Loading…
Add table
Add a link
Reference in a new issue