1
Fork 0

Rollup merge of #137633 - compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr

Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack

Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx.

Previously, we were using the implied bounds compat mode in two cases:
1. During WF, if it detects `ParamSet`
2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc.

While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code.

Fixes #137767
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-03-05 21:46:42 +08:00 committed by GitHub
commit 6c60abf51a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 264 additions and 269 deletions

View file

@ -508,6 +508,14 @@ impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T> {
}
}
impl<'tcx, T: Clone> Key for (CanonicalQueryInput<'tcx, T>, bool) {
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
}
impl Key for (Symbol, u32, u32) {
type Cache<V> = DefaultCache<Self, V>;

View file

@ -2262,22 +2262,13 @@ rustc_queries! {
desc { "normalizing `{}`", goal.value }
}
query implied_outlives_bounds_compat(
goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>
) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution,
> {
desc { "computing implied outlives bounds for `{}`", goal.canonical.value.value.ty }
}
query implied_outlives_bounds(
goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>
key: (CanonicalImpliedOutlivesBoundsGoal<'tcx>, bool)
) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution,
> {
desc { "computing implied outlives bounds v2 for `{}`", goal.canonical.value.value.ty }
desc { "computing implied outlives bounds for `{}` (hack disabled = {:?})", key.0.canonical.value.value.ty, key.1 }
}
/// Do not call this query directly: