Skip to content

Commit 99104ef

Browse files
Finish fixing ui tests
1 parent 2cb8057 commit 99104ef

File tree

18 files changed

+460
-175
lines changed

18 files changed

+460
-175
lines changed

compiler/rustc_attr_parsing/src/attributes/doc.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,12 @@ impl DocParser {
442442
cx.emit_lint(AttributeLintKind::DocUnknownAny { name }, path.span());
443443
}
444444
None => {
445-
// FIXME: is there anything to do in this case?
445+
let full_name =
446+
path.segments().map(|s| s.as_str()).intersperse("::").collect::<String>();
447+
cx.emit_lint(
448+
AttributeLintKind::DocUnknownAny { name: Symbol::intern(&full_name) },
449+
path.span(),
450+
);
446451
}
447452
}
448453
}

compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#![recursion_limit = "256"]
8282
// tidy-alphabetical-end
8383
#![feature(if_let_guard)]
84+
#![feature(iter_intersperse)]
8485

8586
#[macro_use]
8687
/// All the individual attribute parsers for each of rustc's built-in attributes.

tests/rustdoc-ui/deprecated-attrs.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error: unknown `doc` attribute `passes`
1717
--> $DIR/deprecated-attrs.rs:9:8
1818
|
1919
LL | #![doc(passes = "collapse-docs unindent-comments")]
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no longer functions
20+
| ^^^^^^ no longer functions
2121
|
2222
= note: `doc` attribute `passes` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
2323
= note: `doc(passes)` is now a no-op
@@ -26,7 +26,7 @@ error: unknown `doc` attribute `plugins`
2626
--> $DIR/deprecated-attrs.rs:14:8
2727
|
2828
LL | #![doc(plugins = "xxx")]
29-
| ^^^^^^^^^^^^^^^ no longer functions
29+
| ^^^^^^^ no longer functions
3030
|
3131
= note: `doc` attribute `plugins` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
3232
= note: `doc(plugins)` is now a no-op
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
#![doc(alias = "crate-level-not-working")] //~ ERROR
2-
3-
#[doc(alias = "shouldn't work!")] //~ ERROR
4-
pub fn foo() {}
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
2-
--> $DIR/doc-alias-crate-level.rs:3:15
3-
|
4-
LL | #[doc(alias = "shouldn't work!")]
5-
| ^^^^^^^^^^^^^^^^^
6-
71
error: `#![doc(alias = "...")]` isn't allowed as a crate-level attribute
8-
--> $DIR/doc-alias-crate-level.rs:1:8
2+
--> $DIR/doc-alias-crate-level.rs:1:16
93
|
104
LL | #![doc(alias = "crate-level-not-working")]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
126

13-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
148

tests/rustdoc-ui/doc-alias.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[doc(alias = "shouldn't work!")] //~ ERROR
2+
pub fn foo() {}

tests/rustdoc-ui/doc-alias.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: '\'' character isn't allowed in `#[doc(alias = "...")]`
2+
--> $DIR/doc-alias.rs:1:15
3+
|
4+
LL | #[doc(alias = "shouldn't work!")]
5+
| ^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

tests/rustdoc-ui/doc-cfg-2.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(doc_cfg)]
2+
3+
#[doc(cfg(foo), cfg(bar))]
4+
//~^ WARN unexpected `cfg` condition name: `foo`
5+
//~| WARN unexpected `cfg` condition name: `bar`
6+
#[doc(auto_cfg(42))] //~ ERROR
7+
#[doc(auto_cfg(hide(true)))] //~ ERROR
8+
#[doc(auto_cfg(hide(42)))] //~ ERROR
9+
#[doc(auto_cfg(hide("a")))] //~ ERROR
10+
#[doc(auto_cfg = 42)] //~ ERROR
11+
#[doc(auto_cfg = "a")] //~ ERROR
12+
// Shouldn't lint
13+
#[doc(auto_cfg(hide(windows)))]
14+
#[doc(auto_cfg(hide(feature = "windows")))]
15+
#[doc(auto_cfg(hide(foo)))]
16+
pub fn foo() {}

