-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
move implicit Sized
predicate to end of list
#86011
Conversation
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
dc71393
to
6676902
Compare
| | ||
::: $SRC_DIR/std/src/panicking.rs:LL:COL | ||
| | ||
LL | pub fn begin_panic<M: Any + Send>(msg: M) -> ! { | ||
| --- required by this bound in `begin_panic` | ||
| | ||
= note: cannot satisfy `_: Any` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is arguably a regression.
I made these two changes in order to have the right spans available. I'm not sure if these changes would be enough to address what you're mentioning here. 29c8a9f#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394R1480-R1485 29c8a9f#diff-ac1e6e554bac799e1e2d3886bea8fdc0d0bf04b20d33df59f5a8e92c41987ac6R2137-R2139
It some what does. I can point you at where that is happening, but if you search for where E0282 and E0284 are emitted, you'll find them. It's fine if there are small changes, we just might have to tweak the logic there to keep whatever checks we currently have.
Did this happen on tests or while working on rustc? Did it happen with |
r? @estebank |
Thanks for the review! I'll be taking a closer look at the things you pointed out and will probably reply in more detail soon.
I opened issue #86013 with more details. Basically, when I either applied or reverted the patches in this PR, the fingerprints changed and I got the ICE on a specific UI test case. For what it's worth, I built the stage1 compiler and libstd using As for whether this will cause fingerprint errors when this lands in stable? I'm not sure I know enough about the details of incremental compilation. Do we have some way of invalidating incremental compilation caches when there are internal changes to the compiler? (I hope so.) If so, how is this done? Is it part of the release process? Automatically according to the commit-hash stored during build? |
if you compare For issue-16966, I found this area to be somewhat suspicious: rust/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs Lines 1539 to 1543 in 6c2dd25
and I'm attempting to investigate. It maybe that the type inference ambiguity causes a bunch of simultaneous errors and we previously happened to get the Sized trait predicate first, outputting the more terse error E0282 instead of E0283.
|
What I thought was the "obvious" approach to quieting the new E0283 in issue-16966 has some nontrivial fallout. Maybe the smallest change to the diagnostics is what we already have in this pull request? Do you think we need to make additional changes in this pull request? I tried to see what would happen if I made this block in rust/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs Lines 1539 to 1543 in 6c2dd25
I wound up with these outputs from the UI tests: The "never" approach generates a lot more diffs in the stderr output than the "always" approach. (51 failures with "never", vs 19 failures with "always") A quick glance at the output from the "always" approach shows that the diffs are largely making some vague verbose diagnostics less verbose. My guess (partially confirmed by disabling some of the verbosity suppression) is that in the case of issue-16966, the type inference ambiguity was causing every trait bound to not be satisfied, and prior to my changes, we were luckily hitting Any opinions on whether the deleted verbosity with "always" was at all helpful? It sounds like you might be concerned that the E0283 now appearing with issue-16966 is too verbose? If so, how do you feel about the existing instances of E0283 verbosity that are deleted in the "always" approach? |
At a very quick glance, it seems like the always case removes a bunch of useful suggestions, while the never case is just more verbose and perhaps slightly misleading... I'll try to take a look at this PR with fresh eyes tomorrow, but I think we might want to merge as is. |
I wrote an update in #86013 (comment) It seems unlikely to affect users of released versions because invalidation of the incremental caches seems to honor changes in the commit hash. |
Opened #86371 with some discouraging findings. Maybe the better approach is to detect whether we are dealing with violating an implicit |
☔ The latest upstream changes (presumably #84623) made this pull request unmergeable. Please resolve the merge conflicts. |
@tlyu can you rebase? After that r=me, but I would still like to somehow fix |
6676902
to
6d851c8
Compare
@estebank Rebase done. I looked at #16966 and the change in the stderr in this PR isn't a necessarily a regression of the substance of that issue, which is about duplication of error messages. (The change in I think there's a big rabbit hole here of various error reporting heuristics that use the failure to satisfy the implicit |
☔ The latest upstream changes (presumably #87540) made this pull request unmergeable. Please resolve the merge conflicts. |
6d851c8
to
19f32a9
Compare
Rebased again. |
☔ The latest upstream changes (presumably #87628) made this pull request unmergeable. Please resolve the merge conflicts. |
triage: @tlyu could you rebase again? Then perhaps ping estebank to let them know the PR is ready to be approved. Thanks! |
19f32a9
to
c07f5c4
Compare
Looking at the output after the rebase, I am much more comfortable landing this as is. Apologies for the delay in landing this! @bors r+ |
📌 Commit c07f5c4 has been approved by |
…stebank move implicit `Sized` predicate to end of list In `Bounds::predicates()`, move the implicit `Sized` predicate to the end of the generated list. This means that if there is an explicit `Sized` bound, it will be checked first, and any resulting diagnostics will have a more useful span. Fixes rust-lang#85998, at least partially. ~~Based on rust-lang#85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter. I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason. I also ran into an instance of rust-lang#84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful. `@estebank` this seems likely to conflict (slightly?) with your work on rust-lang#85947; how would you like to resolve that?
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#86011 (move implicit `Sized` predicate to end of list) - rust-lang#89821 (Add a strange test for `unsafe_code` lint.) - rust-lang#89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant) - rust-lang#89870 (Suggest Box::pin when Pin::new is used instead) - rust-lang#89880 (Use non-checking TLS relocation in aarch64 asm! sym test.) - rust-lang#89885 (add long explanation for E0183) - rust-lang#89894 (Remove unused dependencies from rustc_const_eval) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Revert rust-lang#86011 to fix an incorrect bound check This reverts commit 36a1076, reversing changes made to e1e9319. Fixes rust-lang#89935 r? `@estebank`
Revert rust-lang#86011 to fix an incorrect bound check This reverts commit 36a1076, reversing changes made to e1e9319. Fixes rust-lang#89935 r? `@estebank`
Revert rust-lang#86011 to fix an incorrect bound check This reverts commit 36a1076, reversing changes made to e1e9319. Fixes rust-lang#89935 r? ``@estebank``
Rollup of 10 pull requests Successful merges: - rust-lang#86479 (Automatic exponential formatting in Debug) - rust-lang#87404 (Add support for artifact size profiling) - rust-lang#87769 (Alloc features cleanup) - rust-lang#88789 (remove unnecessary bound on Zip specialization impl) - rust-lang#88860 (Deduplicate panic_fmt) - rust-lang#90009 (Make more `From` impls `const` (libcore)) - rust-lang#90018 (Fix rustdoc UI for very long type names) - rust-lang#90025 (Revert rust-lang#86011 to fix an incorrect bound check) - rust-lang#90036 (Remove border-bottom from most docblocks.) - rust-lang#90060 (Update RELEASES.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…ulacrum [beta] backports * Don't emit a warning for empty rmeta files. rust-lang#90072 * Erase late-bound regions before computing vtable debuginfo name. rust-lang#90050 * Fix wrong niche calculation when 2+ niches are placed at the start rust-lang#90040 * Revert rust-lang#86011 to fix an incorrect bound check rust-lang#90025 * Fix macro_rules! duplication when reexported in the same module rust-lang#89867 * Bump cargo to include rust-lang/cargo#9979 - Fix fetching git repos after a force push. r? `@Mark-Simulacrum`
In
Bounds::predicates()
, move the implicitSized
predicate to theend of the generated list. This means that if there is an explicit
Sized
bound, it will be checked first, and any resultingdiagnostics will have a more useful span.
Fixes #85998, at least partially.
Based on #85979, but only the last 2 commits are new for this pull request.(edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicitSized
predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with
Sized
bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.
@estebank this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?