aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-04 12:57:28 +0000
committerGitHub <[email protected]>2021-01-04 12:57:28 +0000
commit5771cad4517005afe134d0b9c93571c177f14db4 (patch)
tree4cd712c52d5b423e2690fc0e003ac9ff7c86ed9e /crates/ide
parentd53ff4f67b3c003ca4ce3d983af44c8119c0c9cd (diff)
parent47900dd3bc1cca74e06a3ac1f587e92e352fbd42 (diff)
Merge #7149
7149: Implement hovering for TypeParams r=matklad a=Veykril Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/hover.rs52
1 files changed, 50 insertions, 2 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 2737c900f..61439ae53 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -370,8 +370,9 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
370 } 370 }
371 Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))), 371 Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))),
372 Definition::LifetimeParam(it) => Some(Markup::fenced_block(&it.name(db))), 372 Definition::LifetimeParam(it) => Some(Markup::fenced_block(&it.name(db))),
373 Definition::TypeParam(_) | Definition::ConstParam(_) => { 373 Definition::TypeParam(type_param) => Some(Markup::fenced_block(&type_param.display(db))),
374 // FIXME: Hover for generic param 374 Definition::ConstParam(_) => {
375 // FIXME: Hover for generic const param
375 None 376 None
376 } 377 }
377 }; 378 };
@@ -3257,4 +3258,51 @@ fn foo() {
3257 "#]], 3258 "#]],
3258 ); 3259 );
3259 } 3260 }
3261
3262 #[test]
3263 fn hover_type_param() {
3264 check(
3265 r#"
3266struct Foo<T>(T);
3267trait Copy {}
3268trait Clone {}
3269trait Sized {}
3270impl<T: Copy + Clone> Foo<T<|>> where T: Sized {}
3271"#,
3272 expect![[r#"
3273 *T*
3274
3275 ```rust
3276 T: Copy + Clone + Sized
3277 ```
3278 "#]],
3279 );
3280 check(
3281 r#"
3282struct Foo<T>(T);
3283impl<T> Foo<T<|>> {}
3284"#,
3285 expect![[r#"
3286 *T*
3287
3288 ```rust
3289 T
3290 ```
3291 "#]],
3292 );
3293 // lifetimes aren't being substituted yet
3294 check(
3295 r#"
3296struct Foo<T>(T);
3297impl<T: 'static> Foo<T<|>> {}
3298"#,
3299 expect![[r#"
3300 *T*
3301
3302 ```rust
3303 T: {error}
3304 ```
3305 "#]],
3306 );
3307 }
3260} 3308}