1
Fork 0

resolve: Remove ! from "cannot find" diagnostics for macros

This commit is contained in:
Vadim Petrochenkov 2019-09-15 13:12:14 +03:00
parent 42a19dde82
commit f7f8d6584b
34 changed files with 42 additions and 43 deletions

View file

@ -774,9 +774,8 @@ impl<'a> Resolver<'a> {
} }
Err(..) => { Err(..) => {
assert!(initial_binding.is_none()); assert!(initial_binding.is_none());
let bang = if kind == MacroKind::Bang { "!" } else { "" };
let expected = kind.descr_expected(); let expected = kind.descr_expected();
let msg = format!("cannot find {} `{}{}` in this scope", expected, ident, bang); let msg = format!("cannot find {} `{}` in this scope", expected, ident);
let mut err = self.session.struct_span_err(ident.span, &msg); let mut err = self.session.struct_span_err(ident.span, &msg);
self.unresolved_macro_suggestions(&mut err, kind, &parent_scope, ident); self.unresolved_macro_suggestions(&mut err, kind, &parent_scope, ident);
err.emit(); err.emit();

View file

@ -1,4 +1,4 @@
error: cannot find macro `macro_two!` in this scope error: cannot find macro `macro_two` in this scope
--> $DIR/empty-macro-use.rs:7:5 --> $DIR/empty-macro-use.rs:7:5
| |
LL | macro_two!(); LL | macro_two!();

View file

@ -1,4 +1,4 @@
error: cannot find macro `iamnotanextensionthatexists!` in this scope error: cannot find macro `iamnotanextensionthatexists` in this scope
--> $DIR/ext-nonexistent.rs:2:13 --> $DIR/ext-nonexistent.rs:2:13
| |
LL | fn main() { iamnotanextensionthatexists!(""); } LL | fn main() { iamnotanextensionthatexists!(""); }

View file

@ -4,7 +4,7 @@
mod bar { mod bar {
fn f() { fn f() {
::std::print!(""); // OK ::std::print!(""); // OK
print!(); //~ ERROR cannot find macro `print!` in this scope print!(); //~ ERROR cannot find macro `print` in this scope
} }
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `print!` in this scope error: cannot find macro `print` in this scope
--> $DIR/no_implicit_prelude-2018.rs:7:9 --> $DIR/no_implicit_prelude-2018.rs:7:9
| |
LL | print!(); LL | print!();

View file

@ -13,7 +13,7 @@ mod bar {
} }
fn f() { fn f() {
::foo::m!(); ::foo::m!();
assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope assert_eq!(0, 0); //~ ERROR cannot find macro `panic` in this scope
} }
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `panic!` in this scope error: cannot find macro `panic` in this scope
--> $DIR/no_implicit_prelude.rs:16:9 --> $DIR/no_implicit_prelude.rs:16:9
| |
LL | assert_eq!(0, 0); LL | assert_eq!(0, 0);

View file

@ -1,3 +1,3 @@
fn main() { fn main() {
print!(testo!()); //~ ERROR cannot find macro `testo!` in this scope print!(testo!()); //~ ERROR cannot find macro `testo` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `testo!` in this scope error: cannot find macro `testo` in this scope
--> $DIR/issue-11692-1.rs:2:12 --> $DIR/issue-11692-1.rs:2:12
| |
LL | print!(testo!()); LL | print!(testo!());

View file

@ -1,3 +1,3 @@
fn main() { fn main() {
concat!(test!()); //~ ERROR cannot find macro `test!` in this scope concat!(test!()); //~ ERROR cannot find macro `test` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `test!` in this scope error: cannot find macro `test` in this scope
--> $DIR/issue-11692-2.rs:2:13 --> $DIR/issue-11692-2.rs:2:13
| |
LL | concat!(test!()); LL | concat!(test!());

View file

@ -4,5 +4,5 @@ struct Type;
impl Type { impl Type {
undef!(); undef!();
//~^ ERROR cannot find macro `undef!` in this scope //~^ ERROR cannot find macro `undef` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `undef!` in this scope error: cannot find macro `undef` in this scope
--> $DIR/issue-19734.rs:6:5 --> $DIR/issue-19734.rs:6:5
| |
LL | undef!(); LL | undef!();

View file

@ -1,6 +1,6 @@
trait T { m!(); } //~ ERROR cannot find macro `m!` in this scope trait T { m!(); } //~ ERROR cannot find macro `m` in this scope
struct S; struct S;
impl S { m!(); } //~ ERROR cannot find macro `m!` in this scope impl S { m!(); } //~ ERROR cannot find macro `m` in this scope
fn main() {} fn main() {}

View file

@ -1,10 +1,10 @@
error: cannot find macro `m!` in this scope error: cannot find macro `m` in this scope
--> $DIR/issue-40845.rs:4:10 --> $DIR/issue-40845.rs:4:10
| |
LL | impl S { m!(); } LL | impl S { m!(); }
| ^ | ^
error: cannot find macro `m!` in this scope error: cannot find macro `m` in this scope
--> $DIR/issue-40845.rs:1:11 --> $DIR/issue-40845.rs:1:11
| |
LL | trait T { m!(); } LL | trait T { m!(); }

View file

@ -9,5 +9,5 @@ mod foo {
} }
fn main() { fn main() {
bar!(); //~ ERROR cannot find macro `bar!` in this scope bar!(); //~ ERROR cannot find macro `bar` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `bar!` in this scope error: cannot find macro `bar` in this scope
--> $DIR/issue-49074.rs:12:4 --> $DIR/issue-49074.rs:12:4
| |
LL | bar!(); LL | bar!();

View file

@ -1,4 +1,4 @@
error: cannot find macro `m!` in this scope error: cannot find macro `m` in this scope
--> $DIR/macro-expansion-tests.rs:7:21 --> $DIR/macro-expansion-tests.rs:7:21
| |
LL | fn g() -> i32 { m!() } LL | fn g() -> i32 { m!() }
@ -6,7 +6,7 @@ LL | fn g() -> i32 { m!() }
| |
= help: have you added the `#[macro_use]` on the module/import? = help: have you added the `#[macro_use]` on the module/import?
error: cannot find macro `m!` in this scope error: cannot find macro `m` in this scope
--> $DIR/macro-expansion-tests.rs:15:21 --> $DIR/macro-expansion-tests.rs:15:21
| |
LL | fn g() -> i32 { m!() } LL | fn g() -> i32 { m!() }

View file

@ -1,4 +1,4 @@
error: cannot find macro `printlx!` in this scope error: cannot find macro `printlx` in this scope
--> $DIR/macro-name-typo.rs:2:5 --> $DIR/macro-name-typo.rs:2:5
| |
LL | printlx!("oh noes!"); LL | printlx!("oh noes!");

View file

@ -1,3 +1,3 @@
fn main() { fn main() {
inline!(); //~ ERROR cannot find macro `inline!` in this scope inline!(); //~ ERROR cannot find macro `inline` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `inline!` in this scope error: cannot find macro `inline` in this scope
--> $DIR/macro-path-prelude-fail-3.rs:2:5 --> $DIR/macro-path-prelude-fail-3.rs:2:5
| |
LL | inline!(); LL | inline!();

View file

@ -1,4 +1,4 @@
error: cannot find macro `macro_two!` in this scope error: cannot find macro `macro_two` in this scope
--> $DIR/macro-use-wrong-name.rs:7:5 --> $DIR/macro-use-wrong-name.rs:7:5
| |
LL | macro_two!(); LL | macro_two!();

View file

@ -1,4 +1,4 @@
error: cannot find macro `k!` in this scope error: cannot find macro `k` in this scope
--> $DIR/macro_undefined.rs:11:5 --> $DIR/macro_undefined.rs:11:5
| |
LL | k!(); LL | k!();

View file

@ -4,5 +4,5 @@ extern crate two_macros;
pub fn main() { pub fn main() {
macro_two!(); macro_two!();
//~^ ERROR cannot find macro `macro_two!` in this scope //~^ ERROR cannot find macro `macro_two` in this scope
} }

View file

@ -1,4 +1,4 @@
error: cannot find macro `macro_two!` in this scope error: cannot find macro `macro_two` in this scope
--> $DIR/missing-macro-use.rs:6:5 --> $DIR/missing-macro-use.rs:6:5
| |
LL | macro_two!(); LL | macro_two!();

View file

@ -25,12 +25,12 @@ fn check_bang1() {
my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it
} }
fn check_bang2() { fn check_bang2() {
my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr!` in this scope my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr` in this scope
crate::my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines crate::my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines
//~| ERROR expected macro, found attribute macro `crate::my_macro_attr` //~| ERROR expected macro, found attribute macro `crate::my_macro_attr`
} }
fn check_bang3() { fn check_bang3() {
MyTrait!(); //~ ERROR cannot find macro `MyTrait!` in this scope MyTrait!(); //~ ERROR cannot find macro `MyTrait` in this scope
crate::MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it crate::MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it
//~| ERROR expected macro, found derive macro `crate::MyTrait` //~| ERROR expected macro, found derive macro `crate::MyTrait`
} }

View file

@ -88,13 +88,13 @@ error: expected derive macro, found macro `crate::my_macro`
LL | #[derive(crate::my_macro)] LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^ not a derive macro | ^^^^^^^^^^^^^^^ not a derive macro
error: cannot find macro `my_macro_attr!` in this scope error: cannot find macro `my_macro_attr` in this scope
--> $DIR/macro-namespace-reserved-2.rs:28:5 --> $DIR/macro-namespace-reserved-2.rs:28:5
| |
LL | my_macro_attr!(); LL | my_macro_attr!();
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: cannot find macro `MyTrait!` in this scope error: cannot find macro `MyTrait` in this scope
--> $DIR/macro-namespace-reserved-2.rs:33:5 --> $DIR/macro-namespace-reserved-2.rs:33:5
| |
LL | MyTrait!(); LL | MyTrait!();

View file

@ -1,22 +1,22 @@
error: cannot find macro `bang_proc_macrp!` in this scope error: cannot find macro `bang_proc_macrp` in this scope
--> $DIR/resolve-error.rs:56:5 --> $DIR/resolve-error.rs:56:5
| |
LL | bang_proc_macrp!(); LL | bang_proc_macrp!();
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro` | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro`
error: cannot find macro `Dlona!` in this scope error: cannot find macro `Dlona` in this scope
--> $DIR/resolve-error.rs:53:5 --> $DIR/resolve-error.rs:53:5
| |
LL | Dlona!(); LL | Dlona!();
| ^^^^^ | ^^^^^
error: cannot find macro `attr_proc_macra!` in this scope error: cannot find macro `attr_proc_macra` in this scope
--> $DIR/resolve-error.rs:50:5 --> $DIR/resolve-error.rs:50:5
| |
LL | attr_proc_macra!(); LL | attr_proc_macra!();
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac` | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
error: cannot find macro `FooWithLongNama!` in this scope error: cannot find macro `FooWithLongNama` in this scope
--> $DIR/resolve-error.rs:47:5 --> $DIR/resolve-error.rs:47:5
| |
LL | FooWithLongNama!(); LL | FooWithLongNama!();

View file

@ -1,6 +1,6 @@
// edition:2018 // edition:2018
foo!(); //~ ERROR cannot find macro `foo!` in this scope foo!(); //~ ERROR cannot find macro `foo` in this scope
pub(in ::bar) struct Baz {} //~ ERROR cannot determine resolution for the visibility pub(in ::bar) struct Baz {} //~ ERROR cannot determine resolution for the visibility

View file

@ -4,7 +4,7 @@ error[E0578]: cannot determine resolution for the visibility
LL | pub(in ::bar) struct Baz {} LL | pub(in ::bar) struct Baz {}
| ^^^^^ | ^^^^^
error: cannot find macro `foo!` in this scope error: cannot find macro `foo` in this scope
--> $DIR/visibility-indeterminate.rs:3:1 --> $DIR/visibility-indeterminate.rs:3:1
| |
LL | foo!(); LL | foo!();

View file

@ -19,7 +19,7 @@ pub fn main() {
ref mut Self => (), ref mut Self => (),
//~^ ERROR expected identifier, found keyword `Self` //~^ ERROR expected identifier, found keyword `Self`
Self!() => (), Self!() => (),
//~^ ERROR cannot find macro `Self!` in this scope //~^ ERROR cannot find macro `Self` in this scope
Foo { Self } => (), Foo { Self } => (),
//~^ ERROR expected identifier, found keyword `Self` //~^ ERROR expected identifier, found keyword `Self`
} }

View file

@ -54,7 +54,7 @@ error: lifetimes cannot use keyword names
LL | struct Bar<'Self>; LL | struct Bar<'Self>;
| ^^^^^ | ^^^^^
error: cannot find macro `Self!` in this scope error: cannot find macro `Self` in this scope
--> $DIR/self_type_keyword.rs:21:9 --> $DIR/self_type_keyword.rs:21:9
| |
LL | Self!() => (), LL | Self!() => (),

View file

@ -11,7 +11,7 @@ fn check() {}
#[rustfmt::skip] // OK #[rustfmt::skip] // OK
fn main() { fn main() {
rustfmt; //~ ERROR expected value, found tool module `rustfmt` rustfmt; //~ ERROR expected value, found tool module `rustfmt`
rustfmt!(); //~ ERROR cannot find macro `rustfmt!` in this scope rustfmt!(); //~ ERROR cannot find macro `rustfmt` in this scope
rustfmt::skip; //~ ERROR expected value, found tool attribute `rustfmt::skip` rustfmt::skip; //~ ERROR expected value, found tool attribute `rustfmt::skip`
} }

View file

@ -10,7 +10,7 @@ error: cannot find attribute `rustfmt` in this scope
LL | #[rustfmt] LL | #[rustfmt]
| ^^^^^^^ | ^^^^^^^
error: cannot find macro `rustfmt!` in this scope error: cannot find macro `rustfmt` in this scope
--> $DIR/tool-attributes-misplaced-1.rs:14:5 --> $DIR/tool-attributes-misplaced-1.rs:14:5
| |
LL | rustfmt!(); LL | rustfmt!();