[never_loop
]: recognize ?
desugaring in try blocks
This commit is contained in:
parent
66c29b973b
commit
ff5afac616
@ -201,12 +201,12 @@ fn never_loop_expr<'tcx>(
|
||||
})
|
||||
})
|
||||
},
|
||||
ExprKind::Block(b, l) => {
|
||||
if l.is_some() {
|
||||
ExprKind::Block(b, _) => {
|
||||
if b.targeted_by_break {
|
||||
local_labels.push((b.hir_id, false));
|
||||
}
|
||||
let ret = never_loop_block(cx, b, local_labels, main_loop_id);
|
||||
let jumped_to = l.is_some() && local_labels.pop().unwrap().1;
|
||||
let jumped_to = b.targeted_by_break && local_labels.pop().unwrap().1;
|
||||
match ret {
|
||||
NeverLoopResult::Diverging if jumped_to => NeverLoopResult::Normal,
|
||||
_ => ret,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(inline_const)]
|
||||
#![feature(inline_const, try_blocks)]
|
||||
#![allow(
|
||||
clippy::eq_op,
|
||||
clippy::single_match,
|
||||
@ -400,6 +400,15 @@ pub fn test32() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn issue12205() -> Option<()> {
|
||||
loop {
|
||||
let _: Option<_> = try {
|
||||
None?;
|
||||
return Some(());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
test2();
|
||||
|
Loading…
x
Reference in New Issue
Block a user