diff options
| author | Quinn Sinclair <me@partiallytyped.dev> | 2024-01-26 23:48:47 +0100 |
|---|---|---|
| committer | Quinn Sinclair <me@partiallytyped.dev> | 2024-01-26 23:48:47 +0100 |
| commit | f58950de86f36ac41a7eed134529c76e4da3a552 (patch) | |
| tree | f42127c16ac5090353349353ac122ffbb9f9db68 | |
| parent | 57dd25e2ffbf9c7abd63fcdf057facff7a46c342 (diff) | |
| download | rust-f58950de86f36ac41a7eed134529c76e4da3a552.tar.gz rust-f58950de86f36ac41a7eed134529c76e4da3a552.zip | |
correct lint case
| -rw-r--r-- | tests/ui/needless_return_with_question_mark.fixed | 18 | ||||
| -rw-r--r-- | tests/ui/needless_return_with_question_mark.rs | 17 | ||||
| -rw-r--r-- | tests/ui/needless_return_with_question_mark.stderr | 8 |
3 files changed, 42 insertions, 1 deletions
diff --git a/tests/ui/needless_return_with_question_mark.fixed b/tests/ui/needless_return_with_question_mark.fixed index 8a97d8604a5..2b0a835bc7f 100644 --- a/tests/ui/needless_return_with_question_mark.fixed +++ b/tests/ui/needless_return_with_question_mark.fixed @@ -104,3 +104,21 @@ fn issue11982() { Ok(()) } } + +fn issue11982_no_conversion() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + fn foo(ok: bool) -> Result<(), bar::Error> { + if !ok { + bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?; + //~^ ERROR: unneeded `return` statement with `?` operator + }; + Ok(()) + } + +} diff --git a/tests/ui/needless_return_with_question_mark.rs b/tests/ui/needless_return_with_question_mark.rs index be15b000f5d..ecbf00254f0 100644 --- a/tests/ui/needless_return_with_question_mark.rs +++ b/tests/ui/needless_return_with_question_mark.rs @@ -104,3 +104,20 @@ fn issue11982() { Ok(()) } } + +fn issue11982_no_conversion() { + mod bar { + pub struct Error; + pub fn foo(_: bool) -> Result<(), Error> { + Ok(()) + } + } + + fn foo(ok: bool) -> Result<(), bar::Error> { + if !ok { + return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?; + //~^ ERROR: unneeded `return` statement with `?` operator + }; + Ok(()) + } +} diff --git a/tests/ui/needless_return_with_question_mark.stderr b/tests/ui/needless_return_with_question_mark.stderr index 17aa212ae8d..59c212bcbb3 100644 --- a/tests/ui/needless_return_with_question_mark.stderr +++ b/tests/ui/needless_return_with_question_mark.stderr @@ -13,5 +13,11 @@ error: unneeded `return` statement with `?` operator LL | return Err(())?; | ^^^^^^^ help: remove it -error: aborting due to 2 previous errors +error: unneeded `return` statement with `?` operator + --> $DIR/needless_return_with_question_mark.rs:118:13 + | +LL | return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?; + | ^^^^^^^ help: remove it + +error: aborting due to 3 previous errors |
