diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-03-20 22:51:29 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-08-10 12:08:46 +0200 |
| commit | 917ad034cc89ecdde85771238d0d8f89813290fb (patch) | |
| tree | 282f143bc5be901cbf4f19f58a79822e6f37ee15 | |
| parent | 7591ec4e88f449cf27701c125a1a183dec2225af (diff) | |
| download | rust-917ad034cc89ecdde85771238d0d8f89813290fb.tar.gz rust-917ad034cc89ecdde85771238d0d8f89813290fb.zip | |
Fixes in various places
| -rw-r--r-- | clippy_utils/src/lib.rs | 1 | ||||
| -rw-r--r-- | tests/ui/single_match_else.fixed | 2 | ||||
| -rw-r--r-- | tests/ui/single_match_else.rs | 2 | ||||
| -rw-r--r-- | tests/ui/single_match_else.stderr | 4 |
4 files changed, 5 insertions, 4 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index af74e4b67c1..28755ae0710 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -2931,6 +2931,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU moved_before_use, same_ctxt, }, + #[allow(unreachable_patterns)] Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"), None => ExprUseCtxt { node: Node::Crate(cx.tcx.hir().root_module()), diff --git a/tests/ui/single_match_else.fixed b/tests/ui/single_match_else.fixed index e840adf0fa3..163be16ad8b 100644 --- a/tests/ui/single_match_else.fixed +++ b/tests/ui/single_match_else.fixed @@ -89,7 +89,7 @@ fn main() { // lint here use std::convert::Infallible; - if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else { + if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else { println!("else block"); return; } diff --git a/tests/ui/single_match_else.rs b/tests/ui/single_match_else.rs index 430c4da20f1..3f1fd2b3183 100644 --- a/tests/ui/single_match_else.rs +++ b/tests/ui/single_match_else.rs @@ -98,7 +98,7 @@ fn main() { // lint here use std::convert::Infallible; - match Result::<i32, Infallible>::Ok(1) { + match Result::<i32, &Infallible>::Ok(1) { Ok(a) => println!("${:?}", a), Err(_) => { println!("else block"); diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index f8f88379d6d..61c348260d0 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -64,7 +64,7 @@ LL + } error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> tests/ui/single_match_else.rs:101:5 | -LL | / match Result::<i32, Infallible>::Ok(1) { +LL | / match Result::<i32, &Infallible>::Ok(1) { LL | | Ok(a) => println!("${:?}", a), LL | | Err(_) => { LL | | println!("else block"); @@ -75,7 +75,7 @@ LL | | } | help: try | -LL ~ if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else { +LL ~ if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else { LL + println!("else block"); LL + return; LL + } |
