aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/display.rs')
-rw-r--r--crates/hir_ty/src/display.rs37
1 files changed, 27 insertions, 10 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 64b68014d..f389c5a4b 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -380,20 +380,34 @@ impl HirDisplay for ApplicationTy {
380 write!(f, ">")?; 380 write!(f, ">")?;
381 } 381 }
382 } 382 }
383 TypeCtor::ForeignType(type_alias) => {
384 let type_alias = f.db.type_alias_data(type_alias);
385 write!(f, "{}", type_alias.name)?;
386 if self.parameters.len() > 0 {
387 write!(f, "<")?;
388 f.write_joined(&*self.parameters.0, ", ")?;
389 write!(f, ">")?;
390 }
391 }
383 TypeCtor::OpaqueType(opaque_ty_id) => { 392 TypeCtor::OpaqueType(opaque_ty_id) => {
384 let bounds = match opaque_ty_id { 393 match opaque_ty_id {
385 OpaqueTyId::ReturnTypeImplTrait(func, idx) => { 394 OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
386 let datas = 395 let datas =
387 f.db.return_type_impl_traits(func).expect("impl trait id without data"); 396 f.db.return_type_impl_traits(func).expect("impl trait id without data");
388 let data = (*datas) 397 let data = (*datas)
389 .as_ref() 398 .as_ref()
390 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); 399 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
391 data.subst(&self.parameters) 400 let bounds = data.subst(&self.parameters);
401 write!(f, "impl ")?;
402 write_bounds_like_dyn_trait(&bounds.value, f)?;
403 // FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution
392 } 404 }
393 }; 405 OpaqueTyId::AsyncBlockTypeImplTrait(..) => {
394 write!(f, "impl ")?; 406 write!(f, "impl Future<Output = ")?;
395 write_bounds_like_dyn_trait(&bounds.value, f)?; 407 self.parameters[0].hir_fmt(f)?;
396 // FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution 408 write!(f, ">")?;
409 }
410 }
397 } 411 }
398 TypeCtor::Closure { .. } => { 412 TypeCtor::Closure { .. } => {
399 let sig = self.parameters[0].callable_sig(f.db); 413 let sig = self.parameters[0].callable_sig(f.db);
@@ -474,18 +488,21 @@ impl HirDisplay for Ty {
474 write_bounds_like_dyn_trait(predicates, f)?; 488 write_bounds_like_dyn_trait(predicates, f)?;
475 } 489 }
476 Ty::Opaque(opaque_ty) => { 490 Ty::Opaque(opaque_ty) => {
477 let bounds = match opaque_ty.opaque_ty_id { 491 match opaque_ty.opaque_ty_id {
478 OpaqueTyId::ReturnTypeImplTrait(func, idx) => { 492 OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
479 let datas = 493 let datas =
480 f.db.return_type_impl_traits(func).expect("impl trait id without data"); 494 f.db.return_type_impl_traits(func).expect("impl trait id without data");
481 let data = (*datas) 495 let data = (*datas)
482 .as_ref() 496 .as_ref()
483 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); 497 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
484 data.subst(&opaque_ty.parameters) 498 let bounds = data.subst(&opaque_ty.parameters);
499 write!(f, "impl ")?;
500 write_bounds_like_dyn_trait(&bounds.value, f)?;
501 }
502 OpaqueTyId::AsyncBlockTypeImplTrait(..) => {
503 write!(f, "{{async block}}")?;
485 } 504 }
486 }; 505 };
487 write!(f, "impl ")?;
488 write_bounds_like_dyn_trait(&bounds.value, f)?;
489 } 506 }
490 Ty::Unknown => write!(f, "{{unknown}}")?, 507 Ty::Unknown => write!(f, "{{unknown}}")?,
491 Ty::Infer(..) => write!(f, "_")?, 508 Ty::Infer(..) => write!(f, "_")?,