diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/question_mark.fixed')
-rw-r--r-- | src/tools/clippy/tests/ui/question_mark.fixed | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/question_mark.fixed b/src/tools/clippy/tests/ui/question_mark.fixed index 7f1660f31..2d8920ccc 100644 --- a/src/tools/clippy/tests/ui/question_mark.fixed +++ b/src/tools/clippy/tests/ui/question_mark.fixed @@ -1,4 +1,5 @@ //@run-rustfix +#![feature(try_blocks)] #![allow(unreachable_code)] #![allow(dead_code)] #![allow(clippy::unnecessary_wraps)] @@ -227,6 +228,27 @@ fn pattern() -> Result<(), PatternedError> { fn main() {} +// `?` is not the same as `return None;` if inside of a try block +fn issue8628(a: Option<u32>) -> Option<u32> { + let b: Option<u32> = try { + if a.is_none() { + return None; + } + 32 + }; + b.or(Some(128)) +} + +fn issue6828_nested_body() -> Option<u32> { + try { + fn f2(a: Option<i32>) -> Option<i32> { + a?; + Some(32) + } + 123 + } +} + // should not lint, `?` operator not available in const context const fn issue9175(option: Option<()>) -> Option<()> { if option.is_none() { |