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

lint incorrect implied bounds in wfcheck #109763

Closed
wants to merge 3 commits into from

Conversation

aliemjay
Copy link
Member

@aliemjay aliemjay commented Mar 30, 2023

Lint version of #109482.

This implements a new implied bounds query that fixes the normalization problems with the previous query, including #106569, #109628 and #109799. While the new implementation allows more code to compile, it also breaks code that relies on #109628 (see the crater run in #109482 for details.) For this reason we keep the legacy implementation and emit a lint when they disagree.

Fixes #109628.

This doesn't implement the lint yet. I want to have a perf baseline first.
r? @ghost

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Mar 30, 2023
@aliemjay aliemjay force-pushed the lint-implied-bounds-fork branch 2 times, most recently from dcdb22e to fb49efa Compare March 30, 2023 12:39
@aliemjay
Copy link
Member Author

aliemjay commented Mar 30, 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 Mar 30, 2023
@bors
Copy link
Contributor

bors commented Mar 30, 2023

⌛ Trying commit fb49efa4c195a669c1d518c33e78b3adf9eea34b with merge 67ce1e9f41cb4c34e12f6d249826cce3f073c6c7...

@bors
Copy link
Contributor

bors commented Mar 30, 2023

💔 Test failed - checks-actions

@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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2023
@rust-timer

This comment has been minimized.

@aliemjay
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Mar 30, 2023

⌛ Trying commit 364683472a016eb083e00c781635025f54044e49 with merge 9df496919a3bfe6478f619535af0fa752b6d84b5...

@bors
Copy link
Contributor

bors commented Mar 30, 2023

☀️ Try build successful - checks-actions
Build commit: 9df496919a3bfe6478f619535af0fa752b6d84b5 (9df496919a3bfe6478f619535af0fa752b6d84b5)

@rust-timer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9df496919a3bfe6478f619535af0fa752b6d84b5): comparison URL.

Overall result: ❌ regressions - 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.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
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)
3.5% [3.2%, 3.8%] 2
Regressions ❌
(secondary)
3.0% [1.7%, 3.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) 3.5% [3.2%, 3.8%] 2

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 30, 2023
@aliemjay aliemjay added the A-implied-bounds Area: Implied bounds / inferred outlives-bounds label Mar 31, 2023
@aliemjay aliemjay marked this pull request as ready for review March 31, 2023 14:22
@rustbot
Copy link
Collaborator

rustbot commented Mar 31, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@aliemjay aliemjay added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 31, 2023
@bors
Copy link
Contributor

bors commented May 6, 2023

☀️ Try build successful - checks-actions
Build commit: 7ff4f56db6ea2b678c8cccb37dd6b260df25763c (7ff4f56db6ea2b678c8cccb37dd6b260df25763c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ff4f56db6ea2b678c8cccb37dd6b260df25763c): comparison URL.

Overall result: ❌ regressions - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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.3% [0.2%, 0.4%] 2
Regressions ❌
(secondary)
0.4% [0.2%, 0.6%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 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)
4.5% [3.6%, 5.3%] 4
Regressions ❌
(secondary)
3.1% [2.9%, 3.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 2
All ❌✅ (primary) 4.5% [3.6%, 5.3%] 4

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)
1.3% [0.8%, 2.0%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.3% [0.8%, 2.0%] 3

Binary size

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

Bootstrap: 653.481s -> 654.306s (0.13%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 7, 2023
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long review latency here.

Just a few smaller thoughts, before digging into the logic.

}
})
.collect()
) -> impl Iterator<Item = OutlivesBound<'tcx>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this cleanup into a separate commit or PR?

param_env: ty::ParamEnv<'tcx>,
arg: GenericArg<'tcx>,
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
) -> Vec<traits::PredicateObligation<'tcx>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too can be moved into a separate commit or PR?

@@ -1828,7 +1828,7 @@ rustc_queries! {
desc { "normalizing `{}`", goal.value }
}

query implied_outlives_bounds(
query implied_outlives_bounds_compat(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it seems like most places still use this, it seems like it would make sense to keep this name the same, and name the new version v2 or something.

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally got through this, changes look good to me. I'm expecting the rebase might require retouching some of this code significantly. If so, I can review. Otherwise, r=me

@jackh726 jackh726 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2023
@lcnr
Copy link
Contributor

lcnr commented Aug 14, 2023

Before merging, I would like us to look more deeply into #109482 (comment).

rn this lints triggers for bevy with afaict no sensible way to silence the lint. Given that we may be able to avoid it by a sensible and small extension to implied bounds, we may be able to avoid this.

@jackh726
Copy link
Member

I think the extension to implied bounds is certainly possible. But I think a sensible extension won't be small and small extension won't be simple.

The sensible extension is to effectively allow types to have implied bounds from trait impls. The simple extension is to change nothing and continue to let this compile.

@lcnr
Copy link
Contributor

lcnr commented Sep 18, 2023

blocked on rust-lang/types-team#99, unnominating

@lcnr lcnr removed the I-types-nominated Nominated for discussion during a types team meeting. label Sep 18, 2023
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
if ty.has_infer() {
// Infer vars can appear only in invalid code. See #110161.
self.tcx.sess.delay_span_bug(DUMMY_SP, "infer vars in implied bounds");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, this line should be removed when/if this is rebased #115559

@spastorino
Copy link
Member

In case it's needed I was playing with this PR and "rebased" it in https://github.com/spastorino/rust/tree/lint-implied-bounds

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 2, 2023
lint incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of rust-lang#109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint.

Opening for crater

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 3, 2023
lint incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of rust-lang#109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint.

Opening for crater

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 7, 2023
lint incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of rust-lang#109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint.

Opening for crater

r? `@ghost`
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Dec 9, 2023
…ted-tests, r=jackh726

Add tests related to normalization in implied bounds

Getting `@aliemjay's` tests from rust-lang#109763, so we can better track what's going on in every different example.

r? `@jackh726`
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Dec 9, 2023
…ted-tests, r=jackh726

Add tests related to normalization in implied bounds

Getting ``@aliemjay's`` tests from rust-lang#109763, so we can better track what's going on in every different example.

r? ``@jackh726``
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Dec 9, 2023
…ted-tests, r=jackh726

Add tests related to normalization in implied bounds

Getting ```@aliemjay's``` tests from rust-lang#109763, so we can better track what's going on in every different example.

r? ```@jackh726```
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2023
Rollup merge of rust-lang#118512 - spastorino:add-implied-bounds-related-tests, r=jackh726

Add tests related to normalization in implied bounds

Getting ```@aliemjay's``` tests from rust-lang#109763, so we can better track what's going on in every different example.

r? ```@jackh726```
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2024
error on incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of rust-lang#109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint. This is tracked in rust-lang#119956.

Fixes rust-lang#109628
@jackh726
Copy link
Member

jackh726 commented Feb 5, 2024

Closing since #118553 landed.

@jackh726 jackh726 closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-implied-bounds Area: Implied bounds / inferred outlives-bounds perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bounds on trait impls are used in implied bounds
8 participants