diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-14 18:15:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-14 18:15:32 +0200 |
| commit | 87c319a7701640185ebb8b3e043173ffaab542de (patch) | |
| tree | 25d191e1caf04cdaf84336195ceb4ec659b9b243 | |
| parent | 143f5d76966b6f166187d82ca44ead7e36108fde (diff) | |
| parent | 83ea3454dfaf7ff54171035a70a89d03085d2a9d (diff) | |
Rollup merge of #139777 - compiler-errors:debuggier-proj, r=lcnr
Remove `define_debug_via_print` for `ExistentialProjection`, use regular structural debug impl
The pretty print impl for `ExistentialProjection` always prints `AssocItem = Ty`:
https://github.com/rust-lang/rust/blob/6e830462330a9e34d8176e86d4580dd0820c6fd5/compiler/rustc_middle/src/ty/print/pretty.rs#L3293-L3299
We can't change this, b/c it's used for both pretty printing dyn types and for legacy symbol mangling.
Unfortunately, we also use this printing procedure for `Debug` impls. That means that it leaves out the *trait name* and *trait args* when debug printing an `ExistentialProjection` (or an `ExistentialPredicate` which has a variant for `ExistentialProjection`). This leads to awkward situations, like the two seemingly identical existential projection predicates present in a `dyn Trait` type using the definition below:
```rust
trait Super { type Assoc; }
trait Foo: Super<A, Assoc = i32> + Super<B, Assoc = i32> {}
```
Namely, they both just render as `Projection(Assoc = i32)`! This makes debugging `dyn Trait` type system bugs really hard, so let's use the *regular* debug impl for `ExistentialProjection`.
| -rw-r--r-- | compiler/rustc_type_ir/src/ir_print.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/predicate.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_type_ir/src/ir_print.rs b/compiler/rustc_type_ir/src/ir_print.rs index c259a9747f0..388ad09cb20 100644 --- a/compiler/rustc_type_ir/src/ir_print.rs +++ b/compiler/rustc_type_ir/src/ir_print.rs @@ -60,7 +60,7 @@ define_display_via_print!( PatternKind, ); -define_debug_via_print!(TraitRef, ExistentialTraitRef, ExistentialProjection, PatternKind); +define_debug_via_print!(TraitRef, ExistentialTraitRef, PatternKind); impl<I: Interner, T> fmt::Display for OutlivesPredicate<I, T> where diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index 22d0fa23d0c..8e10636ff65 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -374,7 +374,7 @@ impl<I: Interner> ty::Binder<I, ExistentialTraitRef<I>> { } /// A `ProjectionPredicate` for an `ExistentialTraitRef`. -#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)] +#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)] #[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)] #[cfg_attr( feature = "nightly", |
