Skip to content

Conversation

@fmease
Copy link
Member

@fmease fmease commented Nov 17, 2025

Rewrite its core from scratch using the next-gen trait solver and its ProofTreeVisitor.

Fixes #105199.
Fixes #110740.
Fixes #110741.
Fixes #111102 (tiny FIXME: need to wrap ACE RHS in { } if it's a Param).
Fixes #114097.
Fixes #116539.
Fixes #120606.
Fixes #127593.
Fixes #136778.
Fixes #139964 (no longer hangs, FIXME: now fails under VERIFY).
Fixes #144918.
Fixes #149281 (no longer ICEs, FIXME: we still don't propagate const Bounds).

FIXME: #123298 (still fails under VERIFY).
FIXME: #91380 (Jyn's code: fully fixed; original code: still fails under VERIFY).

Also aims to address rust-lang/trait-system-refactor-initiative#157 & rust-lang/trait-system-refactor-initiative#208 (yet to be tested). NB: Upper bound is #141564 (comment).

@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Nov 17, 2025
@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 17, 2025
@fmease fmease force-pushed the rustdoc-rewrite-auto-trait-impl-synthesis branch 2 times, most recently from 15d9b7b to ea10870 Compare November 17, 2025 11:43
@Kobzol

This comment has been minimized.

@rust-timer

This comment has been minimized.

@fmease
Copy link
Member Author

fmease commented Nov 24, 2025

Not finished but let's get an initial reading, I should've done that a while ago.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 24, 2025
…sis, r=<try>

[WIP] rustdoc: Rewrite auto trait impl synthesis
@rust-bors
Copy link

rust-bors bot commented Nov 24, 2025

☀️ Try build successful (CI)
Build commit: 634512a (634512ace28481d8e463b64400a5788b037103de, parent: c23ed3ef28b3cc30658310f771ddc66e5b687cf4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (634512a): 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.2%] 1
Regressions ❌
(secondary)
20.2% [0.2%, 40.2%] 2
Improvements ✅
(primary)
-3.6% [-14.8%, -0.2%] 16
Improvements ✅
(secondary)
-2.3% [-12.3%, -0.1%] 7
All ❌✅ (primary) -3.4% [-14.8%, 0.2%] 17

Max RSS (memory usage)

Results (primary 2.3%, secondary -3.8%)

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

mean range count
Regressions ❌
(primary)
2.3% [1.0%, 5.9%] 10
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.5% [-6.5%, -2.2%] 8
All ❌✅ (primary) 2.3% [1.0%, 5.9%] 10

Cycles

