Rollup merge of #55138 - zackmdavis:the_paren_trap, r=pnkfelix
in which unused-parens suggestions heed what the user actually wrote Aaron Hill pointed out that unnecessary parens around a macro call (paradigmatically, `format!`) yielded a suggestion of hideous macro-expanded code. `span_to_snippet` is fallable as far as the type system is concerned, so the pretty-printing can live on in the oft-neglected `else` branch. Resolves #55109.
This commit is contained in:
commit
6dfeb7602f
3 changed files with 21 additions and 11 deletions
|
|
@ -56,7 +56,7 @@ fn main() {
|
|||
while true {
|
||||
//~^ WARN denote infinite loops
|
||||
//~| HELP use `loop`
|
||||
let mut a = (1);
|
||||
let mut registry_no = (format!("NX-{}", 74205));
|
||||
//~^ WARN does not need to be mutable
|
||||
//~| HELP remove this `mut`
|
||||
//~| WARN unnecessary parentheses
|
||||
|
|
@ -72,6 +72,6 @@ fn main() {
|
|||
//~^ WARN this pattern is redundant
|
||||
//~| HELP remove this
|
||||
}
|
||||
println!("{} {}", a, b);
|
||||
println!("{} {}", registry_no, b);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
warning: unnecessary parentheses around assigned value
|
||||
--> $DIR/suggestions.rs:59:21
|
||||
--> $DIR/suggestions.rs:59:31
|
||||
|
|
||||
LL | let mut a = (1);
|
||||
| ^^^ help: remove these parentheses
|
||||
LL | let mut registry_no = (format!("NX-{}", 74205));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/suggestions.rs:13:21
|
||||
|
|
@ -21,8 +21,8 @@ LL | #[no_debug] // should suggest removal of deprecated attribute
|
|||
warning: variable does not need to be mutable
|
||||
--> $DIR/suggestions.rs:59:13
|
||||
|
|
||||
LL | let mut a = (1);
|
||||
| ----^
|
||||
LL | let mut registry_no = (format!("NX-{}", 74205));
|
||||
| ----^^^^^^^^^^^
|
||||
| |
|
||||
| help: remove this `mut`
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue