Don't include bang in macro replacement suggestion

When we suggest the replacement for a macro we include the "!" in the
suggested replacement but the span only contains the name of the macro
itself. Using that replacement would cause a duplicate "!" in the
resulting code.

I originally tried to extend the span to be replaced by 1 byte in
rust-lang/rust#47424. However, @zackmdavis pointed out that there can be
whitespace between the macro name and the bang.

Instead, just remove the bang from the suggested replacement.

Fixes #47418
This commit is contained in:
Ryan Cumming 2018-01-15 08:08:22 +11:00
parent bb345a0be3
commit ecd47a91c7
4 changed files with 6 additions and 7 deletions

View file

@ -2,7 +2,7 @@ error: cannot find macro `printlx!` in this scope
--> $DIR/macro-name-typo.rs:12:5
|
12 | printlx!("oh noes!"); //~ ERROR cannot find
| ^^^^^^^ help: you could try the macro: `println!`
| ^^^^^^^ help: you could try the macro: `println`
error: aborting due to previous error

View file

@ -10,7 +10,7 @@ error: cannot find macro `k!` in this scope
--> $DIR/macro_undefined.rs:21:5
|
21 | k!(); //~ ERROR cannot find
| ^ help: you could try the macro: `kl!`
| ^ help: you could try the macro: `kl`
error: aborting due to 2 previous errors