Fix warnings in rustdoc HTML tests

Now that compiletest denies warnings in these tests, they need fixing!
This commit is contained in:
Noah Lev 2021-11-26 15:03:16 -08:00
parent 5fcae0a05d
commit ee58c06a12
64 changed files with 114 additions and 61 deletions

View File

@ -1,11 +1,17 @@
// check-pass
// aux-build:through-proc-macro-aux.rs
// build-aux-docs
#![warn(broken_intra_doc_links)]
// Ensure rustdoc doesn't panic on this code.
#![warn(rustdoc::broken_intra_doc_links)]
extern crate some_macros;
#[some_macros::second]
pub enum Boom {
/// [Oooops]
//~^ WARNING unresolved link to `Oooops`
Bam,
}

View File

@ -0,0 +1,15 @@
warning: unresolved link to `Oooops`
--> $DIR/through-proc-macro.rs:13:10
|
LL | /// [Oooops]
| ^^^^^^ no item named `Oooops` in scope
|
note: the lint level is defined here
--> $DIR/through-proc-macro.rs:7:9
|
LL | #![warn(rustdoc::broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
warning: 1 warning emitted

View File

@ -1,4 +1,7 @@
#![feature(rustdoc_internals)]
#![crate_name = "foo"]
pub use std::fs::File;
// @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation'

View File

@ -1,3 +1,5 @@
#![allow(rustdoc::invalid_rust_codeblocks)]
// @has bad_codeblock_syntax/fn.foo.html
// @has - '//*[@class="docblock"]' '\_'
/// ```

View File

@ -2,6 +2,8 @@
// aux-build:source_code.rs
// build-aux-docs
#![feature(rustdoc_internals)]
#![crate_name = "foo"]
extern crate source_code;
@ -29,21 +31,20 @@ fn babar() {}
// @has - '//a/@href' '/struct.String.html'
// @has - '//a/@href' '/primitive.u32.html'
// @has - '//a/@href' '/primitive.str.html'
// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#21"]' 5
// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5
// @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
let x = 12;
let y: Foo = Foo;
let z: Bar = bar::Bar { field: Foo };
babar();
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#24"]' 'hello'
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#26"]' 'hello'
y.hello();
}
// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {
}
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
// @has - '//a[@href="../../foo/primitive.bool.html"]' 'bool'
#[doc(primitive = "bool")]

View File

