Skip to content

Commit 1a0988b

Browse files
bors[bot]bnjjjlnicola
authored
Merge #4316 #4351
4316: do not truncate display for hover r=matklad a=bnjjj close #4311 4351: Fix Windows server path r=matklad a=lnicola CC @Coder-256. Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
3 parents 5b697d5 + 1ec953f + e0b6385 commit 1a0988b

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

crates/ra_ide/src/hover.rs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, def: Definition) -> Option<Strin
143143
ModuleDef::TypeAlias(it) => from_def_source(db, it, mod_path),
144144
ModuleDef::BuiltinType(it) => Some(it.to_string()),
145145
},
146-
Definition::Local(it) => Some(rust_code_markup(&it.ty(db).display_truncated(db, None))),
146+
Definition::Local(it) => Some(rust_code_markup(&it.ty(db).display(db))),
147147
Definition::TypeParam(_) | Definition::SelfType(_) => {
148148
// FIXME: Hover for generic param
149149
None
@@ -208,7 +208,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
208208
}
209209
}?;
210210

211-
res.extend(Some(rust_code_markup(&ty.display_truncated(db, None))));
211+
res.extend(Some(rust_code_markup(&ty.display(db))));
212212
let range = sema.original_range(&node).range;
213213
Some(RangeInfo::new(range, res))
214214
}
@@ -279,6 +279,47 @@ mod tests {
279279
assert_eq!(trim_markup_opt(hover.info.first()), Some("u32"));
280280
}
281281

282+
#[test]
283+
fn hover_shows_long_type_of_an_expression() {
284+
check_hover_result(
285+
r#"
286+
//- /main.rs
287+
struct Scan<A, B, C> {
288+
a: A,
289+
b: B,
290+
c: C,
291+
}
292+
293+
struct FakeIter<I> {
294+
inner: I,
295+
}
296+
297+
struct OtherStruct<T> {
298+
i: T,
299+
}
300+
301+
enum FakeOption<T> {
302+
Some(T),
303+
None,
304+
}
305+
306+
fn scan<A, B, C>(a: A, b: B, c: C) -> FakeIter<Scan<OtherStruct<A>, B, C>> {
307+
FakeIter { inner: Scan { a, b, c } }
308+
}
309+
310+
fn main() {
311+
let num: i32 = 55;
312+
let closure = |memo: &mut u32, value: &u32, _another: &mut u32| -> FakeOption<u32> {
313+
FakeOption::Some(*memo + value)
314+
};
315+
let number = 5u32;
316+
let mut iter<|> = scan(OtherStruct { i: num }, closure, number);
317+
}
318+
"#,
319+
&["FakeIter<Scan<OtherStruct<OtherStruct<i32>>, |&mut u32, &u32, &mut u32| -> FakeOption<u32>, u32>>"],
320+
);
321+
}
322+
282323
#[test]
283324
fn hover_shows_fn_signature() {
284325
// Single file with result
@@ -405,7 +446,7 @@ mod tests {
405446
}
406447

407448
#[test]
408-
fn hover_omits_default_generic_types() {
449+
fn hover_default_generic_types() {
409450
check_hover_result(
410451
r#"
411452
//- /main.rs
@@ -417,7 +458,7 @@ struct Test<K, T = u8> {
417458
fn main() {
418459
let zz<|> = Test { t: 23, k: 33 };
419460
}"#,
420-
&["Test<i32>"],
461+
&["Test<i32, u8>"],
421462
);
422463
}
423464

docs/user/readme.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The server binary is stored in:
6161

6262
* Linux: `~/.config/Code/User/globalStorage/matklad.rust-analyzer`
6363
* macOS: `~/Library/Application Support/Code/User/globalStorage/matklad.rust-analyzer`
64-
* Windows: `%APPDATA%\Code\User\globalStorage`
64+
* Windows: `%APPDATA%\Code\User\globalStorage\matklad.rust-analyzer`
6565

6666
Note that we only support the latest version of VS Code.
6767

0 commit comments

Comments
 (0)