diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-09 13:16:39 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-09 13:16:39 +0000 |
commit | ef989880fff36f10b7e166647497779bacc1c47f (patch) | |
tree | 3fbf3b76697775ec50c286f9691fc736d7fb4886 /crates/ide/src/hover.rs | |
parent | 7bda4c722bc5bb81b0f5b0f4c9390e3c7b602d0f (diff) | |
parent | da3b5e35a69fd71ba061169e2fe719e36dbc3ef4 (diff) |
Merge #6771
6771: Properly attach inner attributes in Attrs::new r=matklad a=Veykril
Properly attach inner and outer attributes to the things they actually belong to in the HIR. ~~I can add some tests for this if wanted once I know where to put them/how to test for this.~~ Put some tests into `hover.rs`.
So the following snippet
```rust
mod foo {
//! Hello
}
```
now shows `Hello` on hover 🎉
Fixes #2148
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r-- | crates/ide/src/hover.rs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 1b6ff6d21..cf04c3de0 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -3357,4 +3357,66 @@ impl Foo { | |||
3357 | "#]], | 3357 | "#]], |
3358 | ); | 3358 | ); |
3359 | } | 3359 | } |
3360 | |||
3361 | #[test] | ||
3362 | fn hover_doc_outer_inner() { | ||
3363 | check( | ||
3364 | r#" | ||
3365 | /// Be quick; | ||
3366 | mod Foo<|> { | ||
3367 | //! time is mana | ||
3368 | |||
3369 | /// This comment belongs to the function | ||
3370 | fn foo() {} | ||
3371 | } | ||
3372 | "#, | ||
3373 | expect![[r#" | ||
3374 | *Foo* | ||
3375 | |||
3376 | ```rust | ||
3377 | test | ||
3378 | ``` | ||
3379 | |||
3380 | ```rust | ||
3381 | mod Foo | ||
3382 | ``` | ||
3383 | |||
3384 | --- | ||
3385 | |||
3386 | Be quick; | ||
3387 | time is mana | ||
3388 | "#]], | ||
3389 | ); | ||
3390 | } | ||
3391 | |||
3392 | #[test] | ||
3393 | fn hover_doc_outer_inner_attribue() { | ||
3394 | check( | ||
3395 | r#" | ||
3396 | #[doc = "Be quick;"] | ||
3397 | mod Foo<|> { | ||
3398 | #![doc = "time is mana"] | ||
3399 | |||
3400 | #[doc = "This comment belongs to the function"] | ||
3401 | fn foo() {} | ||
3402 | } | ||
3403 | "#, | ||
3404 | expect![[r#" | ||
3405 | *Foo* | ||
3406 | |||
3407 | ```rust | ||
3408 | test | ||
3409 | ``` | ||
3410 | |||
3411 | ```rust | ||
3412 | mod Foo | ||
3413 | ``` | ||
3414 | |||
3415 | --- | ||
3416 | |||
3417 | Be quick; | ||
3418 | time is mana | ||
3419 | "#]], | ||
3420 | ); | ||
3421 | } | ||
3360 | } | 3422 | } |