diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 3ad913e55..7ca9e6b8a 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -906,7 +906,38 @@ impl HirDisplay for ApplicationTy { | |||
906 | write!(f, "{}", name)?; | 906 | write!(f, "{}", name)?; |
907 | if self.parameters.len() > 0 { | 907 | if self.parameters.len() > 0 { |
908 | write!(f, "<")?; | 908 | write!(f, "<")?; |
909 | f.write_joined(&*self.parameters.0, ", ")?; | 909 | |
910 | let mut non_default_parameters = Vec::with_capacity(self.parameters.len()); | ||
911 | let parameters_to_write = if f.should_display_default_types() { | ||
912 | self.parameters.0.as_ref() | ||
913 | } else { | ||
914 | match self | ||
915 | .ctor | ||
916 | .as_generic_def() | ||
917 | .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) | ||
918 | .filter(|defaults| !defaults.is_empty()) | ||
919 | { | ||
920 | Option::None => self.parameters.0.as_ref(), | ||
921 | Option::Some(default_parameters) => { | ||
922 | for (i, parameter) in self.parameters.into_iter().enumerate() { | ||
923 | match (parameter, default_parameters.get(i)) { | ||
924 | (&Ty::Unknown, _) | (_, None) => { | ||
925 | non_default_parameters.push(parameter.clone()) | ||
926 | } | ||
927 | (_, Some(default_parameter)) | ||
928 | if parameter != default_parameter => | ||
929 | { | ||
930 | non_default_parameters.push(parameter.clone()) | ||
931 | } | ||
932 | _ => (), | ||
933 | } | ||
934 | } | ||
935 | &non_default_parameters | ||
936 | } | ||
937 | } | ||
938 | }; | ||
939 | |||
940 | f.write_joined(parameters_to_write, ", ")?; | ||
910 | write!(f, ">")?; | 941 | write!(f, ">")?; |
911 | } | 942 | } |
912 | } | 943 | } |