diff options
| author | WeiTheShinobi <weitheshinobi@gmail.com> | 2024-09-06 23:10:42 +0800 |
|---|---|---|
| committer | WeiTheShinobi <weitheshinobi@gmail.com> | 2024-09-06 23:10:42 +0800 |
| commit | e3ca249e9647396b9a3849e147aa53e168cf4c73 (patch) | |
| tree | 2150541873fcc1854236e738f3ef8085f9fc7200 /tests | |
| parent | 04d70d04fcf9412d7006ee4646f56f8bf5f2149f (diff) | |
| download | rust-e3ca249e9647396b9a3849e147aa53e168cf4c73.tar.gz rust-e3ca249e9647396b9a3849e147aa53e168cf4c73.zip | |
fix `single_match` suggestion
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/single_match.fixed | 10 | ||||
| -rw-r--r-- | tests/ui/single_match.rs | 15 | ||||
| -rw-r--r-- | tests/ui/single_match.stderr | 33 | ||||
| -rw-r--r-- | tests/ui/single_match_else.fixed | 2 | ||||
| -rw-r--r-- | tests/ui/single_match_else.stderr | 2 |
5 files changed, 55 insertions, 7 deletions
diff --git a/tests/ui/single_match.fixed b/tests/ui/single_match.fixed index 04129ec0f13..dcf5a1d33c2 100644 --- a/tests/ui/single_match.fixed +++ b/tests/ui/single_match.fixed @@ -304,13 +304,19 @@ const DATA: Data = Data([1, 2, 3, 4]); const CONST_I32: i32 = 1; fn irrefutable_match() { - { println!() } + println!(); - { println!() } + println!(); let i = 0; { let a = 1; let b = 2; } + + + + + + println!() } diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index 2d51cee3fd9..3ba5eebd01b 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -386,4 +386,19 @@ fn irrefutable_match() { }, _ => {}, } + + match i { + i => {}, + _ => {}, + } + + match i { + i => (), + _ => (), + } + + match CONST_I32 { + CONST_I32 => println!(), + _ => {}, + } } diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index 9578421d2ce..9240b09c50a 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -223,7 +223,7 @@ LL | / match DATA { LL | | DATA => println!(), LL | | _ => {}, LL | | } - | |_____^ help: try: `{ println!() }` + | |_____^ help: try: `println!();` error: this pattern is irrefutable, `match` is useless --> tests/ui/single_match.rs:376:5 @@ -232,7 +232,7 @@ LL | / match CONST_I32 { LL | | CONST_I32 => println!(), LL | | _ => {}, LL | | } - | |_____^ help: try: `{ println!() }` + | |_____^ help: try: `println!();` error: this pattern is irrefutable, `match` is useless --> tests/ui/single_match.rs:382:5 @@ -254,5 +254,32 @@ LL + let b = 2; LL + } | -error: aborting due to 23 previous errors +error: this pattern is irrefutable, `match` is useless + --> tests/ui/single_match.rs:390:5 + | +LL | / match i { +LL | | i => {}, +LL | | _ => {}, +LL | | } + | |_____^ help: `match` expression can be removed + +error: this pattern is irrefutable, `match` is useless + --> tests/ui/single_match.rs:395:5 + | +LL | / match i { +LL | | i => (), +LL | | _ => (), +LL | | } + | |_____^ help: `match` expression can be removed + +error: this pattern is irrefutable, `match` is useless + --> tests/ui/single_match.rs:400:5 + | +LL | / match CONST_I32 { +LL | | CONST_I32 => println!(), +LL | | _ => {}, +LL | | } + | |_____^ help: try: `println!()` + +error: aborting due to 26 previous errors diff --git a/tests/ui/single_match_else.fixed b/tests/ui/single_match_else.fixed index fb57411aaa4..c2ca746976b 100644 --- a/tests/ui/single_match_else.fixed +++ b/tests/ui/single_match_else.fixed @@ -173,5 +173,5 @@ fn issue_10808(bar: Option<i32>) { } fn irrefutable_match() -> Option<&'static ExprNode> { - { Some(&NODE) } + Some(&NODE) } diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 61209053fd0..a2801751a43 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -207,7 +207,7 @@ LL | | let x = 5; LL | | None LL | | }, LL | | } - | |_____^ help: try: `{ Some(&NODE) }` + | |_____^ help: try: `Some(&NODE)` error: aborting due to 10 previous errors |
