Fix broken handling of primitive items
- Fix broken handling of primitive associated items - Remove fragment hack Fixes 83083 - more logging - Update CrateNum hacks The CrateNum has no relation to where in the dependency tree the crate is, only when it's loaded. Explicitly special-case core instead of assuming it will be the first DefId. - Update and add tests - Cache calculation of primitive locations This could possibly be avoided by passing a Cache into collect_intra_doc_links; but that's a much larger change, and doesn't seem valuable other than for this.
This commit is contained in:
parent
f78acaee03
commit
cb7e527692
16 changed files with 144 additions and 165 deletions
|
|
@ -37,13 +37,3 @@ pub fn bar() {}
|
|||
/// Damn enum's variants: [Enum::A#whatever].
|
||||
//~^ ERROR `Enum::A#whatever` contains an anchor
|
||||
pub fn enum_link() {}
|
||||
|
||||
/// Primitives?
|
||||
///
|
||||
/// [u32#hello]
|
||||
//~^ ERROR `u32#hello` contains an anchor
|
||||
pub fn x() {}
|
||||
|
||||
/// [prim@usize#x]
|
||||
//~^ ERROR `prim@usize#x` contains an anchor
|
||||
pub mod usize {}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,3 @@
|
|||
error: `prim@usize#x` contains an anchor, but links to builtin types are already anchored
|
||||
--> $DIR/anchors.rs:47:6
|
||||
|
|
||||
LL | /// [prim@usize#x]
|
||||
| ^^^^^^^^^^--
|
||||
| |
|
||||
| invalid anchor
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/anchors.rs:1:9
|
||||
|
|
||||
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this restriction may be lifted in a future release
|
||||
= note: see https://github.com/rust-lang/rust/issues/83083 for more information
|
||||
|
||||
error: `Foo::f#hola` contains an anchor, but links to fields are already anchored
|
||||
--> $DIR/anchors.rs:25:15
|
||||
|
|
||||
|
|
@ -21,6 +5,12 @@ LL | /// Or maybe [Foo::f#hola].
|
|||
| ^^^^^^-----
|
||||
| |
|
||||
| invalid anchor
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/anchors.rs:1:9
|
||||
|
|
||||
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `hello#people#!` contains multiple anchors
|
||||
--> $DIR/anchors.rs:31:28
|
||||
|
|
@ -38,16 +28,5 @@ LL | /// Damn enum's variants: [Enum::A#whatever].
|
|||
| |
|
||||
| invalid anchor
|
||||
|
||||
error: `u32#hello` contains an anchor, but links to builtin types are already anchored
|
||||
--> $DIR/anchors.rs:43:6
|
||||
|
|
||||
LL | /// [u32#hello]
|
||||
| ^^^------
|
||||
| |
|
||||
| invalid anchor
|
||||
|
|
||||
= note: this restriction may be lifted in a future release
|
||||
= note: see https://github.com/rust-lang/rust/issues/83083 for more information
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
// compile-flags: -Cmetadata=aux
|
||||
|
||||
#![doc(html_root_url = "http://example.com/")]
|
||||
#![feature(lang_items)]
|
||||
#![no_std]
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn foo() {}
|
||||
|
||||
#[panic_handler]
|
||||
fn bar(_: &core::panic::PanicInfo) -> ! { loop {} }
|
||||
|
||||
/// dox
|
||||
#[doc(primitive = "pointer")]
|
||||
|
|
|
|||
|
|
@ -10,3 +10,15 @@ pub struct Something;
|
|||
///
|
||||
/// To link to [Something#Anchor!]
|
||||
pub struct SomeOtherType;
|
||||
|
||||
/// Primitives?
|
||||
///
|
||||
/// [u32#hello]
|
||||
// @has anchors/fn.x.html
|
||||
// @has - '//a/@href' '{{channel}}/std/primitive.u32.html#hello'
|
||||
pub fn x() {}
|
||||
|
||||
/// [prim@usize#x]
|
||||
// @has anchors/usize/index.html
|
||||
// @has - '//a/@href' '{{channel}}/std/primitive.usize.html#x'
|
||||
pub mod usize {}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
#![no_core]
|
||||
#![crate_type="rlib"]
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
/// Some char docs
|
||||
mod char {}
|
||||
|
||||
#[lang = "char"]
|
||||
impl char {
|
||||
pub fn len_utf8(self) -> usize {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#![crate_type = "rlib"]
|
||||
|
||||
// @has prim_methods_external_core/index.html
|
||||
// @has - '//*[@id="main"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char'
|
||||
// @has - '//*[@id="main"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
|
||||
// @has - '//*[@id="main"]//a[@href="../my_core/primitive.char.html"]' 'char'
|
||||
// @has - '//*[@id="main"]//a[@href="../my_core/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
|
||||
|
||||
//! A [`char`] and its [`char::len_utf8`].
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
|
||||
// @has prim_methods_local/index.html
|
||||
// @has - '//*[@id="main"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char'
|
||||
// @has - '//*[@id="main"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8'
|
||||
// @has - '//*[@id="main"]//a[@href="primitive.char.html"]' 'char'
|
||||
// @has - '//*[@id="main"]//a[@href="primitive.char.html#method.len_utf8"]' 'char::len_utf8'
|
||||
|
||||
//! A [`char`] and its [`char::len_utf8`].
|
||||
//! A [prim@`char`] and its [`char::len_utf8`].
|
||||
|
||||
#[doc(primitive = "char")]
|
||||
mod char {}
|
||||
|
||||
#[lang = "char"]
|
||||
impl char {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
/// [Self::f]
|
||||
/// [Self::MAX]
|
||||
// @has intra_link_prim_self/primitive.usize.html
|
||||
// @has - '//a[@href="{{channel}}/std/primitive.usize.html#method.f"]' 'Self::f'
|
||||
// @has - '//a[@href="{{channel}}/std/primitive.usize.html#associatedconstant.MAX"]' 'Self::MAX'
|
||||
// @has - '//a[@href="primitive.usize.html#method.f"]' 'Self::f'
|
||||
// @has - '//a[@href="primitive.usize.html#associatedconstant.MAX"]' 'Self::MAX'
|
||||
impl usize {
|
||||
/// Some docs
|
||||
pub fn f() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// aux-build:issue-15318.rs
|
||||
// ignore-cross-compile
|
||||
#![no_std]
|
||||
|
||||
extern crate issue_15318;
|
||||
|
||||
|
|
|
|||
6
src/test/rustdoc/no_std-primitive.rs
Normal file
6
src/test/rustdoc/no_std-primitive.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#![no_std]
|
||||
|
||||
/// Link to [intra-doc link][u8]
|
||||
// @has 'no_std_primitive/fn.foo.html' '//a[@href="{{channel}}/core/primitive.u8.html"]' 'intra-doc link'
|
||||
// @has - '//a[@href="{{channel}}/core/primitive.u8.html"]' 'u8'
|
||||
pub fn foo() -> u8 {}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#![no_std]
|
||||
|
||||
// @has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'u8'
|
||||
// Link to [u8]
|
||||
// @has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'primitive link'
|
||||
/// Link to [primitive link][u8]
|
||||
pub fn foo() -> u8 {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue