Closed
Description
Summary
Inspired by #11613. It's similar but imo not quite the same issue. This one is more about coercions:
fn foo() -> Result<(), ()> {
let _x: String = {
return Err(())?; // <--- should not lint here
};
Ok(())
}
return
's never type is used to get typeck to coerce the type of the block to something else, but that won't happen with its suggestion (just Err(...)?
).
It might be that the block here has the NeverToAny
adjust that we can use to suppress the lint in these cases.
Lint Name
needless_return_with_question_mark
Reproducer
🆙
Version
rustc 1.74.0-nightly (37390d656 2023-09-24)
binary: rustc
commit-hash: 37390d65636dd67e263753a3c04fbc60dcc4348e
commit-date: 2023-09-24
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0
Additional Labels
@rustbot label +I-suggestion-causes-error