Skip to content

Commit 3c51718

Browse files
committed
Auto merge of rust-lang#91275 - camelid:deny-test-warnings, r=jyn514
Deny warnings in rustdoc non-UI tests These warnings were silently ignored since they did not appear in a `.stderr` file and did not fail the test. With this change, warnings in tests are denied, causing the tests to fail if they have warnings. This change has already led me to find a bug in rustdoc (rust-lang#91274) and a useless test (`src/test/rustdoc/primitive/primitive-generic-impl.rs`, though its uselessness is unrelated to its warnings). r? `@jyn514`
2 parents f04a2f4 + ac88bb7 commit 3c51718

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+118
-66
lines changed

src/test/rustdoc-js/summaries.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![crate_type = "lib"]
22
#![crate_name = "summaries"]
33

4+
#![allow(rustdoc::broken_intra_doc_links)]
5+
46
//! This *summary* has a [link], [`code`], and [`Sidebar2`] intra-doc.
57
//!
68
//! This is the second paragraph. It should not be rendered.

src/test/rustdoc/intra-doc/through-proc-macro.rs renamed to src/test/rustdoc-ui/intra-doc/through-proc-macro.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
// check-pass
12
// aux-build:through-proc-macro-aux.rs
23
// build-aux-docs
3-
#![warn(broken_intra_doc_links)]
4+
5+
// Ensure rustdoc doesn't panic on this code.
6+
7+
#![warn(rustdoc::broken_intra_doc_links)]
8+
49
extern crate some_macros;
510

611
#[some_macros::second]
712
pub enum Boom {
813
/// [Oooops]
14+
//~^ WARNING unresolved link to `Oooops`
915
Bam,
1016
}
1117

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
warning: unresolved link to `Oooops`
2+
--> $DIR/through-proc-macro.rs:13:10
3+
|
4+
LL | /// [Oooops]
5+
| ^^^^^^ no item named `Oooops` in scope
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/through-proc-macro.rs:7:9
9+
|
10+
LL | #![warn(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
13+
14+
warning: 1 warning emitted
15+

src/test/rustdoc/auto-impl-primitive.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#![feature(rustdoc_internals)]
2+
13
#![crate_name = "foo"]
4+
25
pub use std::fs::File;
36

47
// @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation'

src/test/rustdoc/bad-codeblock-syntax.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(rustdoc::invalid_rust_codeblocks)]
2+
13
// @has bad_codeblock_syntax/fn.foo.html
24
// @has - '//*[@class="docblock"]' '\_'
35
/// ```

src/test/rustdoc/check-source-code-urls-to-def.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// aux-build:source_code.rs
33
// build-aux-docs
44

5+
#![feature(rustdoc_internals)]
6+
57
#![crate_name = "foo"]
68

79
extern crate source_code;
@@ -29,21 +31,20 @@ fn babar() {}
2931
// @has - '//a/@href' '/struct.String.html'
3032
// @has - '//a/@href' '/primitive.u32.html'
3133
// @has - '//a/@href' '/primitive.str.html'
32-
// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#21"]' 5
34+
// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5
3335
// @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
3436
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
3537
let x = 12;
3638
let y: Foo = Foo;
3739
let z: Bar = bar::Bar { field: Foo };
3840
babar();
39-
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#24"]' 'hello'
41+
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#26"]' 'hello'
4042
y.hello();
4143
}
4244

4345
// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
4446
// @has - '//a[@href="../../src/foo/auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
45-
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {
46-
}
47+
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
4748

4849
// @has - '//a[@href="../../foo/primitive.bool.html"]' 'bool'
4950
#[doc(primitive = "bool")]

src/test/rustdoc/const-generics/const-impl.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(incomplete_features)]
2+
13
#![feature(adt_const_params)]
24

35
#![crate_name = "foo"]
@@ -15,23 +17,23 @@ pub struct VSet<T, const ORDER: Order> {
1517
inner: Vec<T>,
1618
}
1719

