Skip to content

Commit

Permalink
Remove hack for filtering out param-env outlives that match item-boun…
Browse files Browse the repository at this point in the history
…d outlives
  • Loading branch information
compiler-errors committed Jan 2, 2025
1 parent 7f75bfa commit f364674
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,26 +388,9 @@ where
// Compute the bounds we can derive from the environment. This
// is an "approximate" match -- in some cases, these bounds
// may not apply.
let mut approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
let approx_env_bounds = self.verify_bound.approx_declared_bounds_from_env(alias_ty);
debug!(?approx_env_bounds);

// Remove outlives bounds that we get from the environment but
// which are also deducible from the trait. This arises (cc
// #55756) in cases where you have e.g., `<T as Foo<'a>>::Item:
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
// }` in the trait definition.
approx_env_bounds.retain(|bound_outlives| {
// OK to skip binder because we only manipulate and compare against other values from
// the same binder. e.g. if we have (e.g.) `for<'a> <T as Trait<'a>>::Item: 'a` in
// `bound`, the `'a` will be a `^1` (bound, debruijn index == innermost) region. If the
// declaration is `trait Trait<'b> { type Item: 'b; }`, then
// `projection_declared_bounds_from_trait` will be invoked with `['b => ^1]` and so we
// will get `^1` returned.
let bound = bound_outlives.skip_binder();
let ty::Alias(_, alias_ty) = bound.0.kind() else { bug!("expected AliasTy") };
self.verify_bound.declared_bounds_from_definition(*alias_ty).all(|r| r != bound.1)
});

// If declared bounds list is empty, the only applicable rule is
// OutlivesProjectionComponent. If there are inference variables,
// then, we can break down the outlives into more primitive
Expand Down

0 comments on commit f364674

Please sign in to comment.