1
Fork 0

A non-minimal set of TraitRefBoundarys to work on removing from_poly_trait_ref

This commit is contained in:
Jack Huey 2021-04-12 09:26:39 -04:00
parent ba3d22ed66
commit 32942ab807

View file

@ -638,6 +638,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} }
Scope::Binder { binder_depth, from_poly_trait_ref, .. } => { Scope::Binder { binder_depth, from_poly_trait_ref, .. } => {
if concanetate && !passed_boundary && !from_poly_trait_ref {
bug!("{:?}", self.scope);
}
break if concanetate { break if concanetate {
if passed_boundary || !from_poly_trait_ref { if passed_boundary || !from_poly_trait_ref {
binder_depth + 1 binder_depth + 1
@ -850,8 +853,11 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
}; };
self.with(scope, |old_scope, this| { self.with(scope, |old_scope, this| {
this.check_lifetime_params(old_scope, &generics.params); this.check_lifetime_params(old_scope, &generics.params);
let scope = Scope::TraitRefBoundary { s: this.scope };
this.with(scope, |_, this| {
intravisit::walk_item(this, item); intravisit::walk_item(this, item);
}); });
});
self.missing_named_lifetime_spots.pop(); self.missing_named_lifetime_spots.pop();
} }
} }
@ -985,9 +991,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// Elided lifetimes are not allowed in non-return // Elided lifetimes are not allowed in non-return
// position impl Trait // position impl Trait
let scope = Scope::Elision { elide: Elide::Forbid, s: self.scope }; let scope = Scope::TraitRefBoundary { s: self.scope };
self.with(scope, |_, this| { self.with(scope, |_, this| {
let scope = Scope::Elision { elide: Elide::Forbid, s: this.scope };
this.with(scope, |_, this| {
intravisit::walk_item(this, opaque_ty); intravisit::walk_item(this, opaque_ty);
})
}); });
return; return;
@ -1320,21 +1329,23 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
if !self.trait_definition_only { if !self.trait_definition_only {
check_mixed_explicit_and_in_band_defs(self.tcx, &generics.params); check_mixed_explicit_and_in_band_defs(self.tcx, &generics.params);
} }
let scope = Scope::TraitRefBoundary { s: self.scope };
self.with(scope, |_, this| {
for param in generics.params { for param in generics.params {
match param.kind { match param.kind {
GenericParamKind::Lifetime { .. } => {} GenericParamKind::Lifetime { .. } => {}
GenericParamKind::Type { ref default, .. } => { GenericParamKind::Type { ref default, .. } => {
walk_list!(self, visit_param_bound, param.bounds); walk_list!(this, visit_param_bound, param.bounds);
if let Some(ref ty) = default { if let Some(ref ty) = default {
self.visit_ty(&ty); this.visit_ty(&ty);
} }
} }
GenericParamKind::Const { ref ty, .. } => { GenericParamKind::Const { ref ty, .. } => {
let was_in_const_generic = self.is_in_const_generic; let was_in_const_generic = this.is_in_const_generic;
self.is_in_const_generic = true; this.is_in_const_generic = true;
walk_list!(self, visit_param_bound, param.bounds); walk_list!(this, visit_param_bound, param.bounds);
self.visit_ty(&ty); this.visit_ty(&ty);
self.is_in_const_generic = was_in_const_generic; this.is_in_const_generic = was_in_const_generic;
} }
} }
} }
@ -1356,14 +1367,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.enumerate() .enumerate()
.map(|(late_bound_idx, param)| { .map(|(late_bound_idx, param)| {
let pair = let pair =
Region::late(late_bound_idx as u32, &self.tcx.hir(), param); Region::late(late_bound_idx as u32, &this.tcx.hir(), param);
let r = late_region_as_bound_region(self.tcx, &pair.1); let r = late_region_as_bound_region(this.tcx, &pair.1);
(pair, r) (pair, r)
}) })
.unzip(); .unzip();
self.map.late_bound_vars.insert(bounded_ty.hir_id, binders.clone()); this.map.late_bound_vars.insert(bounded_ty.hir_id, binders.clone());
let scope = Scope::TraitRefBoundary { s: self.scope };
self.with(scope, |_, this| {
if !lifetimes.is_empty() { if !lifetimes.is_empty() {
let next_early_index = this.next_early_index(); let next_early_index = this.next_early_index();
let scope = Scope::Binder { let scope = Scope::Binder {
@ -1387,26 +1396,26 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
this.visit_ty(&bounded_ty); this.visit_ty(&bounded_ty);
walk_list!(this, visit_param_bound, bounds); walk_list!(this, visit_param_bound, bounds);
} }
})
} }
&hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { &hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
ref lifetime, ref lifetime,
bounds, bounds,
.. ..
}) => { }) => {
self.visit_lifetime(lifetime); this.visit_lifetime(lifetime);
walk_list!(self, visit_param_bound, bounds); walk_list!(this, visit_param_bound, bounds);
} }
&hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { &hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
ref lhs_ty, ref lhs_ty,
ref rhs_ty, ref rhs_ty,
.. ..
}) => { }) => {
self.visit_ty(lhs_ty); this.visit_ty(lhs_ty);
self.visit_ty(rhs_ty); this.visit_ty(rhs_ty);
} }
} }
} }
})
} }
fn visit_param_bound(&mut self, bound: &'tcx hir::GenericBound<'tcx>) { fn visit_param_bound(&mut self, bound: &'tcx hir::GenericBound<'tcx>) {