Results (primary -5.3%, secondary 3.9%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.6% [1.8%, 26.4%] 9
Improvements ✅
(primary)
-5.3% [-10.3%, -3.1%] 7
Improvements ✅
(secondary)
-8.2% [-10.0%, -6.3%] 2
All ❌✅ (primary) -5.3% [-10.3%, -3.1%] 7

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.926s -> 471.456s (-0.10%)
Artifact size: 388.27 MiB -> 386.31 MiB (-0.50%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 24, 2025
@fmease

This comment was marked as outdated.


if let Some(clause) = predicate.as_clause()
&& let ty::ClauseKind::Projection(pred) = clause.kind().skip_binder()
&& let ty::Param(_) = pred.self_ty().kind()
Copy link
Contributor

Choose a reason for hiding this comment

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

think this doesn't handle <T::Assoc as Trait>::Assoc

Copy link
Member Author

@fmease fmease Nov 26, 2025

Choose a reason for hiding this comment

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

Yes, indeed. I did already implement that a while ago locally but didn't push any of it because it led me into a deep rabbit hole, I'll elaborate later.

Copy link
Member Author

@fmease fmease Nov 28, 2025

Choose a reason for hiding this comment

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

I'll elaborate later.

Ok, so while I obviously need to recurse into the self type while it's a projection until it's a type param (and bail if it isn't) [A], presently I believe I also have to push any(?) AliasRelate(Equate) [B] as well as any trait & projection predicates that has_infer() assuming the goal result is ambiguous [C].

I'm still a bit lost in the weeds there though. Why do I need to do that? Well it's to account for a whole class of scenarios that feature projection predicates. See below:

Copy link
Member Author

@fmease fmease Nov 28, 2025

Choose a reason for hiding this comment

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

I'm subsequently assuming the following "preamble":

#![feature(auto_traits)]

pub auto trait Marker {}

pub struct Outer<T>(Inner<T>);
struct Inner<T>(T);

I'm also assuming we're "analyzing" <T> <Outer<T> as Marker>.


Here, we want to collect <T as Iterator>, Proj(Iterator::Item, [T]) == ?0 and <?0 as Copy> (omitting sized preds obv):

impl<T, U> Marker for Inner<T>
where
    T: Iterator<Item = U>,
    U: Copy, // or `(U,): Copy` etc.
{}

That I can easily manage. But now consider this:

impl<T> Marker for Inner<T>
where
    T: Iterator<Item: Iterator<Item = ()>>
{}

Here the proof tree contains AliasRelate(Proj(…), …)s and it gets rather hairy (all those intermediary type variables obviously, etc.). I was able to hack something together locally but it isn't beautiful. I don't have a concrete question and I'm not sure if I'm seeking guidance, I just got a bit overwhelmed ^^'

In any case, that made me realize that it's probably more than okay if the algorithm remains rather incomplete in this PR, an MVP if you will, as it's more important to migrate to the next solver than to perfect SATI (thereby conservatively reporting unimplemented in more complicated cases for now).

After all, the SATI@main is even more incomplete: It filters out projection predicates that contain infer vars (even though those can be turned into extra synthetic parameters like I do in this PR (in the old SATI the synthetic impl has to have the same params as the ADT which is ofc super restrictive))! What's worse, it unconditionally validates the resulting set of predicates which of course leads to all of these ICEs due to its incompleteness! ^^'

@fmease fmease force-pushed the rustdoc-rewrite-auto-trait-impl-synthesis branch from ea10870 to a5fdf11 Compare November 28, 2025 21:44
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Nov 28, 2025
@fmease fmease force-pushed the rustdoc-rewrite-auto-trait-impl-synthesis branch from a5fdf11 to 107f5fe Compare November 28, 2025 22:34
@fmease
Copy link
Member Author

fmease commented Nov 28, 2025

@bors try parent=last @rust-timer queue

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 28, 2025
Comment on lines +608 to +582
if nested_goals.is_empty() {
return ControlFlow::Break(());
}
Copy link
Member Author

@fmease fmease Nov 28, 2025

Choose a reason for hiding this comment

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

This feels like a hack to me. Namely, breaking & considering the auto trait unimplemented if (the goal failed and) there is a candidate, a single one, but it doesn't have any goals (so it's kind of "unproductive" or "fake"). Otherwise I only ever break if there's no candidate at all which makes total sense.

Why did I add this check? Well, to correctly determine that <'a> <Outer<'a> as Marker> is unimplemented here (due to a universe mismatch):

#![feature(auto_traits)]

pub auto trait Marker {}

pub struct Outer<'a>(fn(&'a ()));
impl Marker for for<'a> fn(&'a ()) {}
DEBUG PROOF TREE
(G) Err(NoSolution)  Misc  #C=1  for[] TraitPredicate(<Outer<'a> as Marker>, polarity:Positive)
 (C#0) Err(NoSolution)  TraitCandidate/BuiltinImpl(Misc)
  (G) Err(NoSolution)  ImplWhereBound  #C=1  for[] TraitPredicate(<fn(&'a ()) as Marker>, polarity:Positive)
   (C#0) Err(NoSolution)  TraitCandidate/Impl(DefId(0:8 ~ rm[1917]::{impl#0}))

Is that how you're "supposed" to detect this?

@rust-bors
Copy link

rust-bors bot commented Nov 29, 2025

☀️ Try build successful (CI)
Build commit: 94939e6 (94939e6e3ab893597fa00b53eef0f474a0bb2ea7, parent: c23ed3ef28b3cc30658310f771ddc66e5b687cf4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (94939e6): 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
Regressions ❌
(secondary)
40.0% [40.0%, 40.0%] 1
Improvements ✅
(primary)
-3.9% [-15.3%, -0.2%] 16
Improvements ✅
(secondary)
-2.3% [-12.7%, -0.1%] 8
All ❌✅ (primary) -3.9% [-15.3%, -0.2%] 16

Max RSS (memory usage)

Results (primary 1.6%, secondary -4.4%)

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

mean range count
Regressions ❌
(primary)
2.0% [1.2%, 5.1%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-4.4% [-6.6%, -2.2%] 8
All ❌✅ (primary) 1.6% [-1.1%, 5.1%] 8

Cycles

Results (primary -5.4%, secondary 2.9%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
7.1% [2.2%, 25.9%] 8
Improvements ✅
(primary)
-5.4% [-11.2%, -2.4%] 8
Improvements ✅
(secondary)
-5.5% [-11.0%, -1.7%] 4
All ❌✅ (primary) -5.4% [-11.2%, -2.4%] 8

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.926s -> 470.104s (-0.39%)
Artifact size: 388.27 MiB -> 386.27 MiB (-0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 29, 2025
@fmease fmease force-pushed the rustdoc-rewrite-auto-trait-impl-synthesis branch 2 times, most recently from b292701 to 4b20fe6 Compare November 29, 2025 19:07
rust-bors bot added a commit that referenced this pull request Nov 29, 2025
…sis, r=<try>

[WIP] rustdoc: Rewrite auto trait impl synthesis
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 29, 2025
* avoid looking for user-written impls (there can't ever be any)
* avoid copying & interning clauses
* avoid processing region obligations
@fmease fmease force-pushed the rustdoc-rewrite-auto-trait-impl-synthesis branch from 4b20fe6 to 574042c Compare November 29, 2025 19:21
@rust-lang rust-lang deleted a comment from rust-timer Nov 29, 2025
@rust-lang rust-lang deleted a comment from rust-bors bot Nov 29, 2025
@rust-lang rust-lang deleted a comment from rust-bors bot Nov 29, 2025
rust-bors bot added a commit that referenced this pull request Nov 29, 2025
…sis, r=<try>

[WIP] rustdoc: Rewrite auto trait impl synthesis
@rust-lang rust-lang deleted a comment from rust-timer Nov 29, 2025
@fmease
Copy link
Member Author

fmease commented Nov 29, 2025

@bors try parent=last

@rust-lang rust-lang deleted a comment from rust-timer Nov 29, 2025
@rust-bors
Copy link

rust-bors bot commented Nov 29, 2025

⌛ Trying commit 574042c with merge 978c108

(The previously running try build was automatically cancelled.)

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/19788265666

rust-bors bot added a commit that referenced this pull request Nov 29, 2025
…sis, r=<try>

[WIP] rustdoc: Rewrite auto trait impl synthesis
@fmease fmease removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 29, 2025
@fmease
Copy link
Member Author

fmease commented Nov 29, 2025

@rust-timer build 978c108 profiles=doc

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (978c108): 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
Regressions ❌
(secondary)
40.0% [40.0%, 40.0%] 1
Improvements ✅
(primary)
-3.9% [-15.3%, -0.2%] 16
Improvements ✅
(secondary)
-3.7% [-12.7%, -0.4%] 5
All ❌✅ (primary) -3.9% [-15.3%, -0.2%] 16

Max RSS (memory usage)

Results (primary 1.7%, secondary -2.1%)

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

mean range count
Regressions ❌
(primary)
2.4% [1.4%, 5.2%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) 1.7% [-1.1%, 5.2%] 5

Cycles

Results (primary -5.6%, secondary 3.8%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
25.4% [25.4%, 25.4%] 1
Improvements ✅
(primary)
-5.6% [-11.4%, -2.4%] 8
Improvements ✅
(secondary)
-7.0% [-10.8%, -3.1%] 2
All ❌✅ (primary) -5.6% [-11.4%, -2.4%] 8

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 471.926s -> 471.234s (-0.15%)
Artifact size: 388.27 MiB -> 386.24 MiB (-0.52%)

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

Labels

perf-regression Performance regression. rla-silenced Silences rust-log-analyzer postings to the PR it's added on. 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. T-rustdoc Relevant to the rustdoc 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

5 participants