-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Combine Sub
and Equate
#121462
Combine Sub
and Equate
#121462
Conversation
Type relation code was changed Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
This comment has been minimized.
This comment has been minimized.
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 am not too happy with RelateDirection
. Because it doesn't really feel appropriate given that it is used in relate only together with a_is_expected
.
I would personally prefer tracking the variance in TypeRelating
- supporting Contravariance
- and changing relate_with_variance
to simply be self.variance = self.variance.xform(variance);
. This means we then don't need a_is_expected
at all and (after removing (it from) Lub
) can change the Generalizer
to not compare a_is_expected
with target_is_expected
.
Apart from that 👍
9c4a009
to
f7b841a
Compare
This comment has been minimized.
This comment has been minimized.
27da982
to
8ba73e7
Compare
This comment has been minimized.
This comment has been minimized.
5508ab5
to
4d1c58b
Compare
…rors fix generalizer unsoundness I ended up getting confused while trying to flip the variances when flipping the order. Should be all right now. This is only exploitable when generalizing if the `ambient_variance` of the relation is `Contravariant`. This can currently only be the case in the NLL generalizer which only rarely generalizes, causing us to miss this regression. Very much an issue with rust-lang#121462 however.
Rollup merge of rust-lang#121479 - lcnr:fix-generalize, r=compiler-errors fix generalizer unsoundness I ended up getting confused while trying to flip the variances when flipping the order. Should be all right now. This is only exploitable when generalizing if the `ambient_variance` of the relation is `Contravariant`. This can currently only be the case in the NLL generalizer which only rarely generalizes, causing us to miss this regression. Very much an issue with rust-lang#121462 however.
☔ The latest upstream changes (presumably #121491) made this pull request unmergeable. Please resolve the merge conflicts. |
4d1c58b
to
6ccca8c
Compare
This comment has been minimized.
This comment has been minimized.
6ccca8c
to
3034b2b
Compare
//! There are four type combiners: [TypeRelating], [Lub], and [Glb], | ||
//! (and `NllTypeRelating` in rustc_borrowck, which is only used for NLL). |
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.
//! There are four type combiners: [TypeRelating], [Lub], and [Glb], | |
//! (and `NllTypeRelating` in rustc_borrowck, which is only used for NLL). | |
//! There are four type combiners: [TypeRelating], [Lub], and [Glb], | |
//! and `NllTypeRelating` in rustc_borrowck, which is only used for NLL. |
/// Enforce that `a` is equal to or a subtype of `b`. | ||
pub struct TypeRelating<'combine, 'a, 'tcx> { | ||
fields: &'combine mut CombineFields<'a, 'tcx>, | ||
a_is_expected: bool, |
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.
a_is_expected
should be unnecessary now, as we can instead flip the related types by using xform(ty::Contravariance)
. Where do we modify a_is_expected
right now?
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.
It's not that we modify a_is_expected
from within the relation. It's that we construct the relation (and therefore pass in a_is_expected
) separately from where we use it. I think this is prohibitively invasive to fix right now.
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.
hmm, we could then simpy flip the args if Trace { a_is_expected }
is false. But yeah, am fine with doing that in a separate PR
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Combine `Sub` and `Equate` Combine `Sub` and `Equate` into a new relation called `TypeRelating` (that name sounds familiar...) Tracks the difference between `Sub` and `Equate` via `ambient_variance: ty::Variance` much like the `NllTypeRelating` relation, but implemented slightly jankier because it's a more general purpose relation. r? lcnr
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
968abf3
to
d4356b8
Compare
This comment has been minimized.
This comment has been minimized.
d4356b8
to
8ffec21
Compare
☔ The latest upstream changes (presumably #121770) made this pull request unmergeable. Please resolve the merge conflicts. |
8ffec21
to
1d5eaf8
Compare
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.
r=me after final comment cleanup.
Thanks for your work ❤️
1d5eaf8
to
216e6e2
Compare
☔ The latest upstream changes (presumably #118247) made this pull request unmergeable. Please resolve the merge conflicts. |
216e6e2
to
5072b65
Compare
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b0696a5): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 653.924s -> 651.828s (-0.32%) |
as stated in #121462 (comment):
|
Combine
Sub
andEquate
into a new relation calledTypeRelating
(that name sounds familiar...)Tracks the difference between
Sub
andEquate
viaambient_variance: ty::Variance
much like theNllTypeRelating
relation, but implemented slightly jankier because it's a more general purpose relation.r? lcnr