From 901cb4cf4006888dc69d95666886960c31e2c75a Mon Sep 17 00:00:00 2001 From: Albab-Hasan Date: Sat, 7 Mar 2026 22:09:48 +0600 Subject: [PATCH 1/2] fix: implement ir_print debug for next-solver predicate types seven IrPrint::print_debug implementations in the next-solver were placeholder stubs that returned "TODO: " instead of meaningful output. these are called via the Display impl (and Debug for PatternKind) of these types, so any solver trace log containing them was unreadable. implemented proper formatting for each: - TraitPredicate -> "T: Trait" / "!T: Trait" - HostEffectPredicate -> "const T: Trait" / "[const] T: Trait" - NormalizesTo -> "AliasTerm(...) -> Term" - SubtypePredicate -> "A <: B" - CoercePredicate -> "A -> B" - FnSig -> "fn([inputs]) -> output" - PatternKind -> "start..=end" / "or([...])" / "!null" also removed the now-unused type_name_of_val import. --- .../crates/hir-ty/src/next_solver/ir_print.rs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs index 998aab5a3fff..8569b828ae11 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs @@ -1,7 +1,5 @@ //! Things related to IR printing in the next-trait-solver. -use std::any::type_name_of_val; - use rustc_type_ir::{self as ty, ir_print::IrPrint}; use super::SolverDefId; @@ -82,7 +80,10 @@ fn print_debug( t: &ty::TraitPredicate, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + match t.polarity { + ty::PredicatePolarity::Positive => write!(fmt, "{:?}", t.trait_ref), + ty::PredicatePolarity::Negative => write!(fmt, "!{:?}", t.trait_ref), + } } } impl<'db> IrPrint> for DbInterner<'db> { @@ -97,7 +98,11 @@ fn print_debug( t: &rustc_type_ir::HostEffectPredicate, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + let prefix = match t.constness { + ty::BoundConstness::Const => "const", + ty::BoundConstness::Maybe => "[const]", + }; + write!(fmt, "{prefix} {:?}", t.trait_ref) } } impl<'db> IrPrint> for DbInterner<'db> { @@ -183,7 +188,7 @@ fn print_debug( t: &ty::NormalizesTo, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + write!(fmt, "{} -> {:?}", t.alias, t.term) } } impl<'db> IrPrint> for DbInterner<'db> { @@ -198,7 +203,7 @@ fn print_debug( t: &ty::SubtypePredicate, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + write!(fmt, "{:?} <: {:?}", t.a, t.b) } } impl<'db> IrPrint> for DbInterner<'db> { @@ -210,7 +215,7 @@ fn print_debug( t: &ty::CoercePredicate, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + write!(fmt, "{:?} -> {:?}", t.a, t.b) } } impl<'db> IrPrint> for DbInterner<'db> { @@ -219,7 +224,9 @@ fn print(t: &ty::FnSig, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Re } fn print_debug(t: &ty::FnSig, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + let tys = t.inputs_and_output.as_slice(); + let (output, inputs) = tys.split_last().unwrap(); + write!(fmt, "fn({:?}) -> {:?}", inputs, output) } } @@ -235,6 +242,10 @@ fn print_debug( t: &rustc_type_ir::PatternKind>, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t))) + match t { + ty::PatternKind::Range { start, end } => write!(fmt, "{:?}..={:?}", start, end), + ty::PatternKind::Or(list) => write!(fmt, "or({:?})", list), + ty::PatternKind::NotNull => fmt.write_str("!null"), + } } } From e4e8ae7660240d32b79f323066c4e10c9b68aecd Mon Sep 17 00:00:00 2001 From: Albab-Hasan Date: Sun, 8 Mar 2026 11:03:05 +0600 Subject: [PATCH 2/2] fix: qualify NormalizesTo and CoercePredicate in ir_print debug output --- .../rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs index 8569b828ae11..65931549db02 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs @@ -188,7 +188,7 @@ fn print_debug( t: &ty::NormalizesTo, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - write!(fmt, "{} -> {:?}", t.alias, t.term) + write!(fmt, "NormalizesTo({} -> {:?})", t.alias, t.term) } } impl<'db> IrPrint> for DbInterner<'db> { @@ -215,7 +215,7 @@ fn print_debug( t: &ty::CoercePredicate, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { - write!(fmt, "{:?} -> {:?}", t.a, t.b) + write!(fmt, "CoercePredicate({:?} -> {:?})", t.a, t.b) } } impl<'db> IrPrint> for DbInterner<'db> {