diff options
author | Lukas Wirth <[email protected]> | 2021-04-06 13:16:07 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-06 13:21:35 +0100 |
commit | ffdb2da49d08384368fbc50d4f60a8dfd2ab70ee (patch) | |
tree | e05b2c54ee5adb207fa7c364953b8d5160c014fd | |
parent | 002e72a28de3df818992442ad49bb60d3d0b1d0b (diff) |
Don't use HirDisplayWrapper when displaying SourceCode
-rw-r--r-- | crates/hir_ty/src/display.rs | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 8fe4ed3fa..4af2bcf7a 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -256,13 +256,9 @@ impl HirDisplay for ProjectionTy { | |||
256 | } | 256 | } |
257 | 257 | ||
258 | let trait_ = f.db.trait_data(self.trait_(f.db)); | 258 | let trait_ = f.db.trait_data(self.trait_(f.db)); |
259 | let first_parameter = self.self_type_parameter(&Interner).into_displayable( | 259 | write!(f, "<")?; |
260 | f.db, | 260 | self.self_type_parameter(&Interner).hir_fmt(f)?; |
261 | f.max_size, | 261 | write!(f, " as {}", trait_.name)?; |
262 | f.omit_verbose_types, | ||
263 | f.display_target, | ||
264 | ); | ||
265 | write!(f, "<{} as {}", first_parameter, trait_.name)?; | ||
266 | if self.substitution.len(&Interner) > 1 { | 262 | if self.substitution.len(&Interner) > 1 { |
267 | write!(f, "<")?; | 263 | write!(f, "<")?; |
268 | f.write_joined(&self.substitution.interned()[1..], ", ")?; | 264 | f.write_joined(&self.substitution.interned()[1..], ", ")?; |
@@ -341,9 +337,6 @@ impl HirDisplay for Ty { | |||
341 | write!(f, "]")?; | 337 | write!(f, "]")?; |
342 | } | 338 | } |
343 | TyKind::Raw(m, t) | TyKind::Ref(m, _, t) => { | 339 | TyKind::Raw(m, t) | TyKind::Ref(m, _, t) => { |
344 | let ty_display = | ||
345 | t.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target); | ||
346 | |||
347 | if matches!(self.kind(&Interner), TyKind::Raw(..)) { | 340 | if matches!(self.kind(&Interner), TyKind::Raw(..)) { |
348 | write!( | 341 | write!( |
349 | f, | 342 | f, |
@@ -398,16 +391,16 @@ impl HirDisplay for Ty { | |||
398 | if fn_traits(f.db.upcast(), trait_).any(|it| it == trait_) | 391 | if fn_traits(f.db.upcast(), trait_).any(|it| it == trait_) |
399 | && predicates.len() <= 2 | 392 | && predicates.len() <= 2 |
400 | { | 393 | { |
401 | return write!(f, "{}", ty_display); | 394 | return t.hir_fmt(f); |
402 | } | 395 | } |
403 | } | 396 | } |
404 | 397 | ||
405 | if predicates.len() > 1 { | 398 | if predicates.len() > 1 { |
406 | write!(f, "(")?; | 399 | write!(f, "(")?; |
407 | write!(f, "{}", ty_display)?; | 400 | t.hir_fmt(f)?; |
408 | write!(f, ")")?; | 401 | write!(f, ")")?; |
409 | } else { | 402 | } else { |
410 | write!(f, "{}", ty_display)?; | 403 | t.hir_fmt(f)?; |
411 | } | 404 | } |
412 | } | 405 | } |
413 | TyKind::Tuple(_, substs) => { | 406 | TyKind::Tuple(_, substs) => { |
@@ -454,14 +447,8 @@ impl HirDisplay for Ty { | |||
454 | write!(f, ")")?; | 447 | write!(f, ")")?; |
455 | let ret = sig.ret(); | 448 | let ret = sig.ret(); |
456 | if !ret.is_unit() { | 449 | if !ret.is_unit() { |
457 | let ret_display = ret.into_displayable( | 450 | write!(f, " -> ")?; |
458 | f.db, | 451 | ret.hir_fmt(f)?; |
459 | f.max_size, | ||
460 | f.omit_verbose_types, | ||
461 | f.display_target, | ||
462 | ); | ||
463 | |||
464 | write!(f, " -> {}", ret_display)?; | ||
465 | } | 452 | } |
466 | } | 453 | } |
467 | TyKind::Adt(AdtId(def_id), parameters) => { | 454 | TyKind::Adt(AdtId(def_id), parameters) => { |
@@ -603,13 +590,8 @@ impl HirDisplay for Ty { | |||
603 | write!(f, "|")?; | 590 | write!(f, "|")?; |
604 | }; | 591 | }; |
605 | 592 | ||
606 | let ret_display = sig.ret().into_displayable( | 593 | write!(f, " -> ")?; |
607 | f.db, | 594 | sig.ret().hir_fmt(f)?; |
608 | f.max_size, | ||
609 | f.omit_verbose_types, | ||
610 | f.display_target, | ||
611 | ); | ||
612 | write!(f, " -> {}", ret_display)?; | ||
613 | } else { | 595 | } else { |
614 | write!(f, "{{closure}}")?; | 596 | write!(f, "{{closure}}")?; |
615 | } | 597 | } |
@@ -697,9 +679,8 @@ impl HirDisplay for CallableSig { | |||
697 | write!(f, ")")?; | 679 | write!(f, ")")?; |
698 | let ret = self.ret(); | 680 | let ret = self.ret(); |
699 | if !ret.is_unit() { | 681 | if !ret.is_unit() { |
700 | let ret_display = | 682 | write!(f, " -> ")?; |
701 | ret.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target); | 683 | ret.hir_fmt(f)?; |
702 | write!(f, " -> {}", ret_display)?; | ||
703 | } | 684 | } |
704 | Ok(()) | 685 | Ok(()) |
705 | } | 686 | } |