Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ use rustc_middle::query::Providers;
use rustc_middle::traits::solve::NoSolution;
use rustc_middle::ty::trait_def::TraitSpecializationKind;
use rustc_middle::ty::{
self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFlags,
TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
Upcast,
self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable,
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Upcast,
};
use rustc_middle::{bug, span_bug};
use rustc_session::parse::feature_err;
Expand Down Expand Up @@ -2349,8 +2348,11 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
if let ty::ClauseKind::WellFormed(..) = pred.kind().skip_binder() {
continue;
}
// Match the existing behavior.
if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) {
// Match the existing behavior and carve out an exception for `for<'a> Ty: Trait`.
if pred.is_global()
&& !pred.kind().skip_binder().has_escaping_bound_vars()
&& pred.kind().bound_vars().is_empty()
{
let pred = self.normalize(span, None, pred);

// only use the span of the predicate clause (#90869)
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,9 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
//
// Our handling of where-bounds is generally fairly messy but necessary for backwards
// compatibility, see #50825 for why we need to handle global where-bounds like this.
let is_global = |c: ty::PolyTraitPredicate<'tcx>| c.is_global() && !c.has_bound_vars();
let is_global = |c: ty::PolyTraitPredicate<'tcx>| {
c.is_global() && !c.skip_binder().has_escaping_bound_vars()
};
let param_candidates = candidates
.iter()
.filter_map(|c| if let ParamCandidate(p) = c.candidate { Some(p) } else { None });
Expand Down
Loading