Fix unused variable warnings for diverging expressions#158846
Fix unused variable warnings for diverging expressions#158846chenyukang wants to merge 2 commits into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
d838658 to
4216015
Compare
| /// #[expect(unused_variables)] | ||
| /// fn example() -> i32 { | ||
| /// let x = { | ||
| /// return 5; | ||
| /// }; | ||
| /// } |
There was a problem hiding this comment.
For the case of
fn example() -> i32 {
let x = {
return 5;
};
}x is actually unused so i think perhaps we should still emit error for it? 🤔
There was a problem hiding this comment.
Yeah, I agree it's better to keep it.
but I haven't came out with a perfect fix for it, the following commit 8a2d4db is an attempt which seems ugly but workable way.
is_local_used_in_source should be enough for fixing the original issue, but I think we should still keep:
self.body.local_kind(local) == LocalKind::Temp
&& matches!(binding.opt_match_place, Some((None, _)))for a cheap checking.
Fixes #158783