bail out early for source code closures

add closure error
This commit is contained in:
hi-rustin
2021-03-22 15:17:01 +08:00
parent 0d40ff5e62
commit 2e09714dfe
+6
View File
@@ -190,6 +190,7 @@ fn is_test(&self) -> bool {
pub enum DisplaySourceCodeError {
PathNotFound,
UnknownType,
Closure,
}
pub enum HirDisplayError {
@@ -539,6 +540,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() {