@ -1,3 +1,5 @@
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![crate_name = "foo"]
@ -15,15 +17,15 @@ pub struct VSet<T, const ORDER: Order> {
inner: Vec<T>,
}
// @has foo/struct.VSet.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, {Order::Sorted}>'
impl <T> VSet<T, {Order::Sorted}> {
// @has foo/struct.VSet.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Sorted }>'
impl<T> VSet<T, { Order::Sorted }> {
pub fn new() -> Self {
Self { inner: Vec::new() }
}
}
// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, {Order::Unsorted}>'
impl <T> VSet<T, {Order::Unsorted}> {
// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Unsorted }>'
impl<T> VSet<T, { Order::Unsorted }> {
pub fn new() -> Self {
Self { inner: Vec::new() }
}
@ -31,7 +33,7 @@ impl <T> VSet<T, {Order::Unsorted}> {
pub struct Escape<const S: &'static str>;
// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escape<{ r#"<script>alert("Escape");</script>"# }>'
impl Escape<{ r#"<script>alert("Escape");</script>"# }> {
// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>'
impl Escape<r#"<script>alert("Escape");</script>"#> {
pub fn f() {}
}

View File

@ -1,4 +1,4 @@
#![feature(specialization)]
#![feature(min_specialization)]
// @has default_trait_method/trait.Item.html
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'

View File

@ -96,6 +96,6 @@ pub fn uses_cfg_target_feature() {
// @has doc_cfg/fn.multiple_attrs.html \
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
// 'This is supported on x and y and z only.'
#[doc(inline, cfg(x))]
#[doc(cfg(x))]
#[doc(cfg(y), cfg(z))]
pub fn multiple_attrs() {}

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(associated_type_defaults)]
pub trait TraitWithDefault {

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(rustdoc::broken_intra_doc_links)]
/// [`std::collections::BTreeMap::into_iter`]
/// [`String::from`] is ambiguous as to which `From` impl

View File

@ -1,4 +1,4 @@
#![feature(no_core, lang_items)]
#![feature(no_core, lang_items, rustdoc_internals)]
#![no_core]
#![crate_type="rlib"]

View File

@ -1,6 +1,6 @@
// aux-build:additional_doc.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate my_rand;

View File

@ -1,5 +1,5 @@
#![crate_name = "my_rand"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub trait RngCore {}
/// Rng extends [`RngCore`].

View File

@ -1,5 +1,5 @@
#![crate_name = "hidden_dep"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#[doc(hidden)]
pub mod __reexport {

View File

@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub struct Foo;

View File

@ -1,5 +1,5 @@
#![crate_name = "macro_inner"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub struct Foo;

View File

@ -1,5 +1,5 @@
#![crate_name = "module_inner"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
/// [SomeType] links to [bar]
pub struct SomeType;
pub trait SomeTrait {}

View File

@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub mod bar {
pub struct Bar;

View File

@ -1,5 +1,5 @@
#![crate_name = "bar"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub trait Foo {
/// [`Bar`] [`Baz`]

View File

@ -1,6 +1,6 @@
// aux-build:intra-doc-basic.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// from https://github.com/rust-lang/rust/issues/65983
extern crate a;

View File

@ -1,6 +1,6 @@
// aux-build:hidden.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// tests https://github.com/rust-lang/rust/issues/73363

View File

@ -1,7 +1,7 @@
// aux-build:macro_inner.rs
// aux-build:proc_macro.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate macro_inner;
extern crate proc_macro_inner;

View File

@ -1,7 +1,7 @@
// outer.rs
// aux-build: module.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate module_inner;
// @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait'
// @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType'

View File

@ -1,6 +1,6 @@
// aux-build:submodule-inner.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate a;

View File

@ -1,6 +1,6 @@
// aux-build:submodule-outer.rs
// edition:2018
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate bar as bar_;

View File

@ -1,6 +1,6 @@
// aux-build:traits.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate inner;
use inner::SomeTrait;

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(rustdoc::broken_intra_doc_links)]
// first try backticks
/// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`]
// @has disambiguators_removed/struct.AtDisambiguator.html

View File

@ -1,3 +1,5 @@
#![allow(rustdoc::broken_intra_doc_links)]
//! Email me at <hello@example.com>.
//! Email me at <hello-world@example.com>.
//! Email me at <hello@localhost> (this warns but will still become a link).

View File

@ -4,6 +4,6 @@
// though they would never actually get displayed. This tripped intra-doc-link resolution failures,
// for items that aren't under our control, and not actually getting documented!
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate inner;

View File

@ -2,7 +2,7 @@
// ignore-cross-compile
#![crate_name = "outer"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// using a trait that has intra-doc links on it from another crate (whether re-exporting or just
// implementing it) used to give spurious resolution failure warnings

View File

@ -1,6 +1,6 @@
// we need to make sure that intra-doc links on trait impls get resolved in the right scope
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub mod inner {
pub struct SomethingOutOfScope;

View File

@ -1,5 +1,5 @@
#![crate_name = "foo"]
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub enum Foo {
Bar {
abc: i32,

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(intra_doc_pointers)]
pub use std::*;

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub fn foo() {

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
//! [i32::MAX]
// @has prim_assoc/index.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX"

View File

@ -3,7 +3,7 @@
// ignore-cross-compile
// only-linux
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type = "rlib"]

View File

@ -1,5 +1,5 @@
#![deny(broken_intra_doc_links)]
#![feature(no_core, lang_items)]
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(no_core, lang_items, rustdoc_internals)]
#![no_core]
#![crate_type = "rlib"]

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// @has prim_methods/index.html

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub mod char {
/// [char]

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// @has primitive_disambiguators/index.html
// @has - '//a/@href' '{{channel}}/std/primitive.str.html#method.trim'
//! [str::trim()]

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
// @has primitive_non_default_impl/fn.str_methods.html

View File

@ -2,7 +2,7 @@
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
// checked for accuracy anyway.
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
/// ooh, i'm a [rebel] just for kicks
struct SomeStruct;

View File

@ -1,8 +1,11 @@
#![crate_name = "private"]
// compile-flags: --document-private-items
// make sure to update `rustdoc-ui/intra-doc/private.rs` if you update this file
#![allow(rustdoc::private_intra_doc_links)]
#![crate_name = "private"]
/// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x]
// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html"]' 'DontDocMe'
// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#method.f"]' 'DontDocMe::f'

View File

@ -1,6 +1,6 @@
// aux-build:proc-macro-macro.rs
// build-aux-docs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
extern crate proc_macro_macro;

View File

@ -1,5 +1,5 @@
// aux-build: intra-link-pub-use.rs
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![crate_name = "outer"]
extern crate inner;

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
pub mod r#impl {
pub struct S;

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
/// Link to [S::assoc_fn()]
/// Link to [Default::default()]

View File

@ -1,4 +1,4 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![crate_name = "foo"]

View File

@ -1,6 +1,6 @@
// Regression test for issue #86120.
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![crate_name = "foo"]
pub struct Foo;

View File

@ -1,6 +1,7 @@
#![deny(broken_intra_doc_links)]
#![deny(rustdoc::broken_intra_doc_links)]
#![feature(lang_items)]
#![feature(no_core)]
#![feature(rustdoc_internals)]
#![no_core]
#[lang = "usize"]

View File

@ -1,6 +1,7 @@
// Tests that failing to syntax highlight a rust code-block doesn't cause
// rustdoc to fail, while still rendering the code-block (without highlighting).
#![allow(rustdoc::invalid_rust_codeblocks)]
// @has issue_12834/fn.foo.html
// @has - //pre 'a + b '

View File

@ -1,3 +1,5 @@
#![feature(rustdoc_internals)]
// @has issue_15318_3/primitive.pointer.html
/// dox

View File

@ -1,4 +1,5 @@
#![feature(lang_items)]
#![feature(rustdoc_internals)]
#![no_std]
pub mod str {

View File

@ -1,3 +1,5 @@
#![allow(rustdoc::invalid_rust_codeblocks)]
// @has issue_42760/struct.NonGen.html
// @has - '//h2' 'Example'

View File

@ -2,6 +2,7 @@ pub fn g() -> impl Iterator<Item=u8> {
Some(1u8).into_iter()
}
#[allow(unused_parens)]
pub fn h() -> (impl Iterator<Item=u8>) {
Some(1u8).into_iter()
}

View File

@ -1,3 +1,5 @@
#![allow(rustdoc::broken_intra_doc_links)]
#![crate_name = "foo"]
//! hello [foo]

View File

@ -1,3 +1,5 @@
#![feature(rustdoc_internals)]
#![crate_name = "foo"]
include!("primitive/primitive-generic-impl.rs");

View File

@ -1,3 +1,7 @@
#![feature(rustdoc_internals)]
// FIXME: this test doesn't test anything
#[doc(primitive = "i32")]
/// Some useless docs, wouhou!
mod i32 {}

View File

@ -8,7 +8,7 @@
// @has some_macros/index.html
// @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
//! include a link to [some_proc_macro] to make sure it works.
//! include a link to [some_proc_macro!] to make sure it works.
extern crate proc_macro;

View File

@ -2,4 +2,4 @@
// @has foo/fn.f.html
// @has - '//*[@class="rust fn"]' 'pub fn f(_: u8)'
pub fn f(0u8...255: u8) {}
pub fn f(0u8..=255: u8) {}

View File

@ -2,6 +2,7 @@
pub mod internal {
// @has 'raw_ident_eliminate_r_hashtag/internal/struct.mod.html'
#[allow(non_camel_case_types)]
pub struct r#mod;
/// See [name], [other name]

View File

@ -30,11 +30,11 @@ pub struct Bar {
// @has foo/enum.En.html
// @has - '//*[@class="sidebar-title"]/a[@href="#variants"]' 'Variants'
// @has - '//*[@class="sidebar-links"]/a' 'foo'
// @has - '//*[@class="sidebar-links"]/a' 'bar'
// @has - '//*[@class="sidebar-links"]/a' 'Foo'
// @has - '//*[@class="sidebar-links"]/a' 'Bar'
pub enum En {
foo,
bar,
Foo,
Bar,
}
// @has foo/union.MyUnion.html

View File

@ -1,5 +1,7 @@
#![crate_name = "foo"]
#![feature(rustdoc_internals)]
// @matches 'foo/index.html' '//h1' 'Crate foo'
// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'