Report higher-ranked trait error when higher-ranked projection goal fails in new solver#139513
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 10, 2025
Merged
Conversation
Collaborator
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
compiler-errors
commented
Apr 8, 2025
lcnr
reviewed
Apr 8, 2025
compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
Outdated
Show resolved
Hide resolved
…ails in new solver
6794b19 to
f6faaee
Compare
Contributor
Author
|
Pulled this into another @bors r=lcnr rollup |
Collaborator
lcnr
reviewed
Apr 9, 2025
| /// `NormalizesTo` goal, so we don't fall back to the rigid projection check | ||
| /// that should catch when a projection goal fails due to an unsatisfied trait | ||
| /// goal. | ||
| fn detect_error_in_higher_ranked_projection( |
Contributor
There was a problem hiding this comment.
Suggested change
| fn detect_error_in_higher_ranked_projection( | |
| fn detect_trait_error_in_higher_ranked_projection( |
r=me with this change
Contributor
Author
There was a problem hiding this comment.
Already got rolled up, and I don't think this is a significant enough change to kick it out of the rollup. I'll fold this into #139513 which is based off this one.
Contributor
Author
There was a problem hiding this comment.
Unless this fails to merge in which case I'll amend this. I'll keep an eye on the rollup lol
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 9, 2025
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#138470 (Test interaction between RFC 2229 migration and use closures) - rust-lang#138628 (Add more ergonomic clone tests) - rust-lang#139164 (std: improve documentation for get_mut() methods regarding forgotten guards) - rust-lang#139488 (Add missing regression GUI test) - rust-lang#139489 (compiletest: Add directive `dont-require-annotations`) - rust-lang#139513 (Report higher-ranked trait error when higher-ranked projection goal fails in new solver) - rust-lang#139521 (triagebot: roll compiler reviewers for rustc/unstable book) - rust-lang#139532 (Update `u8`-to-and-from-`i8` suggestions.) - rust-lang#139551 (report call site of inlined scopes for large assignment lints) - rust-lang#139575 (Remove redundant words) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 10, 2025
Rollup merge of rust-lang#139513 - compiler-errors:higher-ranked-proj, r=lcnr Report higher-ranked trait error when higher-ranked projection goal fails in new solver ~~See HACK comment inline. Not actually sure if it should be marked as a *HACK*, b/c~~ it's kinda a legitimate case we want to care about unless we're going to make the proof tree visitor *smarter* about the leak check than the actual trait solver itself. Encountered this while battling with `NiceRegionError`s in the old solver b/c I wondered what this code ended up giving us in the *new* solver as a comparison: ```rust trait Foo {} impl<T: FnOnce(&())> Foo for T {} fn baz<T: Foo>() {} fn main() { baz::<fn(&'static ())>(); } ``` On master it's pretty bad: ``` error[E0271]: type mismatch resolving `<fn(&()) as FnOnce<(&(),)>>::Output == ()` --> <source>:8:11 | 8 | baz::<fn(&'static ())>(); | ^^^^^^^^^^^^^^^ types differ | note: required for `fn(&'static ())` to implement `Foo` --> <source>:3:22 | 3 | impl<T: FnOnce(&())> Foo for T {} | ----------- ^^^ ^ | | | unsatisfied trait bound introduced here ``` After this PR it's much better: ``` error[E0277]: the trait bound `fn(&'static ()): Foo` is not satisfied --> /home/mgx/test.rs:8:11 | 8 | baz::<fn(&'static ())>(); | ^^^^^^^^^^^^^^^ the trait `for<'a> FnOnce(&'a ())` is not implemented for `fn(&'static ())` | = note: expected a closure with arguments `(&'static (),)` found a closure with arguments `(&(),)` note: required for `fn(&'static ())` to implement `Foo` --> /home/mgx/test.rs:3:22 | 3 | impl<T: FnOnce(&())> Foo for T {} | ----------- ^^^ ^ | | | unsatisfied trait bound introduced here note: required by a bound in `baz` --> /home/mgx/test.rs:5:11 | 5 | fn baz<T: Foo>() {} | ^^^ required by this bound in `baz` ``` r? lcnr
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Apr 11, 2025
Deeply normalize obligations in `BestObligation` folder Built on rust-lang#139513. This establishes a somewhat rough invariant that the `Obligation`'s predicate is always deeply normalized in the folder; when we construct a new obligation we normalize it. Putting this up for discussion since it does affect some goals. r? lcnr
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 11, 2025
Rollup merge of rust-lang#139564 - compiler-errors:deeply-norm, r=lcnr Deeply normalize obligations in `BestObligation` folder Built on rust-lang#139513. This establishes a somewhat rough invariant that the `Obligation`'s predicate is always deeply normalized in the folder; when we construct a new obligation we normalize it. Putting this up for discussion since it does affect some goals. r? lcnr
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
Apr 19, 2025
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#138470 (Test interaction between RFC 2229 migration and use closures) - rust-lang#138628 (Add more ergonomic clone tests) - rust-lang#139164 (std: improve documentation for get_mut() methods regarding forgotten guards) - rust-lang#139488 (Add missing regression GUI test) - rust-lang#139489 (compiletest: Add directive `dont-require-annotations`) - rust-lang#139513 (Report higher-ranked trait error when higher-ranked projection goal fails in new solver) - rust-lang#139521 (triagebot: roll compiler reviewers for rustc/unstable book) - rust-lang#139532 (Update `u8`-to-and-from-`i8` suggestions.) - rust-lang#139551 (report call site of inlined scopes for large assignment lints) - rust-lang#139575 (Remove redundant words) r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See HACK comment inline. Not actually sure if it should be marked as a HACK, b/cit's kinda a legitimate case we want to care about unless we're going to make the proof tree visitor smarter about the leak check than the actual trait solver itself.Encountered this while battling with
NiceRegionErrors in the old solver b/c I wondered what this code ended up giving us in the new solver as a comparison:On master it's pretty bad:
After this PR it's much better:
r? lcnr