From 2e09714dfe06f6cd252d0708a04741a5c36168e4 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 22 Mar 2021 15:17:01 +0800 Subject: bail out early for source code closures add closure error --- crates/hir_ty/src/display.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates') diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 3845009ae..981ba564d 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -190,6 +190,7 @@ impl DisplayTarget { pub enum DisplaySourceCodeError { PathNotFound, UnknownType, + Closure, } pub enum HirDisplayError { @@ -539,6 +540,11 @@ impl HirDisplay for Ty { } } TyKind::Closure(.., substs) => { + if f.display_target.is_source_code() { + return Err(HirDisplayError::DisplaySourceCodeError( + DisplaySourceCodeError::Closure, + )); + } let sig = substs[0].callable_sig(f.db); if let Some(sig) = sig { if sig.params().is_empty() { -- cgit v1.2.3