Skip to content

Commit ad19341

Browse files
Merge pull request rust-lang#20379 from skewb1k/fix/consistent-hover-doc-breaks
fix(hover): unify horizontal rule formatting to `---`
2 parents dfa11e7 + 1d817dc commit ad19341

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

src/tools/rust-analyzer/crates/ide/src/hover/render.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ pub(super) fn try_for_lint(attr: &ast::Attr, token: &SyntaxToken) -> Option<Hove
361361
let lint =
362362
lints.binary_search_by_key(&needle, |lint| lint.label).ok().map(|idx| &lints[idx])?;
363363
Some(HoverResult {
364-
markup: Markup::from(format!("```\n{}\n```\n___\n\n{}", lint.label, lint.description)),
364+
markup: Markup::from(format!("```\n{}\n```\n---\n\n{}", lint.label, lint.description)),
365365
..Default::default()
366366
})
367367
}
@@ -911,7 +911,7 @@ pub(super) fn literal(
911911
};
912912
let ty = ty.display(sema.db, display_target);
913913

914-
let mut s = format!("```rust\n{ty}\n```\n___\n\n");
914+
let mut s = format!("```rust\n{ty}\n```\n---\n\n");
915915
match value {
916916
Ok(value) => {
917917
let backtick_len = value.chars().filter(|c| *c == '`').count();
@@ -1025,7 +1025,7 @@ fn type_info(
10251025
if let Some(extra) =
10261026
render_notable_trait(db, &notable_traits(db, &original), edition, display_target)
10271027
{
1028-
desc.push_str("\n___\n");
1028+
desc.push_str("\n---\n");
10291029
desc.push_str(&extra);
10301030
};
10311031
desc.into()
@@ -1093,7 +1093,7 @@ fn closure_ty(
10931093
|_| None,
10941094
|_| None,
10951095
) {
1096-
format_to!(markup, "\n___\n{layout}");
1096+
format_to!(markup, "\n---\n{layout}");
10971097
}
10981098
format_to!(markup, "{adjusted}\n\n## Captures\n{}", captures_rendered,);
10991099

src/tools/rust-analyzer/crates/ide/src/hover/tests.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn main() {
360360
```rust
361361
impl Fn(i32) -> i32
362362
```
363-
___
363+
---
364364
size = 8, align = 8, niches = 1
365365
366366
## Captures
@@ -383,7 +383,7 @@ fn main() {
383383
```rust
384384
impl Fn(i32) -> i32
385385
```
386-
___
386+
---
387387
size = 0, align = 1
388388
389389
## Captures
@@ -417,7 +417,7 @@ fn main() {
417417
```rust
418418
impl FnOnce()
419419
```
420-
___
420+
---
421421
size = 16 (0x10), align = 8, niches = 1
422422
423423
## Captures
@@ -446,7 +446,7 @@ fn main() {
446446
```rust
447447
impl FnMut()
448448
```
449-
___
449+
---
450450
size = 8, align = 8, niches = 1
451451
452452
## Captures
@@ -471,7 +471,7 @@ fn main() {
471471
```rust
472472
impl FnOnce() -> S2
473473
```
474-
___
474+
---
475475
size = 8, align = 8, niches = 1
476476
Coerced to: &impl FnOnce() -> S2
477477
@@ -6832,7 +6832,7 @@ fn hover_lint() {
68326832
```
68336833
arithmetic_overflow
68346834
```
6835-
___
6835+
---
68366836
68376837
arithmetic operation overflows
68386838
"#]],
@@ -6844,7 +6844,7 @@ fn hover_lint() {
68446844
```
68456845
arithmetic_overflow
68466846
```
6847-
___
6847+
---
68486848
68496849
arithmetic operation overflows
68506850
"#]],
@@ -6860,7 +6860,7 @@ fn hover_clippy_lint() {
68606860
```
68616861
clippy::almost_swapped
68626862
```
6863-
___
6863+
---
68646864
68656865
Checks for `foo = bar; bar = foo` sequences.
68666866
"#]],
@@ -6872,7 +6872,7 @@ fn hover_clippy_lint() {
68726872
```
68736873
clippy::almost_swapped
68746874
```
6875-
___
6875+
---
68766876
68776877
Checks for `foo = bar; bar = foo` sequences.
68786878
"#]],
@@ -8570,7 +8570,7 @@ fn main() {
85708570
```rust
85718571
&'static str
85728572
```
8573-
___
8573+
---
85748574
85758575
value of literal: ` 🦀🦀\A `
85768576
"#]],
@@ -8586,7 +8586,7 @@ fn main() {
85868586
```rust
85878587
&'static str
85888588
```
8589-
___
8589+
---
85908590
85918591
value of literal: ` 🦀\u{1f980}\\\x41 `
85928592
"#]],
@@ -8608,7 +8608,7 @@ fsdghs";
86088608
```rust
86098609
&'static str
86108610
```
8611-
___
8611+
---
86128612
86138613
value of literal (truncated up to newline): ` 🦀\u{1f980}\\\x41 `
86148614
"#]],
@@ -8628,7 +8628,7 @@ fn main() {
86288628
```rust
86298629
&'static {unknown}
86308630
```
8631-
___
8631+
---
86328632
86338633
value of literal: ` 🦀🦀\A `
86348634
"#]],
@@ -8647,7 +8647,7 @@ fn main() {
86478647
```rust
86488648
&'static str
86498649
```
8650-
___
8650+
---
86518651
86528652
value of literal: ```` `[^`]*` ````
86538653
"#]],
@@ -8662,7 +8662,7 @@ fn main() {
86628662
```rust
86638663
&'static str
86648664
```
8665-
___
8665+
---
86668666
86678667
value of literal: `` ` ``
86688668
"#]],
@@ -8677,7 +8677,7 @@ fn main() {
86778677
```rust
86788678
&'static str
86798679
```
8680-
___
8680+
---
86818681
86828682
value of literal: ` `
86838683
"#]],
@@ -8693,7 +8693,7 @@ fn main() {
86938693
```rust
86948694
&'static str
86958695
```
8696-
___
8696+
---
86978697
86988698
value of literal: ` Hello World `
86998699
"#]],
@@ -8713,7 +8713,7 @@ fn main() {
87138713
```rust
87148714
&'static [u8; 5]
87158715
```
8716-
___
8716+
---
87178717
87188718
value of literal: ` [240, 159, 166, 128, 92] `
87198719
"#]],
@@ -8729,7 +8729,7 @@ fn main() {
87298729
```rust
87308730
&'static [u8; 18]
87318731
```
8732-
___
8732+
---
87338733
87348734
value of literal: ` [92, 120, 70, 48, 92, 120, 57, 70, 92, 120, 65, 54, 92, 120, 56, 48, 92, 92] `
87358735
"#]],
@@ -8749,7 +8749,7 @@ fn main() {
87498749
```rust
87508750
u8
87518751
```
8752-
___
8752+
---
87538753
87548754
value of literal: ` 0xF0 `
87558755
"#]],
@@ -8765,7 +8765,7 @@ fn main() {
87658765
```rust
87668766
u8
87678767
```
8768-
___
8768+
---
87698769
87708770
value of literal: ` 0x5C `
87718771
"#]],
@@ -8785,7 +8785,7 @@ fn main() {
87858785
```rust
87868786
char
87878787
```
8788-
___
8788+
---
87898789
87908790
value of literal: ` A `
87918791
"#]],
@@ -8801,7 +8801,7 @@ fn main() {
88018801
```rust
88028802
char
88038803
```
8804-
___
8804+
---
88058805
88068806
value of literal: ` \ `
88078807
"#]],
@@ -8817,7 +8817,7 @@ fn main() {
88178817
```rust
88188818
char
88198819
```
8820-
___
8820+
---
88218821
88228822
value of literal: ` 🦀 `
88238823
"#]],
@@ -8837,7 +8837,7 @@ fn main() {
88378837
```rust
88388838
f64
88398839
```
8840-
___
8840+
---
88418841
88428842
value of literal: ` 1 (bits: 0x3FF0000000000000) `
88438843
"#]],
@@ -8853,7 +8853,7 @@ fn main() {
88538853
```rust
88548854
f16
88558855
```
8856-
___
8856+
---
88578857
88588858
value of literal: ` 1 (bits: 0x3C00) `
88598859
"#]],
@@ -8869,7 +8869,7 @@ fn main() {
88698869
```rust
88708870
f32
88718871
```
8872-
___
8872+
---
88738873
88748874
value of literal: ` 1 (bits: 0x3F800000) `
88758875
"#]],
@@ -8885,7 +8885,7 @@ fn main() {
88858885
```rust
88868886
f128
88878887
```
8888-
___
8888+
---
88898889
88908890
value of literal: ` 1 (bits: 0x3FFF0000000000000000000000000000) `
88918891
"#]],
@@ -8901,7 +8901,7 @@ fn main() {
89018901
```rust
89028902
f64
89038903
```
8904-
___
8904+
---
89058905
89068906
value of literal: ` 134000000000000 (bits: 0x42DE77D399980000) `
89078907
"#]],
@@ -8917,7 +8917,7 @@ fn main() {
89178917
```rust
89188918
f64
89198919
```
8920-
___
8920+
---
89218921
89228922
value of literal: ` 1523527134274733600000000 (bits: 0x44F429E9249F629B) `
89238923
"#]],
@@ -8933,7 +8933,7 @@ fn main() {
89338933
```rust
89348934
f64
89358935
```
8936-
___
8936+
---
89378937
89388938
invalid literal: invalid float literal
89398939
"#]],
@@ -8953,7 +8953,7 @@ fn main() {
89538953
```rust
89548954
i32
89558955
```
8956-
___
8956+
---
89578957
89588958
value of literal: ` 34325236457856836345234 (0x744C659178614489D92|0b111010001001100011001011001000101111000011000010100010010001001110110010010) `
89598959
"#]],
@@ -8969,7 +8969,7 @@ fn main() {
89698969
```rust
89708970
i32
89718971
```
8972-
___
8972+
---
89738973
89748974
value of literal: ` 13412342421 (0x31F701A95|0b1100011111011100000001101010010101) `
89758975
"#]],
@@ -8985,7 +8985,7 @@ fn main() {
89858985
```rust
89868986
i32
89878987
```
8988-
___
8988+
---
89898989
89908990
value of literal: ` 306328611 (0x12423423|0b10010010000100011010000100011) `
89918991
"#]],
@@ -9001,7 +9001,7 @@ fn main() {
90019001
```rust
90029002
i32
90039003
```
9004-
___
9004+
---
90059005
90069006
value of literal: ` 255 (0xFF|0b11111111) `
90079007
"#]],
@@ -9017,7 +9017,7 @@ fn main() {
90179017
```rust
90189018
i32
90199019
```
9020-
___
9020+
---
90219021
90229022
value of literal: ` 5349 (0x14E5|0b1010011100101) `
90239023
"#]],
@@ -9033,7 +9033,7 @@ fn main() {
90339033
```rust
90349034
i32
90359035
```
9036-
___
9036+
---
90379037
90389038
invalid literal: number too large to fit in target type
90399039
"#]],
@@ -9189,7 +9189,7 @@ fn main() {
91899189
```rust
91909190
S
91919191
```
9192-
___
9192+
---
91939193
Implements notable traits: `Future<Output = u32>`, `Iterator<Item = S>`, `Notable`"#]],
91949194
);
91959195
}

0 commit comments

Comments
 (0)