Skip to content

Commit c58ec93

Browse files
committed
normalization folders, yeet ParamEnv::reveal
1 parent c5dab55 commit c58ec93

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

compiler/rustc_trait_selection/src/traits/normalize.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_macros::extension;
1010
use rustc_middle::traits::{ObligationCause, ObligationCauseCode, Reveal};
1111
use rustc_middle::ty::{
1212
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt,
13+
TypingMode,
1314
};
1415
use tracing::{debug, instrument};
1516

@@ -212,11 +213,12 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
212213

213214
match kind {
214215
ty::Opaque => {
215-
// Only normalize `impl Trait` outside of type inference, usually in codegen.
216-
match self.param_env.reveal() {
217-
Reveal::UserFacing => ty.super_fold_with(self),
218-
219-
Reveal::All => {
216+
match self.selcx.infcx.typing_mode(self.param_env) {
217+
TypingMode::Coherence | TypingMode::Analysis { defining_opaque_types: _ } => {
218+
ty.super_fold_with(self)
219+
}
220+
// Only normalize `impl Trait` outside of type inference, usually in codegen.
221+
TypingMode::PostAnalysis => {
220222
let recursion_limit = self.cx().recursion_limit();
221223
if !recursion_limit.value_within_limit(self.depth) {
222224
self.selcx.infcx.err_ctxt().report_overflow_error(

compiler/rustc_trait_selection/src/traits/query/normalize.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_macros::extension;
99
pub use rustc_middle::traits::query::NormalizationResult;
1010
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
1111
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
12-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
12+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor, TypingMode};
1313
use rustc_span::DUMMY_SP;
1414
use tracing::{debug, info, instrument};
1515

@@ -21,7 +21,7 @@ use crate::infer::canonical::OriginalQueryValues;
2121
use crate::infer::{InferCtxt, InferOk};
2222
use crate::traits::normalize::needs_normalization;
2323
use crate::traits::{
24-
BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer, Reveal, ScrubbedTraitError,
24+
BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer, ScrubbedTraitError,
2525
};
2626

2727
#[extension(pub trait QueryNormalizeExt<'tcx>)]
@@ -215,10 +215,12 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
215215
let res = match kind {
216216
ty::Opaque => {
217217
// Only normalize `impl Trait` outside of type inference, usually in codegen.
218-
match self.param_env.reveal() {
219-
Reveal::UserFacing => ty.try_super_fold_with(self)?,
218+
match self.infcx.typing_mode(self.param_env) {
219+
TypingMode::Coherence | TypingMode::Analysis { defining_opaque_types: _ } => {
220+
ty.try_super_fold_with(self)?
221+
}
220222

221-
Reveal::All => {
223+
TypingMode::PostAnalysis => {
222224
let args = data.args.try_fold_with(self)?;
223225
let recursion_limit = self.cx().recursion_limit();
224226

0 commit comments

Comments
 (0)