Skip to content

Commit f7f8d65

Browse files
committed
resolve: Remove ! from "cannot find" diagnostics for macros
1 parent 42a19dd commit f7f8d65

34 files changed

+42
-43
lines changed

src/librustc_resolve/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,8 @@ impl<'a> Resolver<'a> {
774774
}
775775
Err(..) => {
776776
assert!(initial_binding.is_none());
777-
let bang = if kind == MacroKind::Bang { "!" } else { "" };
778777
let expected = kind.descr_expected();
779-
let msg = format!("cannot find {} `{}{}` in this scope", expected, ident, bang);
778+
let msg = format!("cannot find {} `{}` in this scope", expected, ident);
780779
let mut err = self.session.struct_span_err(ident.span, &msg);
781780
self.unresolved_macro_suggestions(&mut err, kind, &parent_scope, ident);
782781
err.emit();

src/test/ui/empty/empty-macro-use.stderr

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

src/test/ui/ext-nonexistent.stderr

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

src/test/ui/hygiene/no_implicit_prelude-2018.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
mod bar {
55
fn f() {
66
::std::print!(""); // OK
7-
print!(); //~ ERROR cannot find macro `print!` in this scope
7+
print!(); //~ ERROR cannot find macro `print` in this scope
88
}
99
}
1010

src/test/ui/hygiene/no_implicit_prelude-2018.stderr

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

src/test/ui/hygiene/no_implicit_prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod bar {
1313
}
1414
fn f() {
1515
::foo::m!();
16-
assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope
16+
assert_eq!(0, 0); //~ ERROR cannot find macro `panic` in this scope
1717
}
1818
}
1919

src/test/ui/hygiene/no_implicit_prelude.stderr

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

src/test/ui/issues/issue-11692-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
print!(testo!()); //~ ERROR cannot find macro `testo!` in this scope
2+
print!(testo!()); //~ ERROR cannot find macro `testo` in this scope
33
}

src/test/ui/issues/issue-11692-1.stderr

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

src/test/ui/issues/issue-11692-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
concat!(test!()); //~ ERROR cannot find macro `test!` in this scope
2+
concat!(test!()); //~ ERROR cannot find macro `test` in this scope
33
}

src/test/ui/issues/issue-11692-2.stderr

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

src/test/ui/issues/issue-19734.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ struct Type;
44

55
impl Type {
66
undef!();
7-
//~^ ERROR cannot find macro `undef!` in this scope
7+
//~^ ERROR cannot find macro `undef` in this scope
88
}

src/test/ui/issues/issue-19734.stderr

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

src/test/ui/issues/issue-40845.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
trait T { m!(); } //~ ERROR cannot find macro `m!` in this scope
1+
trait T { m!(); } //~ ERROR cannot find macro `m` in this scope
22

33
struct S;
4-
impl S { m!(); } //~ ERROR cannot find macro `m!` in this scope
4+
impl S { m!(); } //~ ERROR cannot find macro `m` in this scope
55

66
fn main() {}

src/test/ui/issues/issue-40845.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: cannot find macro `m!` in this scope
1+
error: cannot find macro `m` in this scope
22
--> $DIR/issue-40845.rs:4:10
33
|
44
LL | impl S { m!(); }
55
| ^
66

7-
error: cannot find macro `m!` in this scope
7+
error: cannot find macro `m` in this scope
88
--> $DIR/issue-40845.rs:1:11
99
|
1010
LL | trait T { m!(); }

src/test/ui/issues/issue-49074.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ mod foo {
99
}
1010

1111
fn main() {
12-
bar!(); //~ ERROR cannot find macro `bar!` in this scope
12+
bar!(); //~ ERROR cannot find macro `bar` in this scope
1313
}

src/test/ui/issues/issue-49074.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: cannot find macro `bar!` in this scope
1+
error: cannot find macro `bar` in this scope
22
--> $DIR/issue-49074.rs:12:4
33
|
44
LL | bar!();

src/test/ui/macros/macro-expansion-tests.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: cannot find macro `m!` in this scope
1+
error: cannot find macro `m` in this scope
22
--> $DIR/macro-expansion-tests.rs:7:21
33
|
44
LL | fn g() -> i32 { m!() }
55
| ^
66
|
77
= help: have you added the `#[macro_use]` on the module/import?
88

9-
error: cannot find macro `m!` in this scope
9+
error: cannot find macro `m` in this scope
1010
--> $DIR/macro-expansion-tests.rs:15:21
1111
|
1212
LL | fn g() -> i32 { m!() }

src/test/ui/macros/macro-name-typo.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: cannot find macro `printlx!` in this scope
1+
error: cannot find macro `printlx` in this scope
22
--> $DIR/macro-name-typo.rs:2:5
33
|
44
LL | printlx!("oh noes!");
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
inline!(); //~ ERROR cannot find macro `inline!` in this scope
2+
inline!(); //~ ERROR cannot find macro `inline` in this scope
33
}

src/test/ui/macros/macro-path-prelude-fail-3.stderr

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

src/test/ui/macros/macro-use-wrong-name.stderr

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

src/test/ui/macros/macro_undefined.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: cannot find macro `k!` in this scope
1+
error: cannot find macro `k` in this scope
22
--> $DIR/macro_undefined.rs:11:5
33
|
44
LL | k!();

src/test/ui/missing/missing-macro-use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ extern crate two_macros;
44

55
pub fn main() {
66
macro_two!();
7-
//~^ ERROR cannot find macro `macro_two!` in this scope
7+
//~^ ERROR cannot find macro `macro_two` in this scope
88
}

src/test/ui/missing/missing-macro-use.stderr

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

src/test/ui/proc-macro/macro-namespace-reserved-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ fn check_bang1() {
2525
my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it
2626
}
2727
fn check_bang2() {
28-
my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr!` in this scope
28+
my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr` in this scope
2929
crate::my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines
3030
//~| ERROR expected macro, found attribute macro `crate::my_macro_attr`
3131
}
3232
fn check_bang3() {
33-
MyTrait!(); //~ ERROR cannot find macro `MyTrait!` in this scope
33+
MyTrait!(); //~ ERROR cannot find macro `MyTrait` in this scope
3434
crate::MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it
3535
//~| ERROR expected macro, found derive macro `crate::MyTrait`
3636
}

src/test/ui/proc-macro/macro-namespace-reserved-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ error: expected derive macro, found macro `crate::my_macro`
8888
LL | #[derive(crate::my_macro)]
8989
| ^^^^^^^^^^^^^^^ not a derive macro
9090

91-
error: cannot find macro `my_macro_attr!` in this scope
91+
error: cannot find macro `my_macro_attr` in this scope
9292
--> $DIR/macro-namespace-reserved-2.rs:28:5
9393
|
9494
LL | my_macro_attr!();
9595
| ^^^^^^^^^^^^^
9696

97-
error: cannot find macro `MyTrait!` in this scope
97+
error: cannot find macro `MyTrait` in this scope
9898
--> $DIR/macro-namespace-reserved-2.rs:33:5
9999
|
100100
LL | MyTrait!();

src/test/ui/proc-macro/resolve-error.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
error: cannot find macro `bang_proc_macrp!` in this scope
1+
error: cannot find macro `bang_proc_macrp` in this scope
22
--> $DIR/resolve-error.rs:56:5
33
|
44
LL | bang_proc_macrp!();
55
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro`
66

7-
error: cannot find macro `Dlona!` in this scope
7+
error: cannot find macro `Dlona` in this scope
88
--> $DIR/resolve-error.rs:53:5
99
|
1010
LL | Dlona!();
1111
| ^^^^^
1212

13-
error: cannot find macro `attr_proc_macra!` in this scope
13+
error: cannot find macro `attr_proc_macra` in this scope
1414
--> $DIR/resolve-error.rs:50:5
1515
|
1616
LL | attr_proc_macra!();
1717
| ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac`
1818

19-
error: cannot find macro `FooWithLongNama!` in this scope
19+
error: cannot find macro `FooWithLongNama` in this scope
2020
--> $DIR/resolve-error.rs:47:5
2121
|
2222
LL | FooWithLongNama!();

src/test/ui/resolve/visibility-indeterminate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// edition:2018
22

3-
foo!(); //~ ERROR cannot find macro `foo!` in this scope
3+
foo!(); //~ ERROR cannot find macro `foo` in this scope
44

55
pub(in ::bar) struct Baz {} //~ ERROR cannot determine resolution for the visibility
66

src/test/ui/resolve/visibility-indeterminate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0578]: cannot determine resolution for the visibility
44
LL | pub(in ::bar) struct Baz {}
55
| ^^^^^
66

7-
error: cannot find macro `foo!` in this scope
7+
error: cannot find macro `foo` in this scope
88
--> $DIR/visibility-indeterminate.rs:3:1
99
|
1010
LL | foo!();

src/test/ui/self/self_type_keyword.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn main() {
1919
ref mut Self => (),
2020
//~^ ERROR expected identifier, found keyword `Self`
2121
Self!() => (),
22-
//~^ ERROR cannot find macro `Self!` in this scope
22+
//~^ ERROR cannot find macro `Self` in this scope
2323
Foo { Self } => (),
2424
//~^ ERROR expected identifier, found keyword `Self`
2525
}

src/test/ui/self/self_type_keyword.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ error: lifetimes cannot use keyword names
5454
LL | struct Bar<'Self>;
5555
| ^^^^^
5656

57-
error: cannot find macro `Self!` in this scope
57+
error: cannot find macro `Self` in this scope
5858
--> $DIR/self_type_keyword.rs:21:9
5959
|
6060
LL | Self!() => (),

src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn check() {}
1111
#[rustfmt::skip] // OK
1212
fn main() {
1313
rustfmt; //~ ERROR expected value, found tool module `rustfmt`
14-
rustfmt!(); //~ ERROR cannot find macro `rustfmt!` in this scope
14+
rustfmt!(); //~ ERROR cannot find macro `rustfmt` in this scope
1515

1616
rustfmt::skip; //~ ERROR expected value, found tool attribute `rustfmt::skip`
1717
}

src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error: cannot find attribute `rustfmt` in this scope
1010
LL | #[rustfmt]
1111
| ^^^^^^^
1212

13-
error: cannot find macro `rustfmt!` in this scope
13+
error: cannot find macro `rustfmt` in this scope
1414
--> $DIR/tool-attributes-misplaced-1.rs:14:5
1515
|
1616
LL | rustfmt!();

0 commit comments

Comments
 (0)