about summary refs log tree commit diff
diff options
context:
space:
mode:
authoryaxum62 <yaxum62@gmail.com>2024-07-15 21:21:52 -0700
committeryaxum62 <yaxum62@gmail.com>2024-07-15 21:21:52 -0700
commitfceeb133995b50bddc3df6cf58c4ce684a64fcf3 (patch)
treeb632b7742ed5c4cbb661c2d023c9a5ecd1506c7d
parenteb4d88e690c431691bc0fd8eaa9f7096ecc2a723 (diff)
downloadrust-fceeb133995b50bddc3df6cf58c4ce684a64fcf3.tar.gz
rust-fceeb133995b50bddc3df6cf58c4ce684a64fcf3.zip
Add test for `try_err` lint within try blocks.
-rw-r--r--tests/ui/try_err.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/ui/try_err.rs b/tests/ui/try_err.rs
index 927eccf2d54..841ec6b5d5c 100644
--- a/tests/ui/try_err.rs
+++ b/tests/ui/try_err.rs
@@ -1,5 +1,5 @@
 //@aux-build:proc_macros.rs
-
+#![feature(try_blocks)]
 #![deny(clippy::try_err)]
 #![allow(
     clippy::unnecessary_wraps,
@@ -152,3 +152,11 @@ pub fn try_return(x: bool) -> Result<i32, i32> {
     }
     Ok(0)
 }
+
+// Test that the lint is suppressed in try block.
+pub fn try_block() -> Result<(), i32> {
+    let _: Result<_, i32> = try {
+        Err(1)?;
+    };
+    Ok(())
+}