From 917ad034cc89ecdde85771238d0d8f89813290fb Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 20 Mar 2024 22:51:29 +0100 Subject: [PATCH] Fixes in various places --- clippy_utils/src/lib.rs | 1 + tests/ui/single_match_else.fixed | 2 +- tests/ui/single_match_else.rs | 2 +- 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 af74e4b67..28755ae07 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 e840adf0f..163be16ad 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::::Ok(1) { println!("${:?}", a) } else { + if let Ok(a) = Result::::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 430c4da20..3f1fd2b31 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::::Ok(1) { + match Result::::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 f8f88379d..61c348260 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::::Ok(1) { +LL | / match Result::::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::::Ok(1) { println!("${:?}", a) } else { +LL ~ if let Ok(a) = Result::::Ok(1) { println!("${:?}", a) } else { LL + println!("else block"); LL + return; LL + }