18-
// @has foo/struct.VSet.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, {Order::Sorted}>'
19-
impl <T> VSet<T, {Order::Sorted}> {
20+
// @has foo/struct.VSet.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Sorted }>'
21+
impl<T> VSet<T, { Order::Sorted }> {
2022
pub fn new() -> Self {
2123
Self { inner: Vec::new() }
2224
}
2325
}
2426

25-
// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, {Order::Unsorted}>'
26-
impl <T> VSet<T, {Order::Unsorted}> {
27+
// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, { Order::Unsorted }>'
28+
impl<T> VSet<T, { Order::Unsorted }> {
2729
pub fn new() -> Self {
2830
Self { inner: Vec::new() }
2931
}
3032
}
3133

3234
pub struct Escape<const S: &'static str>;
3335

34-
// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escape<{ r#"<script>alert("Escape");</script>"# }>'
35-
impl Escape<{ r#"<script>alert("Escape");</script>"# }> {
36+
// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>'
37+
impl Escape<r#"<script>alert("Escape");</script>"#> {
3638
pub fn f() {}
3739
}

src/test/rustdoc/default-trait-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(specialization)]
1+
#![feature(min_specialization)]
22

33
// @has default_trait_method/trait.Item.html
44
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'

src/test/rustdoc/doc-cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ pub fn uses_cfg_target_feature() {
9696
// @has doc_cfg/fn.multiple_attrs.html \
9797
// '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \
9898
// 'This is supported on x and y and z only.'
99-
#[doc(inline, cfg(x))]
99+
#[doc(cfg(x))]
100100
#[doc(cfg(y), cfg(z))]
101101
pub fn multiple_attrs() {}

src/test/rustdoc/intra-doc/associated-defaults.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22
#![feature(associated_type_defaults)]
33

44
pub trait TraitWithDefault {

src/test/rustdoc/intra-doc/associated-items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33
/// [`std::collections::BTreeMap::into_iter`]
44
/// [`String::from`] is ambiguous as to which `From` impl

src/test/rustdoc/intra-doc/auxiliary/my-core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(no_core, lang_items)]
1+
#![feature(no_core, lang_items, rustdoc_internals)]
22
#![no_core]
33
#![crate_type="rlib"]
44

src/test/rustdoc/intra-doc/cross-crate/additional_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:additional_doc.rs
22
// build-aux-docs
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
extern crate my_rand;
66

src/test/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "my_rand"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
pub trait RngCore {}
55
/// Rng extends [`RngCore`].

src/test/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "hidden_dep"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
#[doc(hidden)]
55
pub mod __reexport {

src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "a"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
pub struct Foo;
55

src/test/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "macro_inner"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
pub struct Foo;
55

src/test/rustdoc/intra-doc/cross-crate/auxiliary/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "module_inner"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33
/// [SomeType] links to [bar]
44
pub struct SomeType;
55
pub trait SomeTrait {}

src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "a"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
pub mod bar {
55
pub struct Bar;

src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "bar"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33

44
pub trait Foo {
55
/// [`Bar`] [`Baz`]

src/test/rustdoc/intra-doc/cross-crate/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:intra-doc-basic.rs
22
// build-aux-docs
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
// from https://github.com/rust-lang/rust/issues/65983
66
extern crate a;

src/test/rustdoc/intra-doc/cross-crate/hidden.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:hidden.rs
22
// build-aux-docs
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
// tests https://github.com/rust-lang/rust/issues/73363
66

src/test/rustdoc/intra-doc/cross-crate/macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:macro_inner.rs
22
// aux-build:proc_macro.rs
33
// build-aux-docs
4-
#![deny(broken_intra_doc_links)]
4+
#![deny(rustdoc::broken_intra_doc_links)]
55
extern crate macro_inner;
66
extern crate proc_macro_inner;
77

src/test/rustdoc/intra-doc/cross-crate/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// outer.rs
22
// aux-build: module.rs
33
// build-aux-docs
4-
#![deny(broken_intra_doc_links)]
4+
#![deny(rustdoc::broken_intra_doc_links)]
55
extern crate module_inner;
66
// @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait'
77
// @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType'

src/test/rustdoc/intra-doc/cross-crate/submodule-inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:submodule-inner.rs
22
// build-aux-docs
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
extern crate a;
66

src/test/rustdoc/intra-doc/cross-crate/submodule-outer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:submodule-outer.rs
22
// edition:2018
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
extern crate bar as bar_;
66

src/test/rustdoc/intra-doc/cross-crate/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:traits.rs
22
// build-aux-docs
3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
extern crate inner;
66
use inner::SomeTrait;

src/test/rustdoc/intra-doc/disambiguators-removed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22
// first try backticks
33
/// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`]
44
// @has disambiguators_removed/struct.AtDisambiguator.html

src/test/rustdoc/intra-doc/email-address.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(rustdoc::broken_intra_doc_links)]
2+
13
//! Email me at <[email protected]>.
24
//! Email me at <[email protected]>.
35
//! Email me at <hello@localhost> (this warns but will still become a link).

src/test/rustdoc/intra-doc/extern-crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
// though they would never actually get displayed. This tripped intra-doc-link resolution failures,
55
// for items that aren't under our control, and not actually getting documented!
66

7-
#![deny(broken_intra_doc_links)]
7+
#![deny(rustdoc::broken_intra_doc_links)]
88

99
extern crate inner;

src/test/rustdoc/intra-doc/external-traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ignore-cross-compile
33

44
#![crate_name = "outer"]
5-
#![deny(broken_intra_doc_links)]
5+
#![deny(rustdoc::broken_intra_doc_links)]
66

77
// using a trait that has intra-doc links on it from another crate (whether re-exporting or just
88
// implementing it) used to give spurious resolution failure warnings

src/test/rustdoc/intra-doc/in-bodies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// we need to make sure that intra-doc links on trait impls get resolved in the right scope
22

3-
#![deny(broken_intra_doc_links)]
3+
#![deny(rustdoc::broken_intra_doc_links)]
44

55
pub mod inner {
66
pub struct SomethingOutOfScope;

src/test/rustdoc/intra-doc/issue-82209.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "foo"]
2-
#![deny(broken_intra_doc_links)]
2+
#![deny(rustdoc::broken_intra_doc_links)]
33
pub enum Foo {
44
Bar {
55
abc: i32,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22
#![feature(intra_doc_pointers)]
33

44
pub use std::*;

src/test/rustdoc/intra-doc/mod-ambiguity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33

44
pub fn foo() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33
//! [i32::MAX]
44
// @has prim_assoc/index.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX"

src/test/rustdoc/intra-doc/prim-methods-external-core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ignore-cross-compile
44
// only-linux
55

6-
#![deny(broken_intra_doc_links)]
6+
#![deny(rustdoc::broken_intra_doc_links)]
77
#![feature(no_core, lang_items)]
88
#![no_core]
99
#![crate_type = "rlib"]

src/test/rustdoc/intra-doc/prim-methods-local.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#![deny(broken_intra_doc_links)]
2-
#![feature(no_core, lang_items)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
2+
#![feature(no_core, lang_items, rustdoc_internals)]
33
#![no_core]
44
#![crate_type = "rlib"]
55

src/test/rustdoc/intra-doc/prim-methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33

44
// @has prim_methods/index.html

src/test/rustdoc/intra-doc/prim-precedence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33
pub mod char {
44
/// [char]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22
// @has primitive_disambiguators/index.html
33
// @has - '//a/@href' '{{channel}}/std/primitive.str.html#method.trim'
44
//! [str::trim()]

src/test/rustdoc/intra-doc/primitive-non-default-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(broken_intra_doc_links)]
1+
#![deny(rustdoc::broken_intra_doc_links)]
22

33

44
// @has primitive_non_default_impl/fn.str_methods.html

src/test/rustdoc/intra-doc/private-failures-ignored.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
33
// checked for accuracy anyway.
44

5-
#![deny(broken_intra_doc_links)]
5+
#![deny(rustdoc::broken_intra_doc_links)]
66

77
/// ooh, i'm a [rebel] just for kicks
88
struct SomeStruct;

src/test/rustdoc/intra-doc/private.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#![crate_name = "private"]
21
// compile-flags: --document-private-items
32

43
// make sure to update `rustdoc-ui/intra-doc/private.rs` if you update this file
54

5+
#![allow(rustdoc::private_intra_doc_links)]
6+
7+
#![crate_name = "private"]
8+
69
/// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x]
710
// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html"]' 'DontDocMe'
811
// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#method.f"]' 'DontDocMe::f'

0 commit comments

Comments
 (0)