Skip to content

Commit 8367af4

Browse files
resolve: support GenericBound::LangItemTrait
This commit modifies name resolution to ensure that new scopes are introduced from lang-item generic bounds. Co-authored-by: Matthew Jasper <[email protected]> Signed-off-by: David Wood <[email protected]>
1 parent 664ecf1 commit 8367af4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/librustc_resolve/late/lifetimes.rs

+28
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,24 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
941941
}
942942
}
943943

944+
fn visit_param_bound(&mut self, bound: &'tcx hir::GenericBound<'tcx>) {
945+
match bound {
946+
hir::GenericBound::LangItemTrait { .. } if !self.trait_ref_hack => {
947+
let scope = Scope::Binder {
948+
lifetimes: FxHashMap::default(),
949+
s: self.scope,
950+
next_early_index: self.next_early_index(),
951+
track_lifetime_uses: true,
952+
opaque_type_parent: false,
953+
};
954+
self.with(scope, |_, this| {
955+
intravisit::walk_param_bound(this, bound);
956+
});
957+
}
958+
_ => intravisit::walk_param_bound(self, bound),
959+
}
960+
}
961+
944962
fn visit_poly_trait_ref(
945963
&mut self,
946964
trait_ref: &'tcx hir::PolyTraitRef<'tcx>,
@@ -2296,6 +2314,16 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
22962314
self.outer_index.shift_out(1);
22972315
}
22982316

2317+
fn visit_param_bound(&mut self, bound: &hir::GenericBound<'_>) {
2318+
if let hir::GenericBound::LangItemTrait { .. } = bound {
2319+
self.outer_index.shift_in(1);
2320+
intravisit::walk_param_bound(self, bound);
2321+
self.outer_index.shift_out(1);
2322+
} else {
2323+
intravisit::walk_param_bound(self, bound);
2324+
}
2325+
}
2326+
22992327
fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
23002328
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
23012329
match lifetime {

0 commit comments

Comments
 (0)