diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-05 19:27:44 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-05 19:27:44 +0100 |
commit | bf2d91b26ae5e047abb4f0e7975bb6d0163bab21 (patch) | |
tree | a39fbb5d654a5626ce66c11446776c739b462d6b /crates/ra_hir_ty/src/display.rs | |
parent | 3431312418ea255e98d3f94536344d396b9b07d6 (diff) | |
parent | 7d62280a713de08b361a08df077ff361b2e1fa99 (diff) |
Merge #3858
3858: Hide unit function return types r=flodiebold a=lnicola
r? @flodiebold
This might be a bit heavy-handed (e.g. `|| -> ()` to `||`), what do you think?
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/display.rs')
-rw-r--r-- | crates/ra_hir_ty/src/display.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 13ecd537a..1665e25e4 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs | |||
@@ -155,7 +155,11 @@ impl HirDisplay for ApplicationTy { | |||
155 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); | 155 | let sig = FnSig::from_fn_ptr_substs(&self.parameters); |
156 | write!(f, "fn(")?; | 156 | write!(f, "fn(")?; |
157 | f.write_joined(sig.params(), ", ")?; | 157 | f.write_joined(sig.params(), ", ")?; |
158 | write!(f, ") -> {}", sig.ret().display(f.db))?; | 158 | write!(f, ")")?; |
159 | let ret = sig.ret(); | ||
160 | if *ret != Ty::unit() { | ||
161 | write!(f, " -> {}", ret.display(f.db))?; | ||
162 | } | ||
159 | } | 163 | } |
160 | TypeCtor::FnDef(def) => { | 164 | TypeCtor::FnDef(def) => { |
161 | let sig = f.db.callable_item_signature(def).subst(&self.parameters); | 165 | let sig = f.db.callable_item_signature(def).subst(&self.parameters); |
@@ -180,7 +184,11 @@ impl HirDisplay for ApplicationTy { | |||
180 | } | 184 | } |
181 | write!(f, "(")?; | 185 | write!(f, "(")?; |
182 | f.write_joined(sig.params(), ", ")?; | 186 | f.write_joined(sig.params(), ", ")?; |
183 | write!(f, ") -> {}", sig.ret().display(f.db))?; | 187 | write!(f, ")")?; |
188 | let ret = sig.ret(); | ||
189 | if *ret != Ty::unit() { | ||
190 | write!(f, " -> {}", ret.display(f.db))?; | ||
191 | } | ||
184 | } | 192 | } |
185 | TypeCtor::Adt(def_id) => { | 193 | TypeCtor::Adt(def_id) => { |
186 | let name = match def_id { | 194 | let name = match def_id { |
@@ -242,16 +250,16 @@ impl HirDisplay for ApplicationTy { | |||
242 | let sig = self.parameters[0] | 250 | let sig = self.parameters[0] |
243 | .callable_sig(f.db) | 251 | .callable_sig(f.db) |
244 | .expect("first closure parameter should contain signature"); | 252 | .expect("first closure parameter should contain signature"); |
245 | let return_type_hint = sig.ret().display(f.db); | ||
246 | if sig.params().is_empty() { | 253 | if sig.params().is_empty() { |
247 | write!(f, "|| -> {}", return_type_hint)?; | 254 | write!(f, "||")?; |
248 | } else if f.omit_verbose_types() { | 255 | } else if f.omit_verbose_types() { |
249 | write!(f, "|{}| -> {}", TYPE_HINT_TRUNCATION, return_type_hint)?; | 256 | write!(f, "|{}|", TYPE_HINT_TRUNCATION)?; |
250 | } else { | 257 | } else { |
251 | write!(f, "|")?; | 258 | write!(f, "|")?; |
252 | f.write_joined(sig.params(), ", ")?; | 259 | f.write_joined(sig.params(), ", ")?; |
253 | write!(f, "| -> {}", return_type_hint)?; | 260 | write!(f, "|")?; |
254 | }; | 261 | }; |
262 | write!(f, " -> {}", sig.ret().display(f.db))?; | ||
255 | } | 263 | } |
256 | } | 264 | } |
257 | Ok(()) | 265 | Ok(()) |