Skip to content

Commit 9b1465a

Browse files
Merge #2894
2894: Omit default parameters for references r=matklad a=SomeoneToIgnore Co-authored-by: Kirill Bulatov <[email protected]>
2 parents a5407dd + 4029e44 commit 9b1465a

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

crates/ra_hir_ty/src/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct HirFormatter<'a, 'b, DB> {
99
fmt: &'a mut fmt::Formatter<'b>,
1010
buf: String,
1111
curr_size: usize,
12-
max_size: Option<usize>,
12+
pub(crate) max_size: Option<usize>,
1313
omit_verbose_types: bool,
1414
}
1515

crates/ra_hir_ty/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,12 @@ impl HirDisplay for ApplicationTy {
855855
}
856856
TypeCtor::Ref(m) => {
857857
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)?;
859864
}
860865
TypeCtor::Never => write!(f, "!")?,
861866
TypeCtor::Tuple { .. } => {

crates/ra_ide/src/inlay_hints.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ struct Test<K, T = u8> {
245245
246246
fn main() {
247247
let zz = Test { t: 23, k: 33 };
248+
let zz_ref = &zz;
248249
}"#,
249250
);
250251

@@ -255,6 +256,11 @@ fn main() {
255256
kind: TypeHint,
256257
label: "Test<i32>",
257258
},
259+
InlayHint {
260+
range: [105; 111),
261+
kind: TypeHint,
262+
label: "&Test<i32>",
263+
},
258264
]
259265
"###
260266
);
@@ -374,6 +380,7 @@ fn main() {
374380
375381
let multiply = |a, b, c, d| a * b * c * d;
376382
let _: i32 = multiply(1, 2, 3, 4);
383+
let multiply_ref = &multiply;
377384
378385
let return_42 = || 42;
379386
}"#,
@@ -417,7 +424,12 @@ fn main() {
417424
label: "i32",
418425
},
419426
InlayHint {
420-
range: [201; 210),
427+
range: [200; 212),
428+
kind: TypeHint,
429+
label: "&|…| -> i32",
430+
},
431+
InlayHint {
432+
range: [235; 244),
421433
kind: TypeHint,
422434
label: "|| -> i32",
423435
},

0 commit comments

Comments
 (0)