mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 21:16:27 +03:00
Merge pull request #21779 from Albab-Hasan/fix/next-solver-ir-print
fix: replace TODO placeholders in next-solver IrPrint with proper formatting
This commit is contained in:
@@ -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<Self>,
|
||||
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<rustc_type_ir::HostEffectPredicate<Self>> for DbInterner<'db> {
|
||||
@@ -97,7 +98,11 @@ fn print_debug(
|
||||
t: &rustc_type_ir::HostEffectPredicate<Self>,
|
||||
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<ty::ExistentialTraitRef<Self>> for DbInterner<'db> {
|
||||
@@ -183,7 +188,7 @@ fn print_debug(
|
||||
t: &ty::NormalizesTo<Self>,
|
||||
fmt: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t)))
|
||||
write!(fmt, "NormalizesTo({} -> {:?})", t.alias, t.term)
|
||||
}
|
||||
}
|
||||
impl<'db> IrPrint<ty::SubtypePredicate<Self>> for DbInterner<'db> {
|
||||
@@ -198,7 +203,7 @@ fn print_debug(
|
||||
t: &ty::SubtypePredicate<Self>,
|
||||
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<ty::CoercePredicate<Self>> for DbInterner<'db> {
|
||||
@@ -210,7 +215,7 @@ fn print_debug(
|
||||
t: &ty::CoercePredicate<Self>,
|
||||
fmt: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
fmt.write_str(&format!("TODO: {:?}", type_name_of_val(t)))
|
||||
write!(fmt, "CoercePredicate({:?} -> {:?})", t.a, t.b)
|
||||
}
|
||||
}
|
||||
impl<'db> IrPrint<ty::FnSig<Self>> for DbInterner<'db> {
|
||||
@@ -219,7 +224,9 @@ fn print(t: &ty::FnSig<Self>, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Re
|
||||
}
|
||||
|
||||
fn print_debug(t: &ty::FnSig<Self>, 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<DbInterner<'db>>,
|
||||
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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user