Skip to content

Commit 84295b9

Browse files
committed
traits::project: yeet ParamEnv::reveal
1 parent 4d296ea commit 84295b9

File tree

1 file changed

+16
-13
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+16
-13
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedD
1616
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
1717
use rustc_middle::ty::fold::TypeFoldable;
1818
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
19-
use rustc_middle::ty::{self, Term, Ty, TyCtxt, Upcast};
19+
use rustc_middle::ty::{self, Term, Ty, TyCtxt, TypingMode, Upcast};
2020
use rustc_middle::{bug, span_bug};
2121
use rustc_span::symbol::sym;
2222
use tracing::{debug, instrument};
@@ -975,18 +975,21 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
975975
// and the obligation is monomorphic, otherwise passes such as
976976
// transmute checking and polymorphic MIR optimizations could
977977
// get a result which isn't correct for all monomorphizations.
978-
if obligation.param_env.reveal() == Reveal::All {
979-
// NOTE(eddyb) inference variables can resolve to parameters, so
980-
// assume `poly_trait_ref` isn't monomorphic, if it contains any.
981-
let poly_trait_ref = selcx.infcx.resolve_vars_if_possible(trait_ref);
982-
!poly_trait_ref.still_further_specializable()
983-
} else {
984-
debug!(
985-
assoc_ty = ?selcx.tcx().def_path_str(node_item.item.def_id),
986-
?obligation.predicate,
987-
"assemble_candidates_from_impls: not eligible due to default",
988-
);
989-
false
978+
match selcx.infcx.typing_mode(obligation.param_env) {
979+
TypingMode::Coherence | TypingMode::Analysis { .. } => {
980+
debug!(
981+
assoc_ty = ?selcx.tcx().def_path_str(node_item.item.def_id),
982+
?obligation.predicate,
983+
"assemble_candidates_from_impls: not eligible due to default",
984+
);
985+
false
986+
}
987+
TypingMode::PostAnalysis => {
988+
// NOTE(eddyb) inference variables can resolve to parameters, so
989+
// assume `poly_trait_ref` isn't monomorphic, if it contains any.
990+
let poly_trait_ref = selcx.infcx.resolve_vars_if_possible(trait_ref);
991+
!poly_trait_ref.still_further_specializable()
992+
}
990993
}
991994
}
992995
}

0 commit comments

Comments
 (0)