Commit b203b0d
committed
Auto merge of rust-lang#83068 - mockersf:method-trait-foreign-impl, r=GuillaumeGomez
rustdoc: links from items in a trait impl are inconsistent
Depending on where the struct implementing a trait is coming from, or the current page, the items in a trait impl are not linking to the same thing:
|item| trait page, implementors| trait page, implementations on Foreign Types|struct page, trait implementations|
|-|-|-|-|
|function| link to current impl|link to first impl in the list|link to trait def
|default function | not present |not present |link to trait def
|default function with custom impl|link to current impl|link to trait def |link to trait def
|constant| link to current impl|link to trait def |link to trait def
|associated type| link to current impl|link to trait def |link to trait def
||*missing link to trait def*|*function link wrong + missing link to current impl*|*missing link to current impl*|
<details>
<summary>rust code with those cases</summary>
```rust
pub trait MyTrait {
type Assoc;
const VALUE: u32;
fn trait_function(&self);
fn defaulted(&self) {}
fn defaulted_override(&self) {}
}
impl MyTrait for String {
/// will link to trait def
type Assoc = ();
/// will link to trait def
const VALUE: u32 = 5;
/// will link to first foreign implementor
fn trait_function(&self) {}
/// will link to trait def
fn defaulted_override(&self) {}
}
impl MyTrait for Vec<u8> {
/// will link to trait def
type Assoc = ();
/// will link to trait def
const VALUE: u32 = 5;
/// will link to first foreign implementor
fn trait_function(&self) {}
/// will link to trait def
fn defaulted_override(&self) {}
}
impl MyTrait for MyStruct {
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
type Assoc = bool;
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
const VALUE: u32 = 20;
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
fn trait_function(&self) {}
/// in trait page, will link to current impl
///
/// in struct page, will link to trait def
fn defaulted_override(&self) {}
}
pub struct MyStruct;
```
</details>
In this PR, I fixed all links to target the trait definition, and added an anchor-link to the current implementation appearing on mouse hover.File tree
3 files changed
+134
-19
lines changed- src
- librustdoc/html
- render
- static
- test/rustdoc
3 files changed
+134
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
912 | 912 | | |
913 | 913 | | |
914 | 914 | | |
915 | | - | |
916 | 915 | | |
917 | 916 | | |
918 | | - | |
| 917 | + | |
919 | 918 | | |
920 | 919 | | |
921 | 920 | | |
| |||
925 | 924 | | |
926 | 925 | | |
927 | 926 | | |
928 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
929 | 930 | | |
930 | 931 | | |
931 | 932 | | |
| |||
1452 | 1453 | | |
1453 | 1454 | | |
1454 | 1455 | | |
| 1456 | + | |
1455 | 1457 | | |
1456 | 1458 | | |
1457 | 1459 | | |
1458 | 1460 | | |
1459 | 1461 | | |
1460 | | - | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1461 | 1474 | | |
1462 | | - | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
1463 | 1482 | | |
1464 | 1483 | | |
1465 | 1484 | | |
| |||
1468 | 1487 | | |
1469 | 1488 | | |
1470 | 1489 | | |
| 1490 | + | |
1471 | 1491 | | |
1472 | 1492 | | |
1473 | 1493 | | |
1474 | 1494 | | |
1475 | 1495 | | |
1476 | | - | |
1477 | | - | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
1478 | 1503 | | |
1479 | 1504 | | |
1480 | 1505 | | |
1481 | 1506 | | |
1482 | 1507 | | |
1483 | | - | |
| 1508 | + | |
1484 | 1509 | | |
1485 | 1510 | | |
1486 | 1511 | | |
1487 | 1512 | | |
1488 | | - | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
1489 | 1516 | | |
1490 | 1517 | | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1494 | 1534 | | |
1495 | 1535 | | |
1496 | 1536 | | |
| |||
1499 | 1539 | | |
1500 | 1540 | | |
1501 | 1541 | | |
| 1542 | + | |
1502 | 1543 | | |
1503 | 1544 | | |
1504 | 1545 | | |
1505 | 1546 | | |
1506 | | - | |
1507 | | - | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1508 | 1554 | | |
1509 | 1555 | | |
1510 | 1556 | | |
1511 | 1557 | | |
1512 | 1558 | | |
1513 | | - | |
| 1559 | + | |
1514 | 1560 | | |
1515 | 1561 | | |
1516 | 1562 | | |
1517 | 1563 | | |
1518 | | - | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
1519 | 1567 | | |
1520 | 1568 | | |
1521 | 1569 | | |
| |||
1605 | 1653 | | |
1606 | 1654 | | |
1607 | 1655 | | |
1608 | | - | |
| 1656 | + | |
1609 | 1657 | | |
1610 | 1658 | | |
1611 | 1659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| |||
655 | 656 | | |
656 | 657 | | |
657 | 658 | | |
658 | | - | |
| 659 | + | |
| 660 | + | |
659 | 661 | | |
660 | 662 | | |
661 | 663 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments