forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix intra-doc links for
Self
on primitives
- Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This stringifies DefIds, then resolves them a second time. This is really silly and rustdoc should just use DefIds throughout. Fixing this is a larger task than I want to take on right now.
- Loading branch information
Showing
2 changed files
with
98 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// ignore-tidy-linelength | ||
#![deny(broken_intra_doc_links)] | ||
#![feature(lang_items)] | ||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
#[lang = "usize"] | ||
/// [Self::f] | ||
/// [Self::MAX] | ||
// @has intra_link_prim_self/primitive.usize.html | ||
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.f"]' 'Self::f' | ||
// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.usize.html#associatedconstant.MAX"]' 'Self::MAX' | ||
impl usize { | ||
/// Some docs | ||
pub fn f() {} | ||
|
||
/// 10 and 2^32 are basically the same. | ||
pub const MAX: usize = 10; | ||
|
||
// FIXME(#8995) uncomment this when associated types in inherent impls are supported | ||
// @ has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.usize.html#associatedtype.ME"]' 'Self::ME' | ||
// / [Self::ME] | ||
//pub type ME = usize; | ||
} | ||
|
||
#[doc(primitive = "usize")] | ||
/// This has some docs. | ||
mod usize {} | ||
|
||
/// [S::f] | ||
/// [Self::f] | ||
pub struct S; | ||
|
||
impl S { | ||
pub fn f() {} | ||
} |