Nicer display of projections in Chalk logs

This commit is contained in:
Florian Diebold 2020-04-13 14:39:44 +02:00
parent 7886513f89
commit 2e7b88b525
3 changed files with 12 additions and 8 deletions

1
Cargo.lock generated
View file

@ -1013,6 +1013,7 @@ dependencies = [
"chalk-solve",
"ena",
"insta",
"itertools",
"log",
"ra_arena",
"ra_db",

View file

@ -8,6 +8,7 @@ authors = ["rust-analyzer developers"]
doctest = false
[dependencies]
itertools = "0.9.0"
arrayvec = "0.5.1"
smallvec = "1.2.0"
ena = "0.13.1"

View file

@ -2,6 +2,7 @@
use std::fmt;
use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName};
use itertools::Itertools;
use super::{from_chalk, Interner};
use crate::{db::HirDatabase, CallableDef, TypeCtor};
@ -133,14 +134,15 @@ impl DebugContext<'_> {
};
let trait_data = self.0.trait_data(trait_);
let params = alias.substitution.parameters(&Interner);
write!(
fmt,
"<{:?} as {}<{:?}>>::{}",
&params[0],
trait_data.name,
&params[1..],
type_alias_data.name
)
write!(fmt, "<{:?} as {}", &params[0], trait_data.name,)?;
if params.len() > 1 {
write!(
fmt,
"<{}>",
&params[1..].iter().format_with(", ", |x, f| f(&format_args!("{:?}", x))),
)?;
}
write!(fmt, ">::{}", type_alias_data.name)
}
pub fn debug_ty(