Skip to content

Commit 9332167

Browse files
add -Zui-testing to rustdoc
1 parent 20dc0c5 commit 9332167

6 files changed

+48
-37
lines changed

src/librustdoc/core.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl DocAccessLevels for AccessLevels<DefId> {
263263
pub fn new_handler(error_format: ErrorOutputType,
264264
source_map: Option<Lrc<source_map::SourceMap>>,
265265
treat_err_as_bug: bool,
266+
ui_testing: bool,
266267
) -> errors::Handler {
267268
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
268269
// stick to the defaults
@@ -274,7 +275,7 @@ pub fn new_handler(error_format: ErrorOutputType,
274275
source_map.map(|cm| cm as _),
275276
false,
276277
sessopts.debugging_opts.teach,
277-
).ui_testing(sessopts.debugging_opts.ui_testing)
278+
).ui_testing(ui_testing)
278279
),
279280
ErrorOutputType::Json(pretty) => {
280281
let source_map = source_map.unwrap_or_else(
@@ -284,7 +285,7 @@ pub fn new_handler(error_format: ErrorOutputType,
284285
None,
285286
source_map,
286287
pretty,
287-
).ui_testing(sessopts.debugging_opts.ui_testing)
288+
).ui_testing(ui_testing)
288289
)
289290
},
290291
ErrorOutputType::Short(color_config) => Box::new(
@@ -326,6 +327,7 @@ pub fn run_core(search_paths: SearchPaths,
326327
mut manual_passes: Vec<String>,
327328
mut default_passes: passes::DefaultPassOption,
328329
treat_err_as_bug: bool,
330+
ui_testing: bool,
329331
) -> (clean::Crate, RenderInfo, Vec<String>) {
330332
// Parse, resolve, and typecheck the given crate.
331333

@@ -380,6 +382,8 @@ pub fn run_core(search_paths: SearchPaths,
380382
actually_rustdoc: true,
381383
debugging_opts: config::DebuggingOptions {
382384
force_unstable_if_unmarked,
385+
treat_err_as_bug,
386+
ui_testing,
383387
..config::basic_debugging_options()
384388
},
385389
error_format,
@@ -391,7 +395,8 @@ pub fn run_core(search_paths: SearchPaths,
391395
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
392396
let diagnostic_handler = new_handler(error_format,
393397
Some(source_map.clone()),
394-
treat_err_as_bug);
398+
treat_err_as_bug,
399+
ui_testing);
395400

396401
let mut sess = session::build_session_(
397402
sessopts, cpath, diagnostic_handler, source_map,

src/librustdoc/lib.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,11 @@ fn main_args(args: &[String]) -> isize {
407407
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
408408
*x == "treat-err-as-bug"
409409
});
410+
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
411+
*x == "ui-testing"
412+
});
410413

411-
let diag = core::new_handler(error_format, None, treat_err_as_bug);
414+
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);
412415

413416
// check for deprecated options
414417
check_deprecated_options(&matches, &diag);
@@ -563,7 +566,7 @@ fn main_args(args: &[String]) -> isize {
563566
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
564567
move |out| {
565568
let Output { krate, passes, renderinfo } = out;
566-
let diag = core::new_handler(error_format, None, treat_err_as_bug);
569+
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);
567570
info!("going to format");
568571
match output_format.as_ref().map(|s| &**s) {
569572
Some("html") | None => {
@@ -700,6 +703,9 @@ where R: 'static + Send,
700703
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
701704
*x == "treat-err-as-bug"
702705
});
706+
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
707+
*x == "ui-testing"
708+
});
703709

704710
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
705711

@@ -713,7 +719,7 @@ where R: 'static + Send,
713719
display_warnings, crate_name.clone(),
714720
force_unstable_if_unmarked, edition, cg, error_format,
715721
lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
716-
treat_err_as_bug);
722+
treat_err_as_bug, ui_testing);
717723

718724
info!("finished with rustc");
719725

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: `[v2]` cannot be resolved, ignoring it...
22
--> $DIR/deny-intra-link-resolution-failure.rs:13:6
33
|
4-
13 | /// [v2] //~ ERROR
4+
LL | /// [v2] //~ ERROR
55
| ^^ cannot be resolved, ignoring
66
|
77
note: lint level defined here
88
--> $DIR/deny-intra-link-resolution-failure.rs:11:9
99
|
10-
11 | #![deny(intra_doc_link_resolution_failure)]
10+
LL | #![deny(intra_doc_link_resolution_failure)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
1313

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
warning: the `#![doc(no_default_passes)]` attribute is considered deprecated
2-
|
3-
= warning: please see https://github.com/rust-lang/rust/issues/44136
4-
= help: you may want to use `#![doc(document_private_items)]`
2+
|
3+
= warning: please see https://github.com/rust-lang/rust/issues/44136
4+
= help: you may want to use `#![doc(document_private_items)]`
55

66
warning: the `#![doc(passes = "...")]` attribute is considered deprecated
7-
|
8-
= warning: please see https://github.com/rust-lang/rust/issues/44136
7+
|
8+
= warning: please see https://github.com/rust-lang/rust/issues/44136
99

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: `[TypeAlias::hoge]` cannot be resolved, ignoring it...
22
--> $DIR/intra-doc-alias-ice.rs:15:30
33
|
4-
15 | /// [broken cross-reference](TypeAlias::hoge) //~ ERROR
4+
LL | /// [broken cross-reference](TypeAlias::hoge) //~ ERROR
55
| ^^^^^^^^^^^^^^^ cannot be resolved, ignoring
66
|
77
note: lint level defined here
88
--> $DIR/intra-doc-alias-ice.rs:11:9
99
|
10-
11 | #![deny(intra_doc_link_resolution_failure)]
10+
LL | #![deny(intra_doc_link_resolution_failure)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
1313

src/test/rustdoc-ui/intra-links-warning.stderr

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: `[Foo::baz]` cannot be resolved, ignoring it...
22
--> $DIR/intra-links-warning.rs:13:23
33
|
4-
13 | //! Test with [Foo::baz], [Bar::foo], ...
4+
LL | //! Test with [Foo::baz], [Bar::foo], ...
55
| ^^^^^^^^ cannot be resolved, ignoring
66
|
77
= note: #[warn(intra_doc_link_resolution_failure)] on by default
@@ -10,67 +10,67 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it...
1010
warning: `[Bar::foo]` cannot be resolved, ignoring it...
1111
--> $DIR/intra-links-warning.rs:13:35
1212
|
13-
13 | //! Test with [Foo::baz], [Bar::foo], ...
13+
LL | //! Test with [Foo::baz], [Bar::foo], ...
1414
| ^^^^^^^^ cannot be resolved, ignoring
1515
|
1616
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
1717

1818
warning: `[Uniooon::X]` cannot be resolved, ignoring it...
1919
--> $DIR/intra-links-warning.rs:14:13
2020
|
21-
14 | //! , [Uniooon::X] and [Qux::Z].
21+
LL | //! , [Uniooon::X] and [Qux::Z].
2222
| ^^^^^^^^^^ cannot be resolved, ignoring
2323
|
2424
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
2525

2626
warning: `[Qux::Z]` cannot be resolved, ignoring it...
2727
--> $DIR/intra-links-warning.rs:14:30
2828
|
29-
14 | //! , [Uniooon::X] and [Qux::Z].
29+
LL | //! , [Uniooon::X] and [Qux::Z].
3030
| ^^^^^^ cannot be resolved, ignoring
3131
|
3232
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
3333

3434
warning: `[Uniooon::X]` cannot be resolved, ignoring it...
3535
--> $DIR/intra-links-warning.rs:16:14
3636
|
37-
16 | //! , [Uniooon::X] and [Qux::Z].
37+
LL | //! , [Uniooon::X] and [Qux::Z].
3838
| ^^^^^^^^^^ cannot be resolved, ignoring
3939
|
4040
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
4141

4242
warning: `[Qux::Z]` cannot be resolved, ignoring it...
4343
--> $DIR/intra-links-warning.rs:16:31
4444
|
45-
16 | //! , [Uniooon::X] and [Qux::Z].
45+
LL | //! , [Uniooon::X] and [Qux::Z].
4646
| ^^^^^^ cannot be resolved, ignoring
4747
|
4848
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
4949

5050
warning: `[Qux:Y]` cannot be resolved, ignoring it...
5151
--> $DIR/intra-links-warning.rs:18:13
5252
|
53-
18 | /// [Qux:Y]
53+
LL | /// [Qux:Y]
5454
| ^^^^^ cannot be resolved, ignoring
5555
|
5656
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
5757

5858
warning: `[BarA]` cannot be resolved, ignoring it...
5959
--> $DIR/intra-links-warning.rs:24:10
6060
|
61-
24 | /// bar [BarA] bar
61+
LL | /// bar [BarA] bar
6262
| ^^^^ cannot be resolved, ignoring
6363
|
6464
= help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
6565

6666
warning: `[BarB]` cannot be resolved, ignoring it...
6767
--> $DIR/intra-links-warning.rs:28:1
6868
|
69-
28 | / /**
70-
29 | | * Foo
71-
30 | | * bar [BarB] bar
72-
31 | | * baz
73-
32 | | */
69+
LL | / /**
70+
LL | | * Foo
71+
LL | | * bar [BarB] bar
72+
LL | | * baz
73+
LL | | */
7474
| |___^
7575
|
7676
= note: the link appears in this line:
@@ -82,13 +82,13 @@ warning: `[BarB]` cannot be resolved, ignoring it...
8282
warning: `[BarC]` cannot be resolved, ignoring it...
8383
--> $DIR/intra-links-warning.rs:35:1
8484
|
85-
35 | / /** Foo
86-
36 | |
87-
37 | | bar [BarC] bar
88-
38 | | baz
85+
LL | / /** Foo
86+
LL | |
87+
LL | | bar [BarC] bar
88+
LL | | baz
8989
... |
90-
44 | |
91-
45 | | */
90+
LL | |
91+
LL | | */
9292
| |__^
9393
|
9494
= note: the link appears in this line:
@@ -100,7 +100,7 @@ warning: `[BarC]` cannot be resolved, ignoring it...
100100
warning: `[BarD]` cannot be resolved, ignoring it...
101101
--> $DIR/intra-links-warning.rs:48:1
102102
|
103-
48 | #[doc = "Foo/nbar [BarD] bar/nbaz"]
103+
LL | #[doc = "Foo/nbar [BarD] bar/nbaz"]
104104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105105
|
106106
= note: the link appears in this line:
@@ -112,10 +112,10 @@ warning: `[BarD]` cannot be resolved, ignoring it...
112112
warning: `[BarF]` cannot be resolved, ignoring it...
113113
--> $DIR/intra-links-warning.rs:53:9
114114
|
115-
53 | #[doc = $f]
115+
LL | #[doc = $f]
116116
| ^^^^^^^^^^^
117117
...
118-
57 | f!("Foo/nbar [BarF] bar/nbaz");
118+
LL | f!("Foo/nbar [BarF] bar/nbaz");
119119
| ------------------------------- in this macro invocation
120120
|
121121
= note: the link appears in this line:

0 commit comments

Comments
 (0)