Skip to content

Commit 3d5f54a

Browse files
committed
Respect -Z unstable options in rustdoc --test
1 parent 9642c0e commit 3d5f54a

9 files changed

+120
-119
lines changed

src/librustdoc/doctest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
173173
target_triple: options.target.clone(),
174174
crate_name: options.crate_name.clone(),
175175
remap_path_prefix: options.remap_path_prefix.clone(),
176+
unstable_opts: options.unstable_opts.clone(),
176177
..config::Options::default()
177178
};
178179

tests/rustdoc-ui/doctest/check-attr-test.stderr

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
error: unknown attribute `compile-fail`
2-
--> $DIR/check-attr-test.rs:5:1
3-
|
4-
5 | / /// foo
5-
6 | | ///
6-
7 | | /// ```compile-fail,compilefail,comPile_fail
7-
8 | | /// boo
8-
9 | | /// ```
9-
| |_______^
10-
|
11-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
12-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
2+
--> $DIR/check-attr-test.rs:5:1
3+
|
4+
LL | / /// foo
5+
LL | | ///
6+
LL | | /// ```compile-fail,compilefail,comPile_fail
7+
LL | | /// boo
8+
LL | | /// ```
9+
| |_______^
10+
|
11+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
12+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
1313
note: the lint level is defined here
14-
--> $DIR/check-attr-test.rs:3:9
15-
|
16-
3 | #![deny(rustdoc::invalid_codeblock_attributes)]
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
--> $DIR/check-attr-test.rs:3:9
15+
|
16+
LL | #![deny(rustdoc::invalid_codeblock_attributes)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: unknown attribute `compilefail`
20-
--> $DIR/check-attr-test.rs:5:1
21-
|
22-
5 | / /// foo
23-
6 | | ///
24-
7 | | /// ```compile-fail,compilefail,comPile_fail
25-
8 | | /// boo
26-
9 | | /// ```
27-
| |_______^
28-
|
29-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
30-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
20+
--> $DIR/check-attr-test.rs:5:1
21+
|
22+
LL | / /// foo
23+
LL | | ///
24+
LL | | /// ```compile-fail,compilefail,comPile_fail
25+
LL | | /// boo
26+
LL | | /// ```
27+
| |_______^
28+
|
29+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
30+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
3131

3232
error: unknown attribute `comPile_fail`
33-
--> $DIR/check-attr-test.rs:5:1
34-
|
35-
5 | / /// foo
36-
6 | | ///
37-
7 | | /// ```compile-fail,compilefail,comPile_fail
38-
8 | | /// boo
39-
9 | | /// ```
40-
| |_______^
41-
|
42-
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
43-
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
33+
--> $DIR/check-attr-test.rs:5:1
34+
|
35+
LL | / /// foo
36+
LL | | ///
37+
LL | | /// ```compile-fail,compilefail,comPile_fail
38+
LL | | /// boo
39+
LL | | /// ```
40+
| |_______^
41+
|
42+
= help: use `compile_fail` to invert the results of this test, so that it passes if it cannot be compiled and fails if it can
43+
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
4444

