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?
There was a problem hiding this comment.
I looked into this a little bit. The tracking issue itself says stabilization is blocked on next-solver, and I also went through the open issues myself. Of the F-trivial_bounds tagged issues that are still open:
trivial_boundslint lints on non-global associated type constraints #140311 is a bad diagnostics issue that reproduces on both old and next solver- Impossible bounds cause a linker error in a dylib. #128682 is a weird linker error that also reproduces on both
- ICE: "Missing value for constant, but no error reported?" with unresolvabe const due to trivial bounds #135617 ICEs on old solver and emits E0282 on next solver
- ICE with #[derive(rkyv::Archive)] on cyclic enum #123238 seems to no longer ICE on either solver (hooray!)
and of the issues tagged with A-impossible_bounds that still reproduce:
- [ICE]: Operand evaluation failure during slice pattern matching with Sized constraint #153076, [ICE]: ICE with multiple Drop impls with impossible bound and
Self: Drop#153947, ICE from specializing Drop impl with impossible bound #150387 ICE on both solvers - Function with impossible-to-satisfy higher-ranked bound triggers error when a closure is present #89409 is a weird diagnostic that still reproduces on both solvers
- assoc types in binders can pass wf check but error when trying to normalize via impl #161405 is an unsoundness whose fix depends on assumptions-on-binders
min_specializationis unsound due to trivially-false lifetime bound #149257 is an unsoundness that still reproduces on old solver, but not on next-solver. It's also related to min_specialization, so I feel like this is more of a min_specialization thing than a blocker on stabilization.
Hi there! This project surfaced while assessing what potential breakage PR rust-lang/rust#159118 would cause to the Rust ecosystem. The PR fixes a bug in the compiler where some unsatisfiable `where`-clauses would be allowed to compile without error. Unfortunately, after this fix, this project will no longer compile, since the code generated by lelwel contains a `Default` bound that `ParserContext` doesn't satisfy. To allow the code to continue to compile, this PR just adds a `#[derive(Default)]` on `ParserContext`, since all of its fields are already `Default`. lelwel itself also has an open PR addressing the `Default` bound in question: 0x2a-42/lelwel#70 For reference, the full list of build failures caused by the rustc PR can be found here: https://crater-reports.s3.amazonaws.com/pr-159118/index.html
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