Skip to content

Eagerly normalize in generalize#151746

Open
jdonszelmann wants to merge 12 commits intorust-lang:mainfrom
jdonszelmann:eagerly-normalize-in-generalize
Open

Eagerly normalize in generalize#151746
jdonszelmann wants to merge 12 commits intorust-lang:mainfrom
jdonszelmann:eagerly-normalize-in-generalize

Conversation

@jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Jan 27, 2026

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Jan 27, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Jan 29, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Jan 29, 2026
… r=<try>

Eagerly normalize in generalize
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 29, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 29, 2026

💔 Test for 92bb985 failed: CI. Failed job:

@lcnr
Copy link
Contributor

lcnr commented Jan 30, 2026

collector error: Failed to profile 'serde-1.0.219-new-solver' with Eprintln, recorded: expected success, got exit status: 101

fun, we've got some jank in serde which we don't have in our ui test suite

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from 5bd20bb to d0cdaae Compare February 2, 2026 18:38
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from d0cdaae to fb5d5cf Compare February 3, 2026 15:04
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from fb5d5cf to d96cab0 Compare February 3, 2026 15:51
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from d96cab0 to 5611a89 Compare February 5, 2026 10:47
@jdonszelmann jdonszelmann marked this pull request as ready for review February 5, 2026 10:47
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2026

changes to the core type system

cc @lcnr

@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 Feb 5, 2026
@jdonszelmann
Copy link
Contributor Author

@lcnr I think this fixes all issues we had. Only one test really regressed, some got a bunch better. Fixed the span on the one test we discussed.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from 5611a89 to 3f90d08 Compare February 5, 2026 10:50
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor Author

@GuillaumeGomez is this another flaky test?

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d3da459): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.3%] 5
Regressions ❌
(secondary)
0.3% [0.1%, 0.4%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 5

Max RSS (memory usage)

Results (primary 2.6%, secondary 0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.6%, 2.6%] 1
Regressions ❌
(secondary)
3.2% [0.8%, 5.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.5% [-4.5%, -4.5%] 1
All ❌✅ (primary) 2.6% [2.6%, 2.6%] 1

Cycles

Results (primary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.6%, 2.7%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.6% [2.6%, 2.7%] 2

Binary size

Results (primary 0.0%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 4
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 4

Bootstrap: 474.937s -> 474.9s (-0.01%)
Artifact size: 397.89 MiB -> 398.08 MiB (0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 6, 2026
@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from 3f90d08 to fd20cab Compare February 9, 2026 11:45
@rustbot

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from fd20cab to 3bcdac1 Compare February 19, 2026 16:12
@rustbot

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from 3bcdac1 to a335a41 Compare February 20, 2026 09:49
@rustbot

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from a335a41 to 29ae136 Compare February 24, 2026 10:40
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@jdonszelmann jdonszelmann force-pushed the eagerly-normalize-in-generalize branch from 29ae136 to 1adea68 Compare February 26, 2026 13:57
@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2026

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.

/// `<T as Bar<<?0 as Foo>::Assoc>::Assoc == ?0`. This equality can
/// hold by either normalizing the outer or the inner associated type.
in_alias: bool,
state: GeneralizerState,
Copy link
Contributor

Choose a reason for hiding this comment

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

outdated comment, refer to the docs of GeneralizerState

Comment on lines +358 to +366
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
enum GeneralizerState {
/// Treat aliases as potentially normalizable.
Default,
IncompletelyRelateHigherRankedAlias,
/// Only one layer
ShallowStructurallyRelateAliases,
StructurallyRelateAliases,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please add more context here

  • when are we in which state
  • how do they impact behavior

or maybe just refer to handle_alias_ty and rely on the actual control-flow in that function


match self.state {
GeneralizerState::IncompletelyRelateHigherRankedAlias => {
if self.infcx.next_trait_solver()
Copy link
Contributor

Choose a reason for hiding this comment

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

i feel like it'd be easier for us to only ever be in IncompletelyRelateHigherRankedAlias if we're in the new solver, so that we don't have to check this. In the old solver Default and IncompletelyRelateHigherRankedAlias are equivalent, are they not?

span: Span,
alias: ty::AliasTy<'tcx>,
) -> Ty<'tcx> {
let infcx = unsafe {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to encapsulate these transmute in inhernet functions on InferCtxt and add a safety comment there?

@@ -12,7 +13,6 @@ impl Trait for u32 {}
fn hello() -> Box<impl Trait> {
if true {
let x = hello();
//[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time
let y: Box<dyn Trait> = x;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I don't fully get that 🤔

What does "implicitly contains the + Sized bound" mean? For coerce to consider that Sized bound, it has to be in the root fulfillment context I think?

How does that Sized bound get there. I am also surprised that x has to be equal to the return type of hello() instead of a subtype, how does that happen? ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants