Uh oh!
There was an error while loading. Please reload this page.
Report higher-ranked trait error when higher-ranked projection goal fails in new solver - #139513
Conversation
rustbot
commented
Apr 8, 2025
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
6794b19 to
f6faaeeComparecompiler-errors
commented
Apr 9, 2025
Pulled this into another @bors r=lcnr rollup |
bors
commented
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( |
There was a problem hiding this comment.
| fndetect_error_in_higher_ranked_projection( | |
| fndetect_trait_error_in_higher_ranked_projection( |
r=me with this change
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.
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
…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
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
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
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
…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
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