From 69b78edb5e2a40d8665db713d363bd16c835d6cf Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 12 Dec 2020 18:18:19 +0100 Subject: Don't HirDisplay unknown types when displaying for source --- crates/hir_ty/src/display.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index e77481906..aa286c8c2 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -178,6 +178,7 @@ impl DisplayTarget { #[derive(Debug)] pub enum DisplaySourceCodeError { PathNotFound, + UnknownType, } pub enum HirDisplayError { @@ -558,7 +559,14 @@ impl HirDisplay for Ty { } }; } - Ty::Unknown => write!(f, "{{unknown}}")?, + Ty::Unknown => { + if f.display_target.is_source_code() { + return Err(HirDisplayError::DisplaySourceCodeError( + DisplaySourceCodeError::UnknownType, + )); + } + write!(f, "{{unknown}}")?; + } Ty::Infer(..) => write!(f, "_")?, } Ok(()) -- cgit v1.2.3