diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-04 12:57:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-04 12:57:28 +0000 |
commit | 5771cad4517005afe134d0b9c93571c177f14db4 (patch) | |
tree | 4cd712c52d5b423e2690fc0e003ac9ff7c86ed9e /crates/ide/src | |
parent | d53ff4f67b3c003ca4ce3d983af44c8119c0c9cd (diff) | |
parent | 47900dd3bc1cca74e06a3ac1f587e92e352fbd42 (diff) |
Merge #7149
7149: Implement hovering for TypeParams r=matklad a=Veykril
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/hover.rs | 52 |
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#" | ||
3266 | struct Foo<T>(T); | ||
3267 | trait Copy {} | ||
3268 | trait Clone {} | ||
3269 | trait Sized {} | ||
3270 | impl<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#" | ||
3282 | struct Foo<T>(T); | ||
3283 | impl<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#" | ||
3296 | struct Foo<T>(T); | ||
3297 | impl<T: 'static> Foo<T<|>> {} | ||
3298 | "#, | ||
3299 | expect![[r#" | ||
3300 | *T* | ||
3301 | |||
3302 | ```rust | ||
3303 | T: {error} | ||
3304 | ``` | ||
3305 | "#]], | ||
3306 | ); | ||
3307 | } | ||
3260 | } | 3308 | } |