rust/compiler/rustc_trait_selection/src
Matthias Krüger c264f3e4d8
Rollup merge of #139335 - compiler-errors:error-implies, r=oli-obk
Pass correct param-env to `error_implies`

Duplicated comment from the test:

In the error reporting code, when reporting fulfillment errors for goals A and B, we try to see if elaborating A will result in another goal that can equate with B. That would signal that B is "implied by" A, allowing us to skip reporting it, which is beneficial for cutting down on the number of diagnostics we report.

In the new trait solver especially, but even in the old trait solver through things like defining opaque type usages, this `can_equate` call was not properly taking the param-env of the goals, resulting in nested obligations that had empty param-envs. If one of these nested obligations was a `ConstParamHasTy` goal, then we would ICE, since those goals are particularly strict about the param-env they're evaluated in.

This is morally a fix for <https://github.com/rust-lang/rust/issues/139314>, but that repro uses details about how defining usages in the `check_opaque_well_formed` code can spring out of type equality, and will likely stop failing soon coincidentally once we start using `PostBorrowck` mode in that check. Instead, we use lazy normalization to end up generating an alias-eq goal whose nested goals woul trigger the ICE instead, since this is a lot more stable.

Fixes https://github.com/rust-lang/rust/issues/139314

r? ``@oli-obk`` or reassign
2025-04-04 08:02:08 +02:00
..
error_reporting Pass correct param-env to error_implies 2025-04-03 18:55:53 +00:00
errors Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
solve simplify Interner opaque types API 2025-04-01 23:24:28 +02:00
traits Auto merge of #120706 - Bryanskiy:leak, r=lcnr 2025-04-04 01:35:52 +00:00
errors.rs Don't use kw::Empty in hir::Lifetime::ident. 2025-03-28 10:15:23 +11:00
infer.rs Fix next solver handling of shallow trait impl check 2025-03-19 14:40:14 +00:00
lib.rs Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
regions.rs Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack 2025-03-04 18:18:48 +00:00
solve.rs impossible obligations check fast path 2024-10-10 06:09:50 -04:00