Skip to content

Skip walking into param-env component if it has no placeholder/re-var #143500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 9 additions & 4 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use rustc_type_ir::inherent::*;
use rustc_type_ir::lang_items::TraitSolverLangItem;
use rustc_type_ir::solve::SizedTraitKind;
use rustc_type_ir::{
self as ty, Interner, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt as _,
TypeVisitor, TypingMode, Upcast as _, elaborate,
self as ty, Interner, TypeFlags, TypeFoldable, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt as _, TypeVisitor, TypingMode, Upcast as _, elaborate,
};
use tracing::{debug, instrument};

Expand Down Expand Up @@ -132,6 +132,7 @@ where
})
.enter(|ecx| {
Self::match_assumption(ecx, goal, assumption, |ecx| {
ecx.try_evaluate_added_goals()?;
source.set(ecx.characterize_param_env_assumption(goal.param_env, assumption)?);
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
Expand Down Expand Up @@ -1069,8 +1070,10 @@ where
} else {
ControlFlow::Continue(())
}
} else {
} else if ty.has_type_flags(TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_RE_INFER) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only RE_INFER instead of full infer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc we only care about infer regions in this folder's logic -- it would not even be necessary if we didn't replace free regions with infer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we care about ty/ct infer for this folder anyways? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only care as in: there should never be infer types/consts in the param_env 😁 if we end up with a ty var for whatever reason, then this folder would start incorrectly treating (): Trait<?x> as global evne though it shouldn't be. It currently detects ambiguous aliases in the env as global

Copy link
Member Author

@compiler-errors compiler-errors Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that is the case and how this behavior would change with this fast path, given that visit_ty does not care about infer types at all and because structurally_normalize_ty just returns Ok(_) for infer types.

Can you explain in more detail, because I am obviously missing something here?

ty.super_visit_with(self)
} else {
ControlFlow::Continue(())
}
}

Expand All @@ -1086,8 +1089,10 @@ where
} else {
ControlFlow::Continue(())
}
} else {
} else if ct.has_type_flags(TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_RE_INFER) {
ct.super_visit_with(self)
} else {
ControlFlow::Continue(())
}
}

Expand Down
Loading