8144: bail out early for source code closures r=Veykril a=hi-rustin

close https://github.com/rust-analyzer/rust-analyzer/issues/8084

Co-authored-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
bors[bot] 2021-03-22 12:35:44 +00:00 committed by GitHub
commit 3af1885bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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() {