diff options
author | Kirill Bulatov <[email protected]> | 2020-01-22 14:44:05 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-01-22 14:55:09 +0000 |
commit | 4029e4410245eeb2e1f58adefad1d4cc24898579 (patch) | |
tree | 96de0273a72ddf6a434a82e9db72df942cf1c51c | |
parent | a5407ddc05826b208ed8a0026b2ae566bf0a8b70 (diff) |
Omit default parameters for reference types
-rw-r--r-- | crates/ra_hir_ty/src/display.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 14 |
3 files changed, 20 insertions, 3 deletions
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 37def7c03..d1ff85f0f 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs | |||
@@ -9,7 +9,7 @@ pub struct HirFormatter<'a, 'b, DB> { | |||
9 | fmt: &'a mut fmt::Formatter<'b>, | 9 | fmt: &'a mut fmt::Formatter<'b>, |
10 | buf: String, | 10 | buf: String, |
11 | curr_size: usize, | 11 | curr_size: usize, |
12 | max_size: Option<usize>, | 12 | pub(crate) max_size: Option<usize>, |
13 | omit_verbose_types: bool, | 13 | omit_verbose_types: bool, |
14 | } | 14 | } |
15 | 15 | ||
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index d63f862dc..908e4862d 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -855,7 +855,12 @@ impl HirDisplay for ApplicationTy { | |||
855 | } | 855 | } |
856 | TypeCtor::Ref(m) => { | 856 | TypeCtor::Ref(m) => { |
857 | let t = self.parameters.as_single(); | 857 | let t = self.parameters.as_single(); |
858 | write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?; | 858 | let ty_display = if f.omit_verbose_types() { |
859 | t.display_truncated(f.db, f.max_size) | ||
860 | } else { | ||
861 | t.display(f.db) | ||
862 | }; | ||
863 | write!(f, "&{}{}", m.as_keyword_for_ref(), ty_display)?; | ||
859 | } | 864 | } |
860 | TypeCtor::Never => write!(f, "!")?, | 865 | TypeCtor::Never => write!(f, "!")?, |
861 | TypeCtor::Tuple { .. } => { | 866 | TypeCtor::Tuple { .. } => { |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 236557541..393ca9447 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -245,6 +245,7 @@ struct Test<K, T = u8> { | |||
245 | 245 | ||
246 | fn main() { | 246 | fn main() { |
247 | let zz = Test { t: 23, k: 33 }; | 247 | let zz = Test { t: 23, k: 33 }; |
248 | let zz_ref = &zz; | ||
248 | }"#, | 249 | }"#, |
249 | ); | 250 | ); |
250 | 251 | ||
@@ -255,6 +256,11 @@ fn main() { | |||
255 | kind: TypeHint, | 256 | kind: TypeHint, |
256 | label: "Test<i32>", | 257 | label: "Test<i32>", |
257 | }, | 258 | }, |
259 | InlayHint { | ||
260 | range: [105; 111), | ||
261 | kind: TypeHint, | ||
262 | label: "&Test<i32>", | ||
263 | }, | ||
258 | ] | 264 | ] |
259 | "### | 265 | "### |
260 | ); | 266 | ); |
@@ -374,6 +380,7 @@ fn main() { | |||
374 | 380 | ||
375 | let multiply = |a, b, c, d| a * b * c * d; | 381 | let multiply = |a, b, c, d| a * b * c * d; |
376 | let _: i32 = multiply(1, 2, 3, 4); | 382 | let _: i32 = multiply(1, 2, 3, 4); |
383 | let multiply_ref = &multiply; | ||
377 | 384 | ||
378 | let return_42 = || 42; | 385 | let return_42 = || 42; |
379 | }"#, | 386 | }"#, |
@@ -417,7 +424,12 @@ fn main() { | |||
417 | label: "i32", | 424 | label: "i32", |
418 | }, | 425 | }, |
419 | InlayHint { | 426 | InlayHint { |
420 | range: [201; 210), | 427 | range: [200; 212), |
428 | kind: TypeHint, | ||
429 | label: "&|…| -> i32", | ||
430 | }, | ||
431 | InlayHint { | ||
432 | range: [235; 244), | ||
421 | kind: TypeHint, | 433 | kind: TypeHint, |
422 | label: "|| -> i32", | 434 | label: "|| -> i32", |
423 | }, | 435 | }, |