mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
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 {
|
||||
// dive deeper into the stack, recording the path
|
||||
'diving_in: loop {
|
||||
if let Some((inner_most_trait_ref, _, _)) = stack.last() {
|
||||
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()
|
||||
});
|
||||
let &(inner_most_trait_ref, _, _) = stack.last().unwrap();
|
||||
|
||||
'diving_in_skip_visited_traits: loop {
|
||||
if let Some(next_super_trait) = direct_super_traits_iter.next() {
|
||||
if visited.insert(next_super_trait.to_predicate(tcx)) {
|
||||
// We're throwing away potential constness of super traits here.
|
||||
// FIXME: handle ~const super 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 {
|
||||
continue 'diving_in_skip_visited_traits;
|
||||
}
|
||||
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 {
|
||||
if let Some(next_super_trait) = direct_super_traits_iter.next() {
|
||||
if visited.insert(next_super_trait.to_predicate(tcx)) {
|
||||
// We're throwing away potential constness of super traits here.
|
||||
// FIXME: handle ~const super 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 {
|
||||
break 'diving_in;
|
||||
continue 'diving_in_skip_visited_traits;
|
||||
}
|
||||
} else {
|
||||
break 'diving_in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user