Normalize before checking trivial bounds - #159118
Conversation
|
Seems like CI is failing because of this proc macro in salsa: https://github.com/salsa-rs/salsa/blob/5e239195eee4e54440b84593396ec1c8ca37146c/components/salsa-macro-rules/src/setup_tracked_fn.rs#L495-L497 So I guess it's a hacky version of "trivial_bounds but for stable" to make set_lru_capacity uncallable when the lru's size isn't provided?
|
This comment has been minimized.
This comment has been minimized.
I think not checking trivial bounds if they are higher ranked where-clauses is intended. We want to give users a way to opt-out of this check and this is something that users rely on. I want us to continue to ignore |
|
Ah got it, I looked through #48214 and couldn't find much discussion as to whether this should be allowed or not, so thanks for clarifying. I updated the tests and changed it back to |
This comment has been minimized.
This comment has been minimized.
|
This PR modifies |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR changes a file inside |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors try @rust-timer queue let's do a crater run 😁 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Normalize before checking trivial bounds
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ac56ae8): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 4.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 487.476s -> 490.061s (0.53%) |
|
☔ The latest upstream changes (presumably #154989) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
So of the dependency tree roots that caused other crates to transitively fail:
wyre-0.2.16 seems to be spurious, since cargo failed to resolve its Of the ones whose latest still don't compile:
For the last three crates, the bounds were false and the functions were never callable in the first place, so adding the higher-ranked binder preserves existing behavior while letting them compile again, which I verified using the branch's stage1. |
| fn ice() | ||
| where | ||
| (for<'b> fn(&'b ())): Trait | ||
| //~^ ERROR the trait bound `for<'b> fn(&'b ()): Trait` is not satisfied |
There was a problem hiding this comment.
please instead add feature(trivial_bounds) and keep this as check-pass. Otherwise this test doesn't test what it's intended to anymore
| let pred = self.deeply_normalize(span, None, Unnormalized::new_wip(pred)); | ||
| if pred.is_global() && pred.kind().bound_vars().is_empty() { |
There was a problem hiding this comment.
one option would be to only check pred.is_is_global() && normalize_pred && normalized_pred.is_global() which would allow <T as Normalize>::WillBeUsize: Trait to keep compiling.
Doing this would minimize the breakage and perf impact.
One other option would be to change this function to not be on the wf-check but instead use a separate ObligationCtxt at which point we should then be able to emit the trait errors as future compat warnings instead.
Thinking about this, I generally feel kind of :/ about breaking anything here. I feel like trivial bounds should be a deny-by-default lint and we should just stabilize feature(trivial_bounds) 🤔
not sure what to ask/expect of you here. Would you be interested in looking into the existing trivial_bounds tracking issue and related work/discussions to try and summarize what is blocking there currently?
View all comments
Based on #140313
zulip discussion: #t-types > working on issue #154145
Currently, if a trivial bound is placed on an assoc type, and the type contains generics,
check_false_global_boundsimproperly tries to prove the predicate globally, since normalization, which would reveal the generics, happens only after theis_global()check. This PR moves normalization occur before the globality check. Additionally, we skip only the outermost HRTB withpred.kind().bound_vars().is_empty()rather than checking!pred.has_type_flags(TypeFlags::HAS_BINDER_VARS).As a consequence of normalizing, this PR emits errors for code like this, which currently compiles:
fixes #154145
fixes #140309
r? lcnr