Rollup merge of #93061 - estebank:macr-suggestion, r=cjgillot

Only suggest adding `!` to expressions that can be macro invocation
This commit is contained in:
Matthias Krüger 2022-01-20 23:37:33 +01:00 committed by GitHub
commit dc393b2ecc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 24 deletions

View file

@ -11,16 +11,10 @@ LL | struct SemiTransparent;
| ----------------------- similarly named unit struct `SemiTransparent` defined here
...
LL | semitransparent;
| ^^^^^^^^^^^^^^^ not a value
|
help: use `!` to invoke the macro
|
LL | semitransparent!;
| +
help: a unit struct with a similar name exists
|
LL | SemiTransparent;
| ~~~~~~~~~~~~~~~
| ^^^^^^^^^^^^^^^
| |
| not a value
| help: a unit struct with a similar name exists: `SemiTransparent`
error[E0423]: expected value, found macro `opaque`
--> $DIR/rustc-macro-transparency.rs:30:5
@ -29,16 +23,10 @@ LL | struct Opaque;
| -------------- similarly named unit struct `Opaque` defined here
...
LL | opaque;
| ^^^^^^ not a value
|
help: use `!` to invoke the macro
|
LL | opaque!;
| +
help: a unit struct with a similar name exists
|
LL | Opaque;
| ~~~~~~
| ^^^^^^
| |
| not a value
| help: a unit struct with a similar name exists (notice the capitalization): `Opaque`
error: aborting due to 3 previous errors

View file

@ -0,0 +1,11 @@
// run-rustfix
fn main() {
assert_eq!(1, 1);
//~^ ERROR expected function, found macro `assert_eq`
assert_eq! { 1, 1 };
//~^ ERROR expected struct, variant or union type, found macro `assert_eq`
//~| ERROR expected identifier, found `1`
//~| ERROR expected identifier, found `1`
assert![true];
//~^ ERROR expected value, found macro `assert`
}

View file

@ -1,4 +1,11 @@
// run-rustfix
fn main() {
assert_eq(1, 1);
//~^ ERROR expected function, found macro `assert_eq`
assert_eq { 1, 1 };
//~^ ERROR expected struct, variant or union type, found macro `assert_eq`
//~| ERROR expected identifier, found `1`
//~| ERROR expected identifier, found `1`
assert[true];
//~^ ERROR expected value, found macro `assert`
}

View file

@ -1,5 +1,21 @@
error: expected identifier, found `1`
--> $DIR/resolve-hint-macro.rs:5:17
|
LL | assert_eq { 1, 1 };
| --------- ^ expected identifier
| |
| while parsing this struct
error: expected identifier, found `1`
--> $DIR/resolve-hint-macro.rs:5:20
|
LL | assert_eq { 1, 1 };
| --------- ^ expected identifier
| |
| while parsing this struct
error[E0423]: expected function, found macro `assert_eq`
--> $DIR/resolve-hint-macro.rs:2:5
--> $DIR/resolve-hint-macro.rs:3:5
|
LL | assert_eq(1, 1);
| ^^^^^^^^^ not a function
@ -9,6 +25,29 @@ help: use `!` to invoke the macro
LL | assert_eq!(1, 1);
| +
error: aborting due to previous error
error[E0574]: expected struct, variant or union type, found macro `assert_eq`
--> $DIR/resolve-hint-macro.rs:5:5
|
LL | assert_eq { 1, 1 };
| ^^^^^^^^^ not a struct, variant or union type
|
help: use `!` to invoke the macro
|
LL | assert_eq! { 1, 1 };
| +
For more information about this error, try `rustc --explain E0423`.
error[E0423]: expected value, found macro `assert`
--> $DIR/resolve-hint-macro.rs:9:5
|
LL | assert[true];
| ^^^^^^ not a value
|
help: use `!` to invoke the macro
|
LL | assert![true];
| +
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0423, E0574.
For more information about an error, try `rustc --explain E0423`.