forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#73953 - JohnTitor:audit-hidden-sugg, r=este…
…bank Audit hidden/short code suggestions Should fix rust-lang#73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
- Loading branch information
Showing
153 changed files
with
1,801 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// run-rustfix | ||
|
||
fn foo() -> i32 { | ||
0 | ||
} | ||
|
||
fn main() { | ||
let _x: i32 = { | ||
//~^ ERROR mismatched types | ||
foo() //~ HELP consider removing this semicolon | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/test/ui/block-result/consider-removing-last-semi.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// run-rustfix | ||
|
||
pub fn f() -> String { //~ ERROR mismatched types | ||
0u8; | ||
"bla".to_string() | ||
} | ||
|
||
pub fn g() -> String { //~ ERROR mismatched types | ||
"this won't work".to_string(); | ||
"removeme".to_string() | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
src/test/ui/block-result/consider-removing-last-semi.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/test/ui/coercion/coercion-missing-tail-expected-type.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// #41425 -- error message "mismatched types" has wrong types | ||
// run-rustfix | ||
|
||
fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types | ||
x + 1 | ||
} | ||
|
||
fn foo() -> Result<u8, u64> { //~ ERROR mismatched types | ||
Ok(1) | ||
} | ||
|
||
fn main() { | ||
let x = plus_one(5); | ||
let _ = foo(); | ||
println!("X = {}", x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// check-pass | ||
// run-rustfix | ||
|
||
#![allow(incomplete_features)] | ||
#![warn(unused_braces)] | ||
|
||
#![feature(const_generics)] | ||
|
||
struct A<const N: usize>; | ||
|
||
fn main() { | ||
let _: A<7>; // ok | ||
let _: A< 7 >; //~ WARN unnecessary braces | ||
let _: A<{ 3 + 5 }>; // ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/unused_braces.rs:4:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
warning: unnecessary braces around const expression | ||
--> $DIR/unused_braces.rs:11:14 | ||
--> $DIR/unused_braces.rs:13:14 | ||
| | ||
LL | let _: A<{ 7 }>; | ||
| ^^^^^ help: remove these braces | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused_braces.rs:2:9 | ||
--> $DIR/unused_braces.rs:5:9 | ||
| | ||
LL | #![warn(unused_braces)] | ||
| ^^^^^^^^^^^^^ | ||
|
||
warning: 2 warnings emitted | ||
warning: 1 warning emitted | ||
|
5 changes: 5 additions & 0 deletions
5
src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
let _x = !1; //~ ERROR cannot be used as a unary operator | ||
} |
4 changes: 3 additions & 1 deletion
4
src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
let x = ~1; //~ ERROR cannot be used as a unary operator | ||
let _x = ~1; //~ ERROR cannot be used as a unary operator | ||
} |
6 changes: 3 additions & 3 deletions
6
src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error: `~` cannot be used as a unary operator | ||
--> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:2:13 | ||
--> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:4:14 | ||
| | ||
LL | let x = ~1; | ||
| ^ help: use `!` to perform bitwise not | ||
LL | let _x = ~1; | ||
| ^ help: use `!` to perform bitwise not | ||
|
||
error: aborting due to previous error | ||
|
69 changes: 69 additions & 0 deletions
69
src/test/ui/did_you_mean/issue-54109-without-witness.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// run-rustfix | ||
|
||
// This test is to check if suggestions can be applied automatically. | ||
|
||
#![allow(dead_code, unused_parens)] | ||
|
||
fn main() {} | ||
|
||
fn test_and() { | ||
let a = true; | ||
let b = false; | ||
|
||
let _ = a && b; //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
|
||
if a && b { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_or() { | ||
let a = true; | ||
let b = false; | ||
|
||
let _ = a || b; //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
|
||
if a || b { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_and_par() { | ||
let a = true; | ||
let b = false; | ||
if (a && b) { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_or_par() { | ||
let a = true; | ||
let b = false; | ||
if (a || b) { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_while_and() { | ||
let a = true; | ||
let b = false; | ||
while a && b { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_while_or() { | ||
let a = true; | ||
let b = false; | ||
while a || b { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// run-rustfix | ||
|
||
// This test is to check if suggestions can be applied automatically. | ||
|
||
#![allow(dead_code, unused_parens)] | ||
|
||
fn main() {} | ||
|
||
fn test_and() { | ||
let a = true; | ||
let b = false; | ||
|
||
let _ = a and b; //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
|
||
if a and b { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_or() { | ||
let a = true; | ||
let b = false; | ||
|
||
let _ = a or b; //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
|
||
if a or b { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_and_par() { | ||
let a = true; | ||
let b = false; | ||
if (a and b) { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_or_par() { | ||
let a = true; | ||
let b = false; | ||
if (a or b) { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_while_and() { | ||
let a = true; | ||
let b = false; | ||
while a and b { //~ ERROR `and` is not a logical operator | ||
//~| ERROR `and` is not a logical operator | ||
println!("both"); | ||
} | ||
} | ||
|
||
fn test_while_or() { | ||
let a = true; | ||
let b = false; | ||
while a or b { //~ ERROR `or` is not a logical operator | ||
//~| ERROR `or` is not a logical operator | ||
println!("both"); | ||
} | ||
} |
Oops, something went wrong.