traits::project: yeet ParamEnv::reveal

This commit is contained in:
lcnr 2024-10-31 12:06:19 +01:00
parent 4d296eabe4
commit 84295b917d

View File

@ -16,7 +16,7 @@ use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedD
use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::fast_reject::DeepRejectCtxt;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{self, Term, Ty, TyCtxt, Upcast}; use rustc_middle::ty::{self, Term, Ty, TyCtxt, TypingMode, Upcast};
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
@ -975,18 +975,21 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
// and the obligation is monomorphic, otherwise passes such as // and the obligation is monomorphic, otherwise passes such as
// transmute checking and polymorphic MIR optimizations could // transmute checking and polymorphic MIR optimizations could
// get a result which isn't correct for all monomorphizations. // get a result which isn't correct for all monomorphizations.
if obligation.param_env.reveal() == Reveal::All { match selcx.infcx.typing_mode(obligation.param_env) {
// NOTE(eddyb) inference variables can resolve to parameters, so TypingMode::Coherence | TypingMode::Analysis { .. } => {
// assume `poly_trait_ref` isn't monomorphic, if it contains any. debug!(
let poly_trait_ref = selcx.infcx.resolve_vars_if_possible(trait_ref); assoc_ty = ?selcx.tcx().def_path_str(node_item.item.def_id),
!poly_trait_ref.still_further_specializable() ?obligation.predicate,
} else { "assemble_candidates_from_impls: not eligible due to default",
debug!( );
assoc_ty = ?selcx.tcx().def_path_str(node_item.item.def_id), false
?obligation.predicate, }
"assemble_candidates_from_impls: not eligible due to default", TypingMode::PostAnalysis => {
); // NOTE(eddyb) inference variables can resolve to parameters, so
false // assume `poly_trait_ref` isn't monomorphic, if it contains any.
let poly_trait_ref = selcx.infcx.resolve_vars_if_possible(trait_ref);
!poly_trait_ref.still_further_specializable()
}
} }
} }
} }