Skip to content

Commit 87d61f2

Browse files
Don't track visited outlives bounds when decomposing verify for alias
1 parent ed7e35f commit 87d61f2

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ where
471471
// projection outlive; in some cases, this may add insufficient
472472
// edges into the inference graph, leading to inference failures
473473
// even though a satisfactory solution exists.
474-
let verify_bound = self.verify_bound.alias_bound(alias_ty, &mut Default::default());
474+
let verify_bound = self.verify_bound.alias_bound(alias_ty);
475475
debug!("alias_must_outlive: pushing {:?}", verify_bound);
476476
self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound);
477477
}

compiler/rustc_infer/src/infer/outlives/verify.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::infer::outlives::env::RegionBoundPairs;
22
use crate::infer::region_constraints::VerifyIfEq;
33
use crate::infer::{GenericKind, VerifyBound};
4-
use rustc_data_structures::sso::SsoHashSet;
5-
use rustc_middle::ty::GenericArg;
64
use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
75
use rustc_type_ir::outlives::{compute_alias_components_recursive, Component};
86

@@ -99,12 +97,8 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
9997
self.declared_generic_bounds_from_env_for_erased_ty(erased_alias_ty)
10098
}
10199

102-
#[instrument(level = "debug", skip(self, visited))]
103-
pub fn alias_bound(
104-
&self,
105-
alias_ty: ty::AliasTy<'tcx>,
106-
visited: &mut SsoHashSet<GenericArg<'tcx>>,
107-
) -> VerifyBound<'tcx> {
100+
#[instrument(level = "debug", skip(self))]
101+
pub fn alias_bound(&self, alias_ty: ty::AliasTy<'tcx>) -> VerifyBound<'tcx> {
108102
let alias_ty_as_ty = alias_ty.to_ty(self.tcx);
109103

110104
// Search the env for where clauses like `P: 'a`.
@@ -130,21 +124,22 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
130124
// see the extensive comment in projection_must_outlive
131125
let recursive_bound = {
132126
let mut components = smallvec![];
133-
compute_alias_components_recursive(self.tcx, alias_ty_as_ty, &mut components, visited);
134-
self.bound_from_components(&components, visited)
127+
compute_alias_components_recursive(
128+
self.tcx,
129+
alias_ty_as_ty,
130+
&mut components,
131+
&mut Default::default(),
132+
);
133+
self.bound_from_components(&components)
135134
};
136135

137136
VerifyBound::AnyBound(env_bounds.chain(definition_bounds).collect()).or(recursive_bound)
138137
}
139138

140-
fn bound_from_components(
141-
&self,
142-
components: &[Component<TyCtxt<'tcx>>],
143-
visited: &mut SsoHashSet<GenericArg<'tcx>>,
144-
) -> VerifyBound<'tcx> {
139+
fn bound_from_components(&self, components: &[Component<TyCtxt<'tcx>>]) -> VerifyBound<'tcx> {
145140
let mut bounds = components
146141
.iter()
147-
.map(|component| self.bound_from_single_component(component, visited))
142+
.map(|component| self.bound_from_single_component(component))
148143
// Remove bounds that must hold, since they are not interesting.
149144
.filter(|bound| !bound.must_hold());
150145

@@ -159,18 +154,15 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
159154
fn bound_from_single_component(
160155
&self,
161156
component: &Component<TyCtxt<'tcx>>,
162-
visited: &mut SsoHashSet<GenericArg<'tcx>>,
163157
) -> VerifyBound<'tcx> {
164158
match *component {
165159
Component::Region(lt) => VerifyBound::OutlivedBy(lt),
166160
Component::Param(param_ty) => self.param_or_placeholder_bound(param_ty.to_ty(self.tcx)),
167161
Component::Placeholder(placeholder_ty) => {
168162
self.param_or_placeholder_bound(Ty::new_placeholder(self.tcx, placeholder_ty))
169163
}
170-
Component::Alias(alias_ty) => self.alias_bound(alias_ty, visited),
171-
Component::EscapingAlias(ref components) => {
172-
self.bound_from_components(components, visited)
173-
}
164+
Component::Alias(alias_ty) => self.alias_bound(alias_ty),
165+
Component::EscapingAlias(ref components) => self.bound_from_components(components),
174166
Component::UnresolvedInferenceVariable(v) => {
175167
// Ignore this, we presume it will yield an error later, since
176168
// if a type variable is not resolved by this point it never

0 commit comments

Comments
 (0)