-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Permit recursive weak type aliases #113201
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
@bors r+ |
📌 Commit 01fcce9e0e60c73311b0d94c17f950ac7fded7fa has been approved by It is now in the queue for this repository. |
// Lazily compute this to avoid cycles under `lazy_type_alias` | ||
let mut ty = None; | ||
let mut ty = || *ty.get_or_insert_with(|| self.tcx().at(span).type_of(did)); | ||
|
||
if matches!(self.tcx().def_kind(did), DefKind::TyAlias) | ||
&& (ty.skip_binder().has_opaque_types() || self.tcx().features().lazy_type_alias) | ||
&& (self.tcx().features().lazy_type_alias || ty().skip_binder().has_opaque_types()) |
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 lazy caching of the ty
variable seems a bit convoluted imo. I think the control flow is clearer if we just duplicate the weak alias branch by first doing:
if tcx.features.lazy_type_alias {
make the projection
} else {
// comment going here explaining the query cycle avoidance in the above branch
let ty = tcx.type_of(...);
if ty.has_opaques() {
// old comment mentioning opaques goes here
make projection
} else {
ty.subst(..)
}
}
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 guess I'll do that as a follow-up since this PR is already approved, though.
error[E0275]: overflow evaluating the requirement `X` | ||
--> $DIR/infinite-vec-type-recursion.rs:9:20 | ||
| | ||
LL | fn main() { let b: X = Vec::new(); } | ||
| ^ |
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.
Hm, I consider this to be a worse error message than the query cycle, since at least that one's got spans pointing to all the aliases participating in the cycle. But the fixes to overflow handling in weak aliases seems necessary regardless, though, since you could probably have recreated this condition using TAITs.
@bors r- |
☔ The latest upstream changes (presumably #113591) made this pull request unmergeable. Please resolve the merge conflicts. |
triage: @oli-obk can you please address the merge conflicts and assign to reviewer? |
01fcce9
to
09c793e
Compare
@bors r=estebank,compiler-errors |
📌 Commit 09c793e80c18025b2cbe965071b7627ac4a538de has been approved by It is now in the queue for this repository. |
⌛ Testing commit 09c793e80c18025b2cbe965071b7627ac4a538de with merge 1e65ca4280c4e894138b84b4245286efc9199059... |
09c793e
to
5d850e0
Compare
@bors r=estebank,compiler-errors |
⌛ Testing commit 5d850e0 with merge cec1940b1cfc92a766635a2117bd856d98be10a8... |
@bors ping |
Finished benchmarking commit (cec1940b1cfc92a766635a2117bd856d98be10a8): 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 Warning ⚠: The following benchmark(s) failed to build:
cc @rust-lang/wg-compiler-performance 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: 632.146s -> 631.714s (-0.07%) |
@bors r- |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 5d850e0 with merge 85e17c5d3df8e83bde2f0783dc9600177063c904... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (85e17c5d3df8e83bde2f0783dc9600177063c904): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.413s -> 631.275s (-0.02%) |
@bors r=estebank,compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (96f62fc): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. 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: 632.086s -> 631.878s (-0.03%) |
I saw #63097 and thought "we can do
betterfunnier". So here it is. It's not useful, but it's certainly something. This may actually become feasible with lazy norm (so in 5 years (constant, not reducing over time)).r? @estebank
cc @GuillaumeGomez