diff options
Diffstat (limited to 'crates/hir_ty/src/display.rs')
-rw-r--r-- | crates/hir_ty/src/display.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 97f1092c6..148eb7506 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive, | 19 | db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive, |
20 | to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy, | 20 | to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasEq, AliasTy, |
21 | CallableDefId, CallableSig, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime, OpaqueTy, | 21 | CallableDefId, CallableSig, DomainGoal, GenericArg, ImplTraitId, Interner, Lifetime, OpaqueTy, |
22 | ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, TraitRef, Ty, TyKind, WhereClause, | 22 | ProjectionTy, QuantifiedWhereClause, Scalar, TraitRef, Ty, TyExt, TyKind, WhereClause, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | pub struct HirFormatter<'a> { | 25 | pub struct HirFormatter<'a> { |
@@ -260,7 +260,7 @@ impl HirDisplay for ProjectionTy { | |||
260 | write!(f, "<{} as {}", first_parameter, trait_.name)?; | 260 | write!(f, "<{} as {}", first_parameter, trait_.name)?; |
261 | if self.substitution.len(&Interner) > 1 { | 261 | if self.substitution.len(&Interner) > 1 { |
262 | write!(f, "<")?; | 262 | write!(f, "<")?; |
263 | f.write_joined(&self.substitution.interned(&Interner)[1..], ", ")?; | 263 | f.write_joined(&self.substitution.interned()[1..], ", ")?; |
264 | write!(f, ">")?; | 264 | write!(f, ">")?; |
265 | } | 265 | } |
266 | write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty_id)).name)?; | 266 | write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty_id)).name)?; |
@@ -387,7 +387,7 @@ impl HirDisplay for Ty { | |||
387 | write!(f, ",)")?; | 387 | write!(f, ",)")?; |
388 | } else { | 388 | } else { |
389 | write!(f, "(")?; | 389 | write!(f, "(")?; |
390 | f.write_joined(&*substs.0, ", ")?; | 390 | f.write_joined(&*substs.interned(), ", ")?; |
391 | write!(f, ")")?; | 391 | write!(f, ")")?; |
392 | } | 392 | } |
393 | } | 393 | } |
@@ -415,7 +415,7 @@ impl HirDisplay for Ty { | |||
415 | // We print all params except implicit impl Trait params. Still a bit weird; should we leave out parent and self? | 415 | // We print all params except implicit impl Trait params. Still a bit weird; should we leave out parent and self? |
416 | if total_len > 0 { | 416 | if total_len > 0 { |
417 | write!(f, "<")?; | 417 | write!(f, "<")?; |
418 | f.write_joined(¶meters.0[..total_len], ", ")?; | 418 | f.write_joined(¶meters.interned()[..total_len], ", ")?; |
419 | write!(f, ">")?; | 419 | write!(f, ">")?; |
420 | } | 420 | } |
421 | } | 421 | } |
@@ -423,7 +423,7 @@ impl HirDisplay for Ty { | |||
423 | f.write_joined(sig.params(), ", ")?; | 423 | f.write_joined(sig.params(), ", ")?; |
424 | write!(f, ")")?; | 424 | write!(f, ")")?; |
425 | let ret = sig.ret(); | 425 | let ret = sig.ret(); |
426 | if *ret != Ty::unit() { | 426 | if !ret.is_unit() { |
427 | let ret_display = ret.into_displayable( | 427 | let ret_display = ret.into_displayable( |
428 | f.db, | 428 | f.db, |
429 | f.max_size, | 429 | f.max_size, |
@@ -468,7 +468,7 @@ impl HirDisplay for Ty { | |||
468 | .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) | 468 | .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) |
469 | .filter(|defaults| !defaults.is_empty()) | 469 | .filter(|defaults| !defaults.is_empty()) |
470 | { | 470 | { |
471 | None => parameters.0.as_ref(), | 471 | None => parameters.interned().as_ref(), |
472 | Some(default_parameters) => { | 472 | Some(default_parameters) => { |
473 | let mut default_from = 0; | 473 | let mut default_from = 0; |
474 | for (i, parameter) in parameters.iter(&Interner).enumerate() { | 474 | for (i, parameter) in parameters.iter(&Interner).enumerate() { |
@@ -490,11 +490,11 @@ impl HirDisplay for Ty { | |||
490 | } | 490 | } |
491 | } | 491 | } |
492 | } | 492 | } |
493 | ¶meters.0[0..default_from] | 493 | ¶meters.interned()[0..default_from] |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } else { | 496 | } else { |
497 | parameters.0.as_ref() | 497 | parameters.interned().as_ref() |
498 | }; | 498 | }; |
499 | if !parameters_to_write.is_empty() { | 499 | if !parameters_to_write.is_empty() { |
500 | write!(f, "<")?; | 500 | write!(f, "<")?; |
@@ -517,7 +517,7 @@ impl HirDisplay for Ty { | |||
517 | write!(f, "{}::{}", trait_.name, type_alias_data.name)?; | 517 | write!(f, "{}::{}", trait_.name, type_alias_data.name)?; |
518 | if parameters.len(&Interner) > 0 { | 518 | if parameters.len(&Interner) > 0 { |
519 | write!(f, "<")?; | 519 | write!(f, "<")?; |
520 | f.write_joined(&*parameters.0, ", ")?; | 520 | f.write_joined(&*parameters.interned(), ", ")?; |
521 | write!(f, ">")?; | 521 | write!(f, ">")?; |
522 | } | 522 | } |
523 | } else { | 523 | } else { |
@@ -591,7 +591,7 @@ impl HirDisplay for Ty { | |||
591 | write!(f, "{}", param_data.name.clone().unwrap_or_else(Name::missing))? | 591 | write!(f, "{}", param_data.name.clone().unwrap_or_else(Name::missing))? |
592 | } | 592 | } |
593 | TypeParamProvenance::ArgumentImplTrait => { | 593 | TypeParamProvenance::ArgumentImplTrait => { |
594 | let substs = Substitution::type_params_for_generics(f.db, &generics); | 594 | let substs = generics.type_params_subst(f.db); |
595 | let bounds = f | 595 | let bounds = f |
596 | .db | 596 | .db |
597 | .generic_predicates(id.parent) | 597 | .generic_predicates(id.parent) |
@@ -663,7 +663,7 @@ impl HirDisplay for CallableSig { | |||
663 | } | 663 | } |
664 | write!(f, ")")?; | 664 | write!(f, ")")?; |
665 | let ret = self.ret(); | 665 | let ret = self.ret(); |
666 | if *ret != Ty::unit() { | 666 | if !ret.is_unit() { |
667 | let ret_display = | 667 | let ret_display = |
668 | ret.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target); | 668 | ret.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target); |
669 | write!(f, " -> {}", ret_display)?; | 669 | write!(f, " -> {}", ret_display)?; |
@@ -727,13 +727,13 @@ fn write_bounds_like_dyn_trait( | |||
727 | // existential) here, which is the only thing that's | 727 | // existential) here, which is the only thing that's |
728 | // possible in actual Rust, and hence don't print it | 728 | // possible in actual Rust, and hence don't print it |
729 | write!(f, "{}", f.db.trait_data(trait_).name)?; | 729 | write!(f, "{}", f.db.trait_data(trait_).name)?; |
730 | if let [_, params @ ..] = &*trait_ref.substitution.0 { | 730 | if let [_, params @ ..] = &*trait_ref.substitution.interned() { |
731 | if is_fn_trait { | 731 | if is_fn_trait { |
732 | if let Some(args) = | 732 | if let Some(args) = |
733 | params.first().and_then(|it| it.assert_ty_ref(&Interner).as_tuple()) | 733 | params.first().and_then(|it| it.assert_ty_ref(&Interner).as_tuple()) |
734 | { | 734 | { |
735 | write!(f, "(")?; | 735 | write!(f, "(")?; |
736 | f.write_joined(&*args.0, ", ")?; | 736 | f.write_joined(&*args.interned(), ", ")?; |
737 | write!(f, ")")?; | 737 | write!(f, ")")?; |
738 | } | 738 | } |
739 | } else if !params.is_empty() { | 739 | } else if !params.is_empty() { |
@@ -789,7 +789,7 @@ impl TraitRef { | |||
789 | write!(f, "{}", f.db.trait_data(self.hir_trait_id()).name)?; | 789 | write!(f, "{}", f.db.trait_data(self.hir_trait_id()).name)?; |
790 | if self.substitution.len(&Interner) > 1 { | 790 | if self.substitution.len(&Interner) > 1 { |
791 | write!(f, "<")?; | 791 | write!(f, "<")?; |
792 | f.write_joined(&self.substitution.interned(&Interner)[1..], ", ")?; | 792 | f.write_joined(&self.substitution.interned()[1..], ", ")?; |
793 | write!(f, ">")?; | 793 | write!(f, ">")?; |
794 | } | 794 | } |
795 | Ok(()) | 795 | Ok(()) |