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

Ignore own item bounds in parent alias types in for_each_item_bound #120942

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Feb 11, 2024

Fixes #120912

I want to get a vibe check on this approach, which is very obviously a hack, but I believe something that is forwards-compatible with a more thorough solution and "good enough for now".

The problem here is that for a really deep rigid associated type, we are now repeatedly considering unrelated item bounds from the parent alias types, meaning we're doing a lot of extra work in the MIR inliner for deeply substituted rigid projections.

This feels intimately related to #107614. In that PR, we split supertrait bounds (bound which share the same Self type as the predicate which is being elaborated) and implied bounds (anything that is implied by elaborating the predicate).

The problem here is related to the fact that we don't maintain the split between these two for item_bounds. If we did, then when recursing into a parent alias type, we'd want to consider only the bounds that are given by PredicateFilter::All except those given by PredicateFilter::SelfOnly.

@rustbot
Copy link
Collaborator

rustbot commented Feb 11, 2024

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Feb 11, 2024
@compiler-errors
Copy link
Member Author

whoops

r? lcnr

@rustbot rustbot assigned lcnr and unassigned jackh726 Feb 11, 2024
@compiler-errors
Copy link
Member Author

For the record, I understand that this approach also doesn't fix the new trait solver, which still suffers this problem. Didn't want to make a change there until we decide what the best approach for this problem actually is.

@lcnr
Copy link
Contributor

lcnr commented Feb 12, 2024

I think we can go with the same approach in the new solver. Given that when assembling item bounds for Alias1<Alias2>, we know that ALias1 and Alias2 are rigid at this point, so any alias bound which applies to Alias2 does not apply to Alias1.

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Feb 12, 2024

📌 Commit 38df5bd has been approved by lcnr

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 Feb 12, 2024
@lcnr
Copy link
Contributor

lcnr commented Feb 12, 2024

(this should partially revert the perf regression in #120862)

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 13, 2024
Ignore own item bounds in parent alias types in `for_each_item_bound`

Fixes rust-lang#120912

I want to get a vibe check on this approach, which is very obviously a hack, but I believe something that is forwards-compatible with a more thorough solution and "good enough for now".

The problem here is that for a really deep rigid associated type, we are now repeatedly considering unrelated item bounds from the parent alias types, meaning we're doing a *lot* of extra work in the MIR inliner for deeply substituted rigid projections.

This feels intimately related to rust-lang#107614. In that PR, we split *supertrait* bounds (bound which share the same `Self` type as the predicate which is being elaborated) and *implied* bounds (anything that is implied by elaborating the predicate).

The problem here is related to the fact that we don't maintain the split between these two for `item_bounds`. If we did, then when recursing into a parent alias type, we'd want to consider only the bounds that are given by [`PredicateFilter::All`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/astconv/enum.PredicateFilter.html#variant.SelfOnly) **except** those given by [`PredicateFilter::SelfOnly`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/astconv/enum.PredicateFilter.html#variant.SelfOnly).
@bors
Copy link
Contributor

bors commented Feb 13, 2024

⌛ Testing commit 38df5bd with merge c1b1174...

@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)

@lcnr
Copy link
Contributor

lcnr commented Feb 13, 2024

@bors retry

@bors
Copy link
Contributor

bors commented Feb 14, 2024

⌛ Testing commit 38df5bd with merge 37b6533...

@bors
Copy link
Contributor

bors commented Feb 14, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 37b6533 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 14, 2024
@bors bors merged commit 37b6533 into rust-lang:master Feb 14, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 14, 2024
@compiler-errors compiler-errors deleted the deep-assoc-hang branch February 14, 2024 03:25
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (37b6533): 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)

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

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)
- - 0
Improvements ✅
(primary)
-3.5% [-3.5%, -3.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.5% [-3.5%, -3.5%] 1

Binary size

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

Bootstrap: 628.588s -> 631.732s (0.50%)
Artifact size: 305.10 MiB -> 305.05 MiB (-0.02%)

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.

polymorphic_recursion.rs takes longer to compile
7 participants