resolve: Refactor away MacroBinding
`fn resolve_legacy_scope` can now resolve only to `macro_rules!` items, `fn resolve_lexical_macro_path_segment` is for everything else - modularized macros, preludes
This commit is contained in:
parent
23e9a1def5
commit
c2788a88ca
9 changed files with 160 additions and 116 deletions
21
src/test/ui/imports/issue-53269.rs
Normal file
21
src/test/ui/imports/issue-53269.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Ambiguity between a `macro_rules` macro and a non-existent import recovered as `Def::Err`
|
||||
|
||||
macro_rules! mac { () => () }
|
||||
|
||||
mod m {
|
||||
use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
|
||||
|
||||
mac!(); //~ ERROR `mac` is ambiguous
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
26
src/test/ui/imports/issue-53269.stderr
Normal file
26
src/test/ui/imports/issue-53269.stderr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
error[E0432]: unresolved import `nonexistent_module`
|
||||
--> $DIR/issue-53269.rs:16:9
|
||||
|
|
||||
LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
|
||||
| ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate nonexistent_module;`?
|
||||
|
||||
error: `mac` is ambiguous
|
||||
--> $DIR/issue-53269.rs:18:5
|
||||
|
|
||||
LL | mac!(); //~ ERROR `mac` is ambiguous
|
||||
| ^^^
|
||||
|
|
||||
note: `mac` could refer to the macro defined here
|
||||
--> $DIR/issue-53269.rs:13:1
|
||||
|
|
||||
LL | macro_rules! mac { () => () }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: `mac` could also refer to the macro imported here
|
||||
--> $DIR/issue-53269.rs:16:9
|
||||
|
|
||||
LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0432`.
|
||||
17
src/test/ui/imports/issue-53512.rs
Normal file
17
src/test/ui/imports/issue-53512.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Macro from prelude is shadowed by non-existent import recovered as `Def::Err`.
|
||||
|
||||
use std::assert; //~ ERROR unresolved import `std::assert`
|
||||
|
||||
fn main() {
|
||||
assert!(true);
|
||||
}
|
||||
9
src/test/ui/imports/issue-53512.stderr
Normal file
9
src/test/ui/imports/issue-53512.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0432]: unresolved import `std::assert`
|
||||
--> $DIR/issue-53512.rs:13:5
|
||||
|
|
||||
LL | use std::assert; //~ ERROR unresolved import `std::assert`
|
||||
| ^^^^^^^^^^^ no `assert` in the root
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0432`.
|
||||
|
|
@ -37,10 +37,10 @@ mod m4 {
|
|||
|
||||
mod m5 {
|
||||
macro_rules! m { () => {
|
||||
macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
|
||||
macro_rules! panic { () => {} }
|
||||
} }
|
||||
m!();
|
||||
panic!();
|
||||
panic!(); //~ ERROR `panic` is ambiguous
|
||||
}
|
||||
|
||||
#[macro_use(n)]
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
error: `panic` is already in scope
|
||||
error: `panic` is ambiguous
|
||||
--> $DIR/shadow_builtin_macros.rs:43:5
|
||||
|
|
||||
LL | panic!(); //~ ERROR `panic` is ambiguous
|
||||
| ^^^^^
|
||||
|
|
||||
note: `panic` could refer to the macro defined here
|
||||
--> $DIR/shadow_builtin_macros.rs:40:9
|
||||
|
|
||||
LL | macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
|
||||
LL | macro_rules! panic { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | } }
|
||||
LL | m!();
|
||||
| ----- in this macro invocation
|
||||
|
|
||||
= note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560)
|
||||
note: `panic` could also refer to the macro imported here
|
||||
|
||||
error[E0659]: `panic` is ambiguous
|
||||
--> $DIR/shadow_builtin_macros.rs:25:14
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue