From fceeb133995b50bddc3df6cf58c4ce684a64fcf3 Mon Sep 17 00:00:00 2001 From: yaxum62 Date: Mon, 15 Jul 2024 21:21:52 -0700 Subject: Add test for `try_err` lint within try blocks. --- tests/ui/try_err.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 { } Ok(0) } + +// Test that the lint is suppressed in try block. +pub fn try_block() -> Result<(), i32> { + let _: Result<_, i32> = try { + Err(1)?; + }; + Ok(()) +} -- cgit 1.4.1-3-g733a5 From 1821defc39d410b3f761dbc0bae45e7ac1e6d585 Mon Sep 17 00:00:00 2001 From: yaxum62 Date: Mon, 15 Jul 2024 21:54:15 -0700 Subject: add expected output for try_err test --- tests/ui/try_err.fixed | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/ui/try_err.fixed b/tests/ui/try_err.fixed index aae4f8ac47f..f149bfb7774 100644 --- a/tests/ui/try_err.fixed +++ b/tests/ui/try_err.fixed @@ -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 { } Ok(0) } + +// Test that the lint is suppressed in try block. +pub fn try_block() -> Result<(), i32> { + let _: Result<_, i32> = try { + Err(1)?; + }; + Ok(()) +} -- cgit 1.4.1-3-g733a5