4545
error: unknown attribute `should-panic`
4646
--> $DIR/check-attr-test.rs:12:1
4747
|
48-
12 | / /// bar
49-
13 | | ///
50-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
51-
15 | | /// boo
52-
16 | | /// ```
48+
LL | / /// bar
49+
LL | | ///
50+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
51+
LL | | /// boo
52+
LL | | /// ```
5353
| |_______^
5454
|
5555
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
@@ -58,11 +58,11 @@ error: unknown attribute `should-panic`
5858
error: unknown attribute `shouldpanic`
5959
--> $DIR/check-attr-test.rs:12:1
6060
|
61-
12 | / /// bar
62-
13 | | ///
63-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
64-
15 | | /// boo
65-
16 | | /// ```
61+
LL | / /// bar
62+
LL | | ///
63+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
64+
LL | | /// boo
65+
LL | | /// ```
6666
| |_______^
6767
|
6868
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
@@ -71,11 +71,11 @@ error: unknown attribute `shouldpanic`
7171
error: unknown attribute `shOuld_panic`
7272
--> $DIR/check-attr-test.rs:12:1
7373
|
74-
12 | / /// bar
75-
13 | | ///
76-
14 | | /// ```should-panic,shouldpanic,shOuld_panic
77-
15 | | /// boo
78-
16 | | /// ```
74+
LL | / /// bar
75+
LL | | ///
76+
LL | | /// ```should-panic,shouldpanic,shOuld_panic
77+
LL | | /// boo
78+
LL | | /// ```
7979
| |_______^
8080
|
8181
= help: use `should_panic` to invert the results of this test, so that if passes if it panics and fails if it does not
@@ -84,11 +84,11 @@ error: unknown attribute `shOuld_panic`
8484
error: unknown attribute `no-run`
8585
--> $DIR/check-attr-test.rs:19:1
8686
|
87-
19 | / /// foobar
88-
20 | | ///
89-
21 | | /// ```no-run,norun,nO_run
90-
22 | | /// boo
91-
23 | | /// ```
87+
LL | / /// foobar
88+
LL | | ///
89+
LL | | /// ```no-run,norun,nO_run
90+
LL | | /// boo
91+
LL | | /// ```
9292
| |_______^
9393
|
9494
= help: use `no_run` to compile, but not run, the code sample during testing
@@ -97,11 +97,11 @@ error: unknown attribute `no-run`
9797
error: unknown attribute `norun`
9898
--> $DIR/check-attr-test.rs:19:1
9999
|
100-
19 | / /// foobar
101-
20 | | ///
102-
21 | | /// ```no-run,norun,nO_run
103-
22 | | /// boo
104-
23 | | /// ```
100+
LL | / /// foobar
101+
LL | | ///
102+
LL | | /// ```no-run,norun,nO_run
103+
LL | | /// boo
104+
LL | | /// ```
105105
| |_______^
106106
|
107107
= help: use `no_run` to compile, but not run, the code sample during testing
@@ -110,11 +110,11 @@ error: unknown attribute `norun`
110110
error: unknown attribute `nO_run`
111111
--> $DIR/check-attr-test.rs:19:1
112112
|
113-
19 | / /// foobar
114-
20 | | ///
115-
21 | | /// ```no-run,norun,nO_run
116-
22 | | /// boo
117-
23 | | /// ```
113+
LL | / /// foobar
114+
LL | | ///
115+
LL | | /// ```no-run,norun,nO_run
116+
LL | | /// boo
117+
LL | | /// ```
118118
| |_______^
119119
|
120120
= help: use `no_run` to compile, but not run, the code sample during testing
@@ -123,11 +123,11 @@ error: unknown attribute `nO_run`
123123
error: unknown attribute `test-harness`
124124
--> $DIR/check-attr-test.rs:26:1
125125
|
126-
26 | / /// b
127-
27 | | ///
128-
28 | | /// ```test-harness,testharness,tesT_harness
129-
29 | | /// boo
130-
30 | | /// ```
126+
LL | / /// b
127+
LL | | ///
128+
LL | | /// ```test-harness,testharness,tesT_harness
129+
LL | | /// boo
130+
LL | | /// ```
131131
| |_______^
132132
|
133133
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
@@ -136,11 +136,11 @@ error: unknown attribute `test-harness`
136136
error: unknown attribute `testharness`
137137
--> $DIR/check-attr-test.rs:26:1
138138
|
139-
26 | / /// b
140-
27 | | ///
141-
28 | | /// ```test-harness,testharness,tesT_harness
142-
29 | | /// boo
143-
30 | | /// ```
139+
LL | / /// b
140+
LL | | ///
141+
LL | | /// ```test-harness,testharness,tesT_harness
142+
LL | | /// boo
143+
LL | | /// ```
144144
| |_______^
145145
|
146146
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function
@@ -149,11 +149,11 @@ error: unknown attribute `testharness`
149149
error: unknown attribute `tesT_harness`
150150
--> $DIR/check-attr-test.rs:26:1
151151
|
152-
26 | / /// b
153-
27 | | ///
154-
28 | | /// ```test-harness,testharness,tesT_harness
155-
29 | | /// boo
156-
30 | | /// ```
152+
LL | / /// b
153+
LL | | ///
154+
LL | | /// ```test-harness,testharness,tesT_harness
155+
LL | | /// boo
156+
LL | | /// ```
157157
| |_______^
158158
|
159159
= help: use `test_harness` to run functions marked `#[test]` instead of a potentially-implicit `main` function

tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
22
--> $DIR/failed-doctest-extra-semicolon-on-item.rs:11:1
33
|
4-
11 | /// ```rust
4+
LL | /// ```rust
55
| ^^^^^^^^^^^
66

77
warning: 1 warning emitted

tests/rustdoc-ui/doctest/main-alongside-stmts.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
22
--> $DIR/main-alongside-stmts.rs:17:1
33
|
4-
17 | //! ```
4+
LL | //! ```
55
| ^^^^^^^
66

77
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
88
--> $DIR/main-alongside-stmts.rs:26:1
99
|
10-
26 | //! ```
10+
LL | //! ```
1111
| ^^^^^^^
1212

1313
warning: 2 warnings emitted

tests/rustdoc-ui/doctest/standalone-warning-2024.stderr

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
error: unknown attribute `standalone`
22
--> $DIR/standalone-warning-2024.rs:11:1
33
|
4-
11 | / //! ```standalone
5-
12 | | //! bla
6-
13 | | //! ```
7-
14 | | //!
8-
15 | | //! ```standalone-crate
9-
16 | | //! bla
10-
17 | | //! ```
4+
LL | / //! ```standalone
5+
LL | | //! bla
6+
LL | | //! ```
7+
LL | | //!
8+
LL | | //! ```standalone-crate
9+
LL | | //! bla
10+
LL | | //! ```
1111
| |_______^
1212
|
1313
= help: use `standalone_crate` to compile this code block separately
1414
= help: this code block may be skipped during testing, because unknown attributes are treated as markers for code samples written in other programming languages, unless it is also explicitly marked as `rust`
1515
note: the lint level is defined here
1616
--> $DIR/standalone-warning-2024.rs:9:9
1717
|
18-
9 | #![deny(warnings)]
18+
LL | #![deny(warnings)]
1919
| ^^^^^^^^
2020
= note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
2121

2222
error: unknown attribute `standalone-crate`
2323
--> $DIR/standalone-warning-2024.rs:11:1
2424
|
25-
11 | / //! ```standalone
26-
12 | | //! bla
27-
13 | | //! ```
28-
14 | | //!
29-
15 | | //! ```standalone-crate
30-
16 | | //! bla
31-
17 | | //! ```
25+
LL | / //! ```standalone
26+
LL | | //! bla
27+
LL | | //! ```
28+
LL | | //!
29+
LL | | //! ```standalone-crate
30+
LL | | //! bla
31+
LL | | //! ```
3232
| |_______^
3333
|
3434
= help: use `standalone_crate` to compile this code block separately

tests/rustdoc-ui/doctest/test-compile-fail1.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0428]: the name `f` is defined multiple times
2-
--> $DIR/test-compile-fail1.rs:8:1
3-
|
4-
6 | pub fn f() {}
5-
| ---------- previous definition of the value `f` here
6-
7 |
7-
8 | pub fn f() {}
8-
| ^^^^^^^^^^ `f` redefined here
9-
|
10-
= note: `f` must be defined only once in the value namespace of this module
2+
--> $DIR/test-compile-fail1.rs:8:1
3+
|
4+
LL | pub fn f() {}
5+
| ---------- previous definition of the value `f` here
6+
LL |
7+
LL | pub fn f() {}
8+
| ^^^^^^^^^^ `f` redefined here
9+
|
10+
= note: `f` must be defined only once in the value namespace of this module
1111

1212
error: aborting due to 1 previous error
1313

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: expected one of `!` or `::`, found `<eof>`
2-
--> $DIR/test-compile-fail2.rs:3:1
3-
|
4-
3 | fail
5-
| ^^^^ expected one of `!` or `::`
2+
--> $DIR/test-compile-fail2.rs:3:1
3+
|
4+
LL | fail
5+
| ^^^^ expected one of `!` or `::`
66

77
error: aborting due to 1 previous error
88

tests/rustdoc-ui/doctest/test-compile-fail3.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0765]: unterminated double quote string
2-
--> $DIR/test-compile-fail3.rs:3:1
3-
|
4-
3 | "fail
5-
| ^^^^^
2+
--> $DIR/test-compile-fail3.rs:3:1
3+
|
4+
LL | "fail
5+
| ^^^^^
66

77
error: aborting due to 1 previous error
88

tests/rustdoc-ui/doctest/warn-main-not-called.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
22
--> $DIR/warn-main-not-called.rs:10:1
33
|
4-
10 | //! ```
4+
LL | //! ```
55
| ^^^^^^^
66

77
warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function
88
--> $DIR/warn-main-not-called.rs:19:1
99
|
10-
19 | //! ```
10+
LL | //! ```
1111
| ^^^^^^^
1212

1313
warning: 2 warnings emitted

0 commit comments

Comments
 (0)