Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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() {}

0 commit comments

Comments
 (0)