diff options
author | Lukas Wirth <[email protected]> | 2021-01-01 23:05:51 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-04 11:24:47 +0000 |
commit | 47900dd3bc1cca74e06a3ac1f587e92e352fbd42 (patch) | |
tree | 61bbf0f03da85b42229a103203d5840fbbba3048 /crates/ide | |
parent | 5b86ff3e91838e58397ec39502d85056e46fcfcb (diff) |
Impl hovering for TypeParams
Diffstat (limited to 'crates/ide')
-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 | } |