Replace if let with unwrap in prepare_vtable_segments

Reasoning: if the stack is empty, the loop will be infinite,
so the assumption is that the stack can't be non empty. Unwrap
makes the assumption more clear (and removes an indentation level)
This commit is contained in:
Maybe Waffle 2023-07-19 09:49:13 +00:00
parent 348f26e409
commit f8f5d7aab2

View File

@ -116,8 +116,8 @@ fn prepare_vtable_segments_inner<'tcx, T>(
loop { loop {
// dive deeper into the stack, recording the path // dive deeper into the stack, recording the path
'diving_in: loop { 'diving_in: loop {
if let Some((inner_most_trait_ref, _, _)) = stack.last() { let &(inner_most_trait_ref, _, _) = stack.last().unwrap();
let inner_most_trait_ref = *inner_most_trait_ref;
let mut direct_super_traits_iter = tcx let mut direct_super_traits_iter = tcx
.super_predicates_of(inner_most_trait_ref.def_id()) .super_predicates_of(inner_most_trait_ref.def_id())
.predicates .predicates
@ -146,7 +146,6 @@ fn prepare_vtable_segments_inner<'tcx, T>(
} }
} }
} }
}
// Other than the left-most path, vptr should be emitted for each trait. // Other than the left-most path, vptr should be emitted for each trait.
emit_vptr_on_new_entry = true; emit_vptr_on_new_entry = true;