aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/hover.rs19
-rw-r--r--crates/ra_ide/src/inlay_hints.rs26
2 files changed, 44 insertions, 1 deletions
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 51e320128..a227bf546 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -250,7 +250,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
250 } else { 250 } else {
251 return None; 251 return None;
252 }; 252 };
253 Some(ty.display(db).to_string()) 253 Some(ty.display_truncated(db, None).to_string())
254} 254}
255 255
256#[cfg(test)] 256#[cfg(test)]
@@ -425,6 +425,23 @@ mod tests {
425 } 425 }
426 426
427 #[test] 427 #[test]
428 fn hover_omits_default_generic_types() {
429 check_hover_result(
430 r#"
431//- /main.rs
432struct Test<K, T = u8> {
433 k: K,
434 t: T,
435}
436
437fn main() {
438 let zz<|> = Test { t: 23, k: 33 };
439}"#,
440 &["Test<i32>"],
441 );
442 }
443
444 #[test]
428 fn hover_some() { 445 fn hover_some() {
429 let (analysis, position) = single_file_with_position( 446 let (analysis, position) = single_file_with_position(
430 " 447 "
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 3730121af..3154df457 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -160,6 +160,32 @@ mod tests {
160 use crate::mock_analysis::single_file; 160 use crate::mock_analysis::single_file;
161 161
162 #[test] 162 #[test]
163 fn default_generic_types_should_not_be_displayed() {
164 let (analysis, file_id) = single_file(
165 r#"
166struct Test<K, T = u8> {
167 k: K,
168 t: T,
169}
170
171fn main() {
172 let zz = Test { t: 23, k: 33 };
173}"#,
174 );
175
176 assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
177 [
178 InlayHint {
179 range: [69; 71),
180 kind: TypeHint,
181 label: "Test<i32>",
182 },
183 ]
184 "###
185 );
186 }
187
188 #[test]
163 fn let_statement() { 189 fn let_statement() {
164 let (analysis, file_id) = single_file( 190 let (analysis, file_id) = single_file(
165 r#" 191 r#"