aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_ty/src/display.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs
index c3d92a268..13ecd537a 100644
--- a/crates/ra_hir_ty/src/display.rs
+++ b/crates/ra_hir_ty/src/display.rs
@@ -190,8 +190,6 @@ impl HirDisplay for ApplicationTy {
190 }; 190 };
191 write!(f, "{}", name)?; 191 write!(f, "{}", name)?;
192 if self.parameters.len() > 0 { 192 if self.parameters.len() > 0 {
193 write!(f, "<")?;
194
195 let mut non_default_parameters = Vec::with_capacity(self.parameters.len()); 193 let mut non_default_parameters = Vec::with_capacity(self.parameters.len());
196 let parameters_to_write = if f.omit_verbose_types() { 194 let parameters_to_write = if f.omit_verbose_types() {
197 match self 195 match self
@@ -200,8 +198,8 @@ impl HirDisplay for ApplicationTy {
200 .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) 198 .map(|generic_def_id| f.db.generic_defaults(generic_def_id))
201 .filter(|defaults| !defaults.is_empty()) 199 .filter(|defaults| !defaults.is_empty())
202 { 200 {
203 Option::None => self.parameters.0.as_ref(), 201 None => self.parameters.0.as_ref(),
204 Option::Some(default_parameters) => { 202 Some(default_parameters) => {
205 for (i, parameter) in self.parameters.iter().enumerate() { 203 for (i, parameter) in self.parameters.iter().enumerate() {
206 match (parameter, default_parameters.get(i)) { 204 match (parameter, default_parameters.get(i)) {
207 (&Ty::Unknown, _) | (_, None) => { 205 (&Ty::Unknown, _) | (_, None) => {
@@ -221,7 +219,7 @@ impl HirDisplay for ApplicationTy {
221 } else { 219 } else {
222 self.parameters.0.as_ref() 220 self.parameters.0.as_ref()
223 }; 221 };
224 222 write!(f, "<")?;
225 f.write_joined(parameters_to_write, ", ")?; 223 f.write_joined(parameters_to_write, ", ")?;
226 write!(f, ">")?; 224 write!(f, ">")?;
227 } 225 }
@@ -231,9 +229,9 @@ impl HirDisplay for ApplicationTy {
231 AssocContainerId::TraitId(it) => it, 229 AssocContainerId::TraitId(it) => it,
232 _ => panic!("not an associated type"), 230 _ => panic!("not an associated type"),
233 }; 231 };
234 let trait_name = f.db.trait_data(trait_).name.clone(); 232 let trait_ = f.db.trait_data(trait_);
235 let name = f.db.type_alias_data(type_alias).name.clone(); 233 let type_alias = f.db.type_alias_data(type_alias);
236 write!(f, "{}::{}", trait_name, name)?; 234 write!(f, "{}::{}", trait_.name, type_alias.name)?;
237 if self.parameters.len() > 0 { 235 if self.parameters.len() > 0 {
238 write!(f, "<")?; 236 write!(f, "<")?;
239 f.write_joined(&*self.parameters.0, ", ")?; 237 f.write_joined(&*self.parameters.0, ", ")?;
@@ -266,8 +264,8 @@ impl HirDisplay for ProjectionTy {
266 return write!(f, "{}", TYPE_HINT_TRUNCATION); 264 return write!(f, "{}", TYPE_HINT_TRUNCATION);
267 } 265 }
268 266
269 let trait_name = f.db.trait_data(self.trait_(f.db)).name.clone(); 267 let trait_ = f.db.trait_data(self.trait_(f.db));
270 write!(f, "<{} as {}", self.parameters[0].display(f.db), trait_name,)?; 268 write!(f, "<{} as {}", self.parameters[0].display(f.db), trait_.name)?;
271 if self.parameters.len() > 1 { 269 if self.parameters.len() > 1 {
272 write!(f, "<")?; 270 write!(f, "<")?;
273 f.write_joined(&self.parameters[1..], ", ")?; 271 f.write_joined(&self.parameters[1..], ", ")?;
@@ -312,7 +310,7 @@ impl HirDisplay for Ty {
312 Ty::Opaque(_) => write!(f, "impl ")?, 310 Ty::Opaque(_) => write!(f, "impl ")?,
313 _ => unreachable!(), 311 _ => unreachable!(),
314 }; 312 };
315 write_bounds_like_dyn_trait(&predicates, f)?; 313 write_bounds_like_dyn_trait(predicates, f)?;
316 } 314 }
317 Ty::Unknown => write!(f, "{{unknown}}")?, 315 Ty::Unknown => write!(f, "{{unknown}}")?,
318 Ty::Infer(..) => write!(f, "_")?, 316 Ty::Infer(..) => write!(f, "_")?,
@@ -345,7 +343,7 @@ fn write_bounds_like_dyn_trait(
345 // We assume that the self type is $0 (i.e. the 343 // We assume that the self type is $0 (i.e. the
346 // existential) here, which is the only thing that's 344 // existential) here, which is the only thing that's
347 // possible in actual Rust, and hence don't print it 345 // possible in actual Rust, and hence don't print it
348 write!(f, "{}", f.db.trait_data(trait_ref.trait_).name.clone())?; 346 write!(f, "{}", f.db.trait_data(trait_ref.trait_).name)?;
349 if trait_ref.substs.len() > 1 { 347 if trait_ref.substs.len() > 1 {
350 write!(f, "<")?; 348 write!(f, "<")?;
351 f.write_joined(&trait_ref.substs[1..], ", ")?; 349 f.write_joined(&trait_ref.substs[1..], ", ")?;
@@ -362,9 +360,8 @@ fn write_bounds_like_dyn_trait(
362 write!(f, "<")?; 360 write!(f, "<")?;
363 angle_open = true; 361 angle_open = true;
364 } 362 }
365 let name = 363 let type_alias = f.db.type_alias_data(projection_pred.projection_ty.associated_ty);
366 f.db.type_alias_data(projection_pred.projection_ty.associated_ty).name.clone(); 364 write!(f, "{} = ", type_alias.name)?;
367 write!(f, "{} = ", name)?;
368 projection_pred.ty.hir_fmt(f)?; 365 projection_pred.ty.hir_fmt(f)?;
369 } 366 }
370 GenericPredicate::Error => { 367 GenericPredicate::Error => {
@@ -398,7 +395,7 @@ impl TraitRef {
398 } else { 395 } else {
399 write!(f, ": ")?; 396 write!(f, ": ")?;
400 } 397 }
401 write!(f, "{}", f.db.trait_data(self.trait_).name.clone())?; 398 write!(f, "{}", f.db.trait_data(self.trait_).name)?;
402 if self.substs.len() > 1 { 399 if self.substs.len() > 1 {
403 write!(f, "<")?; 400 write!(f, "<")?;
404 f.write_joined(&self.substs[1..], ", ")?; 401 f.write_joined(&self.substs[1..], ", ")?;