Skip to content

Commit f58950d

Browse files
committedJan 26, 2024
correct lint case
1 parent 57dd25e commit f58950d

3 files changed

+42
-1
lines changed
 

‎tests/ui/needless_return_with_question_mark.fixed

+18
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,21 @@ fn issue11982() {
104104
Ok(())
105105
}
106106
}
107+
108+
fn issue11982_no_conversion() {
109+
mod bar {
110+
pub struct Error;
111+
pub fn foo(_: bool) -> Result<(), Error> {
112+
Ok(())
113+
}
114+
}
115+
116+
fn foo(ok: bool) -> Result<(), bar::Error> {
117+
if !ok {
118+
bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?;
119+
//~^ ERROR: unneeded `return` statement with `?` operator
120+
};
121+
Ok(())
122+
}
123+
124+
}

‎tests/ui/needless_return_with_question_mark.rs

+17
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,20 @@ fn issue11982() {
104104
Ok(())
105105
}
106106
}
107+
108+
fn issue11982_no_conversion() {
109+
mod bar {
110+
pub struct Error;
111+
pub fn foo(_: bool) -> Result<(), Error> {
112+
Ok(())
113+
}
114+
}
115+
116+
fn foo(ok: bool) -> Result<(), bar::Error> {
117+
if !ok {
118+
return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?;
119+
//~^ ERROR: unneeded `return` statement with `?` operator
120+
};
121+
Ok(())
122+
}
123+
}

‎tests/ui/needless_return_with_question_mark.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,11 @@ error: unneeded `return` statement with `?` operator
1313
LL | return Err(())?;
1414
| ^^^^^^^ help: remove it
1515

16-
error: aborting due to 2 previous errors
16+
error: unneeded `return` statement with `?` operator
17+
--> $DIR/needless_return_with_question_mark.rs:118:13
18+
|
19+
LL | return bar::foo(ok).map(|_| Ok::<(), bar::Error>(()))?;
20+
| ^^^^^^^ help: remove it
21+
22+
error: aborting due to 3 previous errors
1723

0 commit comments

Comments
 (0)