Skip to content

Conversation

@adwinwhite
Copy link
Contributor

@adwinwhite adwinwhite commented Nov 14, 2025

First step for param_env normalization future compat warning. zulip thread

I didn't put the check directly in param_env query because normalize_param_env_or_error has some adjustments on the predicates: elaboration and outlive predicates manipulation. I'd have to replicate these in param_env to compare normalized predicates properly.
The downside of putting the check inside normalize_param_env_or_error is that it's used in more than param_env query. It's also used in compare_impl_item and several other places. I'm not sure if this is desired.

I didn't bless tests since the hard error will be changed to lint later.
Blessed tests to demonstrate the changes.

And there's one test about const generics I don't know how to fix.
Canonicalizer for the next solver will replace ParamConst with PlaceholderConst, but it still uses the same try_evaluate_const internally and process_obligation doesn't like PlaceholderConst.

r? @lcnr

@rustbot
Copy link
Collaborator

rustbot commented Nov 14, 2025

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Nov 14, 2025
@rust-log-analyzer

This comment has been minimized.

@adwinwhite adwinwhite force-pushed the env_normalization_fcw branch from 5cd4303 to 4408f14 Compare November 14, 2025 12:30
@rustbot
Copy link
Collaborator

rustbot commented Nov 14, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

orig_pred,
) {
Ok(pred_by_next) => {
if pred_by_next == *pred_by_old {
Copy link
Contributor

@lcnr lcnr Nov 16, 2025

Choose a reason for hiding this comment

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

need to fully resolve the predicates before comparing them. This is causing the error in std. Also just generally move this further to the end of this function?

I think doing it here isn't ideally, but should be good enough for a crater run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

std compiles fine after resolving predicates normalized by the old solver.
It turns out that stderr changes of some tests are noise. They're restored to the original state.

@rust-log-analyzer

This comment has been minimized.

@adwinwhite
Copy link
Contributor Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

impl<'a, T> Check for T
//~^ ERROR: overflow evaluating the requirement `T: Check`
where
T: Iterate<'a>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should projection alias in param env imply that the trait predicate holds for the next solver?
I add manual trait clause for these three specialization tests to avoid unnecessary lint triggering.

@adwinwhite
Copy link
Contributor Author

If we resolve regions for the next solver, these two tests will trigger ICEs. They're the same tests mentioned in 166.

  • tests/ui/higher-ranked/trait-bounds/issue-102899.rs
  • tests/ui/higher-ranked/trait-bounds/issue-100689.rs

The cause is that we add constraints that contains placeholders to infcx's constraints collector and resolve_regions can't handle that.
We replace bounds with placeholders and restore them after trait solving in deeply_normalize, but the restoration doesn't apply to region constraints added to infcx.

Now the only ui test broken should be the one in PR description. Sorry for not running all tests faithfully before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next solver normalizes free alias to opaque while the old solver doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not a diverging between the trait solvers, but instead deeply normalizing with the new solver not checking whether predicates may get normalized.

see

fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
if p.allow_normalization() && needs_normalization(self.selcx.infcx, &p) {
p.super_fold_with(self)
} else {
p
}
}
which does not exist in the new solver deeply normalize as we've never deeply normalized predicates before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we add a try_fold_predicate with this check to the next solver version as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next solver normalizes projection alias to opaque while the old solver doesn't.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Nov 17, 2025

If we resolve regions for the next solver, these two tests will trigger ICEs. They're the same tests mentioned in 166.

* tests/ui/higher-ranked/trait-bounds/issue-102899.rs

* tests/ui/higher-ranked/trait-bounds/issue-100689.rs

The cause is that we add constraints that contains placeholders to infcx's constraints collector and resolve_regions can't handle that. We replace bounds with placeholders and restore them after trait solving in deeply_normalize, but the restoration doesn't apply to region constraints added to infcx.

Now the only ui test broken should be the one in PR description. Sorry for not running all tests faithfully before.

this should similarly affect the old solver except that it does not register outlives constraints if considering_regions is set to false :<

I feel like we can probably just disable that ICE/assert for now, idk where exactly that happens and didn't look into it before writing this comment

@adwinwhite
Copy link
Contributor Author

adwinwhite commented Nov 18, 2025

this should similarly affect the old solver except that it does not register outlives constraints if considering_regions is set to false :<

yeah, the next solver doesn't seem to check infcx.considering_regions as I ripgrepped.
Should we check it in some region constraint registering function of infcx or the next solver?

I feel like we can probably just disable that ICE/assert for now, idk where exactly that happens and didn't look into it before writing this comment

Got it. I'll ignore the errors of resolve_regions for now.

@adwinwhite
Copy link
Contributor Author

adwinwhite commented Nov 18, 2025

About ICE in this test.

I understand that the generic_const_exprs is not supported by the next solver for now.
The problem is that this test uses generic_const_exprs features in dependency crate so we can't skip our lint before hand.
If we can know whether dependencies use generic_const_exprs and disable out lint, the lint's usefulness is damaged?

Now that we accept we will run into generic const in normalization with the next solver, there're two choices:

  • detect generic param and return the unevaluated const back. (The old normalization does this)
  • return error as the normalization does fail. (My impression is that normalization with the next solver is less forgiving)

@adwinwhite adwinwhite force-pushed the env_normalization_fcw branch from 571ea88 to 578bcc8 Compare November 18, 2025 06:46
@adwinwhite
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 18, 2025
@lcnr
Copy link
Contributor

lcnr commented Nov 18, 2025

@bors try

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 18, 2025
Show env normalization differences under two solvers
@rust-bors
Copy link

rust-bors bot commented Nov 18, 2025

☀️ Try build successful (CI)
Build commit: c8085cf (c8085cfed34c45021fc8f66d073f6394b3e35431, parent: 217cb73577ed6f30a2005dd75bab01d23ec4cd60)

@lcnr
Copy link
Contributor

lcnr commented Nov 18, 2025

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-148939 created and queued.
🤖 Automatically detected try build c8085cf
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-crater Status: Waiting on a crater run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants