Skip to content
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

Merged
merged 1 commit into from
Sep 1, 2023
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 30, 2023

I saw #63097 and thought "we can do better funnier". 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

@rustbot
Copy link
Collaborator

rustbot commented Jun 30, 2023

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added 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. labels Jun 30, 2023
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 30, 2023

📌 Commit 01fcce9e0e60c73311b0d94c17f950ac7fded7fa has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2023
Comment on lines 915 to 920
// 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())
Copy link
Member

@compiler-errors compiler-errors Jun 30, 2023

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(..)
  }
}

Copy link
Member

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.

Comment on lines 1 to 5
error[E0275]: overflow evaluating the requirement `X`
--> $DIR/infinite-vec-type-recursion.rs:9:20
|
LL | fn main() { let b: X = Vec::new(); }
| ^
Copy link
Member

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.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 30, 2023

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 30, 2023
@bors
Copy link
Contributor

bors commented Jul 14, 2023

☔ The latest upstream changes (presumably #113591) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

JohnCSimon commented Aug 27, 2023

triage: @oli-obk can you please address the merge conflicts and assign to reviewer?

@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 30, 2023

@bors r=estebank,compiler-errors

@bors
Copy link
Contributor

bors commented Aug 30, 2023

📌 Commit 09c793e80c18025b2cbe965071b7627ac4a538de has been approved by estebank,compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 30, 2023
@bors
Copy link
Contributor

bors commented Aug 30, 2023

⌛ Testing commit 09c793e80c18025b2cbe965071b7627ac4a538de with merge 1e65ca4280c4e894138b84b4245286efc9199059...

@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 30, 2023

@bors r=estebank,compiler-errors

@bors
Copy link
Contributor

bors commented Aug 30, 2023

📌 Commit 5d850e0 has been approved by estebank,compiler-errors

It is now in the queue for this repository.

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Aug 30, 2023

⌛ Testing commit 5d850e0 with merge cec1940b1cfc92a766635a2117bd856d98be10a8...

@oli-obk oli-obk closed this Aug 30, 2023
@oli-obk oli-obk reopened this Aug 30, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 30, 2023

@bors ping

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cec1940b1cfc92a766635a2117bd856d98be10a8): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Warning ⚠: The following benchmark(s) failed to build:

  • image-0.24.1

cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.9% [0.9%, 0.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-2.2%, 0.9%] 2

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.1% [1.8%, 2.4%] 2
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
-2.6% [-3.7%, -2.0%] 4
All ❌✅ (primary) -0.9% [-0.9%, -0.9%] 1

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
0.9% [0.9%, 0.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-2.1%, 0.9%] 2

Binary size

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

Bootstrap: 632.146s -> 631.714s (-0.07%)
Artifact size: 316.62 MiB -> 316.59 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Aug 31, 2023
@oli-obk oli-obk removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. labels Aug 31, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 31, 2023

@bors r-

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 31, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 31, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 31, 2023
@bors
Copy link
Contributor

bors commented Aug 31, 2023

⌛ Trying commit 5d850e0 with merge 85e17c5d3df8e83bde2f0783dc9600177063c904...

@bors
Copy link
Contributor

bors commented Aug 31, 2023

☀️ Try build successful - checks-actions
Build commit: 85e17c5d3df8e83bde2f0783dc9600177063c904 (85e17c5d3df8e83bde2f0783dc9600177063c904)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (85e17c5d3df8e83bde2f0783dc9600177063c904): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
1.4% [1.1%, 1.7%] 3
Regressions ❌
(secondary)
2.8% [1.7%, 4.4%] 3
Improvements ✅
(primary)
-1.0% [-1.0%, -1.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [-1.0%, 1.7%] 4

Cycles

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

Binary size

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

Bootstrap: 631.413s -> 631.275s (-0.02%)
Artifact size: 316.57 MiB -> 316.51 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 31, 2023
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 1, 2023

@bors r=estebank,compiler-errors

@bors
Copy link
Contributor

bors commented Sep 1, 2023

📌 Commit 5d850e0 has been approved by estebank,compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 1, 2023
@bors
Copy link
Contributor

bors commented Sep 1, 2023

⌛ Testing commit 5d850e0 with merge 96f62fc...

@bors
Copy link
Contributor

bors commented Sep 1, 2023

☀️ Test successful - checks-actions
Approved by: estebank,compiler-errors
Pushing 96f62fc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 1, 2023
@bors bors merged commit 96f62fc into rust-lang:master Sep 1, 2023
23 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 1, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (96f62fc): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
1.4% [0.6%, 1.8%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [0.6%, 1.8%] 3

Cycles

Results

This 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.

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

Binary size

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

Bootstrap: 632.086s -> 631.878s (-0.03%)
Artifact size: 316.25 MiB -> 316.40 MiB (0.05%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants