2894: Omit default parameters for references r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
bors[bot] 2020-01-22 15:00:21 +00:00 committed by GitHub
commit 9b1465af32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -9,7 +9,7 @@ pub struct HirFormatter<'a, 'b, DB> {
fmt: &'a mut fmt::Formatter<'b>,
buf: String,
curr_size: usize,
max_size: Option<usize>,
pub(crate) max_size: Option<usize>,
omit_verbose_types: bool,
}

View File

@ -855,7 +855,12 @@ fn hir_fmt(&self, f: &mut HirFormatter<impl HirDatabase>) -> fmt::Result {
}
TypeCtor::Ref(m) => {
let t = self.parameters.as_single();
write!(f, "&{}{}", m.as_keyword_for_ref(), t.display(f.db))?;
let ty_display = if f.omit_verbose_types() {
t.display_truncated(f.db, f.max_size)
} else {
t.display(f.db)
};
write!(f, "&{}{}", m.as_keyword_for_ref(), ty_display)?;
}
TypeCtor::Never => write!(f, "!")?,
TypeCtor::Tuple { .. } => {

View File

@ -245,6 +245,7 @@ struct Test<K, T = u8> {
fn main() {
let zz = Test { t: 23, k: 33 };
let zz_ref = &zz;
}"#,
);
@ -255,6 +256,11 @@ fn main() {
kind: TypeHint,
label: "Test<i32>",
},
InlayHint {
range: [105; 111),
kind: TypeHint,
label: "&Test<i32>",
},
]
"###
);
@ -374,6 +380,7 @@ fn main() {
let multiply = |a, b, c, d| a * b * c * d;
let _: i32 = multiply(1, 2, 3, 4);
let multiply_ref = &multiply;
let return_42 = || 42;
}"#,
@ -417,7 +424,12 @@ fn main() {
label: "i32",
},
InlayHint {
range: [201; 210),
range: [200; 212),
kind: TypeHint,
label: "&|…| -> i32",
},
InlayHint {
range: [235; 244),
kind: TypeHint,
label: "|| -> i32",
},