From 7b35da04bf56a5461321a6dca515dcd29f44b57f Mon Sep 17 00:00:00 2001 From: Matt Hooper Date: Tue, 24 Mar 2020 23:50:25 +0100 Subject: Improvements based on code review feedback --- crates/ra_ide/src/inlay_hints.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 07aab45ee..f4f0751c0 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -76,7 +76,6 @@ fn get_chaining_hints( } let ty = sema.type_of_expr(&expr)?; - let label = ty.display_truncated(sema.db, options.max_length).to_string(); if ty.is_unknown() { return None; } @@ -96,6 +95,7 @@ fn get_chaining_hints( let next = tokens.next()?.kind(); let next_next = tokens.next()?.kind(); if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT { + let label = ty.display_truncated(sema.db, options.max_length).to_string(); acc.push(InlayHint { range: expr.syntax().text_range(), kind: InlayKind::ChainingHint, @@ -1105,7 +1105,7 @@ fn main() { r#" struct A(B); impl A { fn into_b(self) -> B { self.0 } } - struct B(C) + struct B(C); impl B { fn into_c(self) -> C { self.0 } } struct C; @@ -1118,12 +1118,12 @@ fn main() { assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" [ InlayHint { - range: [231; 268), + range: [232; 269), kind: ChainingHint, label: "B", }, InlayHint { - range: [231; 238), + range: [232; 239), kind: ChainingHint, label: "A", }, @@ -1136,7 +1136,7 @@ fn main() { r#" struct A(B); impl A { fn into_b(self) -> B { self.0 } } - struct B(C) + struct B(C); impl B { fn into_c(self) -> C { self.0 } } struct C; -- cgit v1.2.3