diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index cc6b93d37ad..6149067c73a 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -190,6 +190,7 @@ fn is_test(&self) -> bool { pub enum DisplaySourceCodeError { PathNotFound, UnknownType, + Closure, } pub enum HirDisplayError { @@ -543,6 +544,11 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { } } 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() {