Address review comments
This commit is contained in:
parent
959801ff2e
commit
0f5759a005
1 changed files with 74 additions and 68 deletions
|
@ -2070,12 +2070,19 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
)
|
||||
});
|
||||
|
||||
let one_bound = bounds.next();
|
||||
let Some((bound_vars, assoc_item)) = bounds.next() else {
|
||||
// This will error in HIR lowering.
|
||||
self.tcx
|
||||
.dcx()
|
||||
.span_delayed_bug(path.span, "no resolution for RTN path");
|
||||
return;
|
||||
};
|
||||
|
||||
// Don't bail if we have identical bounds, which may be collected from
|
||||
// something like `T: Bound + Bound`, or via elaborating supertraits.
|
||||
for second_bound in bounds {
|
||||
if Some(&second_bound) != one_bound.as_ref() {
|
||||
for (second_vars, second_assoc_item) in bounds {
|
||||
if second_vars != bound_vars || second_assoc_item != assoc_item {
|
||||
// This will error in HIR lowering.
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
path.span,
|
||||
"ambiguous resolution for RTN path",
|
||||
|
@ -2084,13 +2091,6 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
let Some((bound_vars, assoc_item)) = one_bound else {
|
||||
self.tcx
|
||||
.dcx()
|
||||
.span_delayed_bug(path.span, "no resolution for RTN path");
|
||||
return;
|
||||
};
|
||||
|
||||
(bound_vars, assoc_item.def_id, item_segment)
|
||||
}
|
||||
// If we have a self type alias (in an impl), try to resolve an
|
||||
|
@ -2166,31 +2166,23 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
std::iter::from_coroutine(
|
||||
#[coroutine]
|
||||
move || {
|
||||
let mut next_scope = Some(self.scope);
|
||||
while let Some(current_scope) = next_scope {
|
||||
next_scope = None;
|
||||
let hir_id = match *current_scope {
|
||||
Scope::Binder { s, hir_id, .. } => {
|
||||
next_scope = Some(s);
|
||||
hir_id
|
||||
}
|
||||
Scope::Body { s, .. }
|
||||
| Scope::ObjectLifetimeDefault { s, .. }
|
||||
| Scope::Supertrait { s, .. }
|
||||
| Scope::TraitRefBoundary { s }
|
||||
| Scope::LateBoundary { s, .. }
|
||||
| Scope::Opaque { s, .. } => {
|
||||
next_scope = Some(s);
|
||||
continue;
|
||||
}
|
||||
Scope::Root { opt_parent_item } => {
|
||||
if let Some(parent_id) = opt_parent_item {
|
||||
self.tcx.local_def_id_to_hir_id(parent_id)
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
let mut scope = self.scope;
|
||||
loop {
|
||||
let hir_id = match *scope {
|
||||
Scope::Binder { hir_id, .. } => Some(hir_id),
|
||||
Scope::Root { opt_parent_item: Some(parent_def_id) } => {
|
||||
Some(self.tcx.local_def_id_to_hir_id(parent_def_id))
|
||||
}
|
||||
Scope::Body { .. }
|
||||
| Scope::ObjectLifetimeDefault { .. }
|
||||
| Scope::Supertrait { .. }
|
||||
| Scope::TraitRefBoundary { .. }
|
||||
| Scope::LateBoundary { .. }
|
||||
| Scope::Opaque { .. }
|
||||
| Scope::Root { opt_parent_item: None } => None,
|
||||
};
|
||||
|
||||
if let Some(hir_id) = hir_id {
|
||||
let node = self.tcx.hir_node(hir_id);
|
||||
// If this is a `Self` bound in a trait, yield the trait itself.
|
||||
// Specifically, we don't need to look at any supertraits since
|
||||
|
@ -2204,7 +2196,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
yield item.owner_id.def_id.to_def_id();
|
||||
} else if let Some(generics) = node.generics() {
|
||||
for pred in generics.predicates {
|
||||
let hir::WherePredicateKind::BoundPredicate(pred) = pred.kind else {
|
||||
let hir::WherePredicateKind::BoundPredicate(pred) = pred.kind
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let hir::TyKind::Path(hir::QPath::Resolved(None, bounded_path)) =
|
||||
|
@ -2232,9 +2225,22 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
match *scope {
|
||||
Scope::Binder { s, .. }
|
||||
| Scope::Body { s, .. }
|
||||
| Scope::ObjectLifetimeDefault { s, .. }
|
||||
| Scope::Supertrait { s, .. }
|
||||
| Scope::TraitRefBoundary { s }
|
||||
| Scope::LateBoundary { s, .. }
|
||||
| Scope::Opaque { s, .. } => {
|
||||
scope = s;
|
||||
}
|
||||
Scope::Root { .. } => break,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.fuse()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue