-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[WIP] rustdoc: Rewrite auto trait impl synthesis #149019
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
base: main
Are you sure you want to change the base?
[WIP] rustdoc: Rewrite auto trait impl synthesis #149019
Conversation
15d9b7b to
ea10870
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Not finished but let's get an initial reading, I should've done that a while ago. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…sis, r=<try> [WIP] rustdoc: Rewrite auto trait impl synthesis
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (634512a): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary -5.3%, secondary 3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.926s -> 471.456s (-0.10%) |
This comment was marked as outdated.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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! ^^'
ea10870 to
a5fdf11
Compare
a5fdf11 to
107f5fe
Compare
|
@bors try parent=last @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
| if nested_goals.is_empty() { | ||
| return ControlFlow::Break(()); | ||
| } |
There was a problem hiding this comment.
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?
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (94939e6): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary -5.4%, secondary 2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.926s -> 470.104s (-0.39%) |
b292701 to
4b20fe6
Compare
…sis, r=<try> [WIP] rustdoc: Rewrite auto trait impl synthesis
* avoid looking for user-written impls (there can't ever be any) * avoid copying & interning clauses * avoid processing region obligations
4b20fe6 to
574042c
Compare
…sis, r=<try> [WIP] rustdoc: Rewrite auto trait impl synthesis
|
@bors try parent=last |
|
⌛ Trying commit 574042c with merge 978c108… (The previously running try build was automatically cancelled.) To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/19788265666 |
…sis, r=<try> [WIP] rustdoc: Rewrite auto trait impl synthesis
|
@rust-timer build 978c108 profiles=doc |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (978c108): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary -5.6%, secondary 3.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.926s -> 471.234s (-0.15%) |
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).