tests/rustdoc-ui/doc-cfg-2.stderr

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
warning: unexpected `cfg` condition name: `foo`
2+
--> $DIR/doc-cfg-2.rs:3:11
3+
|
4+
LL | #[doc(cfg(foo), cfg(bar))]
5+
| ^^^
6+
|
7+
= help: expected names are: `FALSE` and `test` and 31 more
8+
= help: to expect this configuration use `--check-cfg=cfg(foo)`
9+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
10+
= note: `#[warn(unexpected_cfgs)]` on by default
11+
12+
warning: unexpected `cfg` condition name: `bar`
13+
--> $DIR/doc-cfg-2.rs:3:21
14+
|
15+
LL | #[doc(cfg(foo), cfg(bar))]
16+
| ^^^
17+
|
18+
= help: to expect this configuration use `--check-cfg=cfg(bar)`
19+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
20+
21+
error: only `hide` or `show` are allowed in `#[doc(auto_cfg(...))]`
22+
--> $DIR/doc-cfg-2.rs:6:16
23+
|
24+
LL | #[doc(auto_cfg(42))]
25+
| ^^
26+
|
27+
= note: `#[deny(invalid_doc_attributes)]` on by default
28+
29+
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items
30+
--> $DIR/doc-cfg-2.rs:7:21
31+
|
32+
LL | #[doc(auto_cfg(hide(true)))]
33+
| ^^^^
34+
35+
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items
36+
--> $DIR/doc-cfg-2.rs:8:21
37+
|
38+
LL | #[doc(auto_cfg(hide(42)))]
39+
| ^^
40+
41+
error: `#![doc(auto_cfg(hide(...)))]` only accepts identifiers or key/value items
42+
--> $DIR/doc-cfg-2.rs:9:21
43+
|
44+
LL | #[doc(auto_cfg(hide("a")))]
45+
| ^^^
46+
47+
error: expected boolean for `#[doc(auto_cfg = ...)]`
48+
--> $DIR/doc-cfg-2.rs:10:18
49+
|
50+
LL | #[doc(auto_cfg = 42)]
51+
| ^^
52+
53+
error: expected boolean for `#[doc(auto_cfg = ...)]`
54+
--> $DIR/doc-cfg-2.rs:11:18
55+
|
56+
LL | #[doc(auto_cfg = "a")]
57+
| ^^^
58+
59+
error: aborting due to 6 previous errors; 2 warnings emitted
60+

tests/rustdoc-ui/doc-cfg.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
#![feature(doc_cfg)]
22

33
#[doc(cfg(), cfg(foo, bar))]
4-
//~^ ERROR
5-
//~^^ ERROR
6-
#[doc(cfg(foo), cfg(bar))]
7-
//~^ WARN unexpected `cfg` condition name: `foo`
8-
//~^^ WARN unexpected `cfg` condition name: `bar`
4+
//~^ ERROR malformed `doc` attribute input
5+
//~| ERROR malformed `doc` attribute input
96
#[doc(cfg())] //~ ERROR
107
#[doc(cfg(foo, bar))] //~ ERROR
11-
#[doc(auto_cfg(42))] //~ ERROR
12-
#[doc(auto_cfg(hide(true)))] //~ ERROR
13-
#[doc(auto_cfg(hide(42)))] //~ ERROR
14-
#[doc(auto_cfg(hide("a")))] //~ ERROR
158
#[doc(auto_cfg(hide(foo::bar)))] //~ ERROR
16-
#[doc(auto_cfg = 42)] //~ ERROR
17-
#[doc(auto_cfg = "a")] //~ ERROR
18-
// Shouldn't lint
19-
#[doc(auto_cfg(hide(windows)))]
20-
#[doc(auto_cfg(hide(feature = "windows")))]
21-
#[doc(auto_cfg(hide(foo)))]
229
pub fn foo() {}

0 commit comments

Comments
 (0)