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:
parent
348f26e409
commit
f8f5d7aab2
@ -116,34 +116,33 @@ 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
|
|
||||||
.super_predicates_of(inner_most_trait_ref.def_id())
|
|
||||||
.predicates
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(move |(pred, _)| {
|
|
||||||
pred.subst_supertrait(tcx, &inner_most_trait_ref).as_trait_clause()
|
|
||||||
});
|
|
||||||
|
|
||||||
'diving_in_skip_visited_traits: loop {
|
let mut direct_super_traits_iter = tcx
|
||||||
if let Some(next_super_trait) = direct_super_traits_iter.next() {
|
.super_predicates_of(inner_most_trait_ref.def_id())
|
||||||
if visited.insert(next_super_trait.to_predicate(tcx)) {
|
.predicates
|
||||||
// We're throwing away potential constness of super traits here.
|
.into_iter()
|
||||||
// FIXME: handle ~const super traits
|
.filter_map(move |(pred, _)| {
|
||||||
let next_super_trait = next_super_trait.map_bound(|t| t.trait_ref);
|
pred.subst_supertrait(tcx, &inner_most_trait_ref).as_trait_clause()
|
||||||
stack.push((
|
});
|
||||||
next_super_trait,
|
|
||||||
emit_vptr_on_new_entry,
|
'diving_in_skip_visited_traits: loop {
|
||||||
Some(direct_super_traits_iter),
|
if let Some(next_super_trait) = direct_super_traits_iter.next() {
|
||||||
));
|
if visited.insert(next_super_trait.to_predicate(tcx)) {
|
||||||
break 'diving_in_skip_visited_traits;
|
// We're throwing away potential constness of super traits here.
|
||||||
} else {
|
// FIXME: handle ~const super traits
|
||||||
continue 'diving_in_skip_visited_traits;
|
let next_super_trait = next_super_trait.map_bound(|t| t.trait_ref);
|
||||||
}
|
stack.push((
|
||||||
|
next_super_trait,
|
||||||
|
emit_vptr_on_new_entry,
|
||||||
|
Some(direct_super_traits_iter),
|
||||||
|
));
|
||||||
|
break 'diving_in_skip_visited_traits;
|
||||||
} else {
|
} else {
|
||||||
break 'diving_in;
|
continue 'diving_in_skip_visited_traits;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
break 'diving_in;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user