Skip to content

Commit a1c8846

Browse files
committed
ignore ui-fulldeps/session-derive-errors.rs on beta and stable
The session-derive-errors test ensures the internal SessionDiagnostic derive macro outputs the right error messages when misused. The macro relies on the proc_macro2 crate though, which changes its span behavior depending on whether the channel is nightly or not. This caused test failures when bumping the channel from nightly to beta/stable. Since SessionDiagnostic is internal-only we don't care about its diagnostics quality outside of nightly, as the compiler itself is developed on nightly. Thus the easiest solution is to ignore that test on the beta and stable channels. This also implements `// only-{channel}` and `// ignore-{channel}` in compiletest to properly support the change.
1 parent 022720b commit a1c8846

File tree

7 files changed

+48
-19
lines changed

7 files changed

+48
-19
lines changed

src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,8 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15171517

15181518
cmd.env("BOOTSTRAP_CARGO", &builder.initial_cargo);
15191519

1520+
cmd.arg("--channel").arg(&builder.config.channel);
1521+
15201522
builder.ci_env.force_coloring_in_ci(&mut cmd);
15211523

15221524
builder.info(&format!(

src/test/ui-fulldeps/session-derive-errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// check-fail
22
// Tests error conditions for specifying diagnostics using #[derive(SessionDiagnostic)]
33

4+
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
5+
// changing the output of this test. Since SessionDiagnostic is strictly internal to the compiler
6+
// the test is just ignored on stable and beta:
7+
// ignore-beta
8+
// ignore-stable
9+
410
#![feature(rustc_private)]
511
#![crate_type = "lib"]
612

src/test/ui-fulldeps/session-derive-errors.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[derive(SessionDiagnostic)]` can only be used on structs
2-
--> $DIR/session-derive-errors.rs:28:1
2+
--> $DIR/session-derive-errors.rs:34:1
33
|
44
LL | / #[error = "E0123"]
55
LL | |
@@ -10,51 +10,51 @@ LL | | }
1010
| |_^
1111

1212
error: `#[label = ...]` is not a valid SessionDiagnostic struct attribute
13-
--> $DIR/session-derive-errors.rs:37:1
13+
--> $DIR/session-derive-errors.rs:43:1
1414
|
1515
LL | #[label = "This is in the wrong place"]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
error: `#[suggestion = ...]` is not a valid SessionDiagnostic field attribute
19-
--> $DIR/session-derive-errors.rs:44:5
19+
--> $DIR/session-derive-errors.rs:50:5
2020
|
2121
LL | #[suggestion = "this is the wrong kind of attribute"]
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323

2424
error: `error` specified multiple times
25-
--> $DIR/session-derive-errors.rs:52:11
25+
--> $DIR/session-derive-errors.rs:58:11
2626
|
2727
LL | #[error = "E0456"]
2828
| ^^^^^^^
2929

3030
error: `lint` specified when `error` was already specified
31-
--> $DIR/session-derive-errors.rs:58:10
31+
--> $DIR/session-derive-errors.rs:64:10
3232
|
3333
LL | #[lint = "some_useful_lint"]
3434
| ^^^^^^^^^^^^^^^^^^
3535

3636
error: `code` not specified
37-
--> $DIR/session-derive-errors.rs:67:1
37+
--> $DIR/session-derive-errors.rs:73:1
3838
|
3939
LL | struct ErrorCodeNotProvided {}
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141
|
4242
= help: use the [code = "..."] attribute to set this diagnostic's error code
4343

4444
error: the `#[message = "..."]` attribute can only be applied to fields of type Span
45-
--> $DIR/session-derive-errors.rs:95:5
45+
--> $DIR/session-derive-errors.rs:101:5
4646
|
4747
LL | #[message = "this message is applied to a String field"]
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4949

5050
error: `name` doesn't refer to a field on this type
51-
--> $DIR/session-derive-errors.rs:102:1
51+
--> $DIR/session-derive-errors.rs:108:1
5252
|
5353
LL | #[message = "This error has a field, and references {name}"]
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5555

5656
error: invalid format string: expected `'}'` but string was terminated
57-
--> $DIR/session-derive-errors.rs:110:1
57+
--> $DIR/session-derive-errors.rs:116:1
5858
|
5959
LL | #[error = "E0123"]
6060
| - because of this opening brace
@@ -65,7 +65,7 @@ LL | #[message = "This is missing a closing brace: {name"]
6565
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
6666

6767
error: invalid format string: unmatched `}` found
68-
--> $DIR/session-derive-errors.rs:119:1
68+
--> $DIR/session-derive-errors.rs:125:1
6969
|
7070
LL | #[message = "This is missing an opening brace: name}"]
7171
| ^ unmatched `}` in format string
@@ -74,33 +74,33 @@ LL | #[message = "This is missing an opening brace: name}"]
7474
= note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
7575

7676
error: The `#[label = ...]` attribute can only be applied to fields of type Span
77-
--> $DIR/session-derive-errors.rs:138:5
77+
--> $DIR/session-derive-errors.rs:144:5
7878
|
7979
LL | #[label = "See here"]
8080
| ^^^^^^^^^^^^^^^^^^^^^
8181

8282
error: `nonsense` is not a valid key for `#[suggestion(...)]`
83-
--> $DIR/session-derive-errors.rs:163:18
83+
--> $DIR/session-derive-errors.rs:169:18
8484
|
8585
LL | #[suggestion(nonsense = "This is nonsense")]
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8787

8888
error: `msg` is not a valid key for `#[suggestion(...)]`
89-
--> $DIR/session-derive-errors.rs:171:18
89+
--> $DIR/session-derive-errors.rs:177:18
9090
|
9191
LL | #[suggestion(msg = "This is a suggestion")]
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9393

9494
error: missing suggestion message
95-
--> $DIR/session-derive-errors.rs:179:7
95+
--> $DIR/session-derive-errors.rs:185:7
9696
|
9797
LL | #[suggestion(code = "This is suggested code")]
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9999
|
100100
= help: provide a suggestion message using #[suggestion(message = "...")]
101101

102102
error: wrong field type for suggestion
103-
--> $DIR/session-derive-errors.rs:194:5
103+
--> $DIR/session-derive-errors.rs:200:5
104104
|
105105
LL | / #[suggestion(message = "This is a message", code = "This is suggested code")]
106106
LL | |
@@ -110,23 +110,23 @@ LL | | suggestion: Applicability,
110110
= help: #[suggestion(...)] should be applied to fields of type Span or (Span, Applicability)
111111

112112
error: type of field annotated with `#[suggestion(...)]` contains more than one Span
113-
--> $DIR/session-derive-errors.rs:209:5
113+
--> $DIR/session-derive-errors.rs:215:5
114114
|
115115
LL | / #[suggestion(message = "This is a message", code = "This is suggested code")]
116116
LL | |
117117
LL | | suggestion: (Span, Span, Applicability),
118118
| |___________________________________________^
119119

120120
error: type of field annotated with `#[suggestion(...)]` contains more than one Applicability
121-
--> $DIR/session-derive-errors.rs:217:5
121+
--> $DIR/session-derive-errors.rs:223:5
122122
|
123123
LL | / #[suggestion(message = "This is a message", code = "This is suggested code")]
124124
LL | |
125125
LL | | suggestion: (Applicability, Applicability, Span),
126126
| |____________________________________________________^
127127

128128
error: invalid annotation list `#[label(...)]`
129-
--> $DIR/session-derive-errors.rs:225:7
129+
--> $DIR/session-derive-errors.rs:231:7
130130
|
131131
LL | #[label("wrong kind of annotation for label")]
132132
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ pub struct Config {
346346
/// whether to run `tidy` when a rustdoc test fails
347347
pub has_tidy: bool,
348348

349+
/// The current Rust channel
350+
pub channel: String,
351+
349352
// Configuration for various run-make tests frobbing things like C compilers
350353
// or querying about various LLVM component information.
351354
pub cc: String,

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ impl Config {
876876
name == util::get_arch(&self.target) || // architecture
877877
name == util::get_pointer_width(&self.target) || // pointer width
878878
name == self.stage_id.split('-').next().unwrap() || // stage
879+
name == self.channel || // channel
879880
(self.target != self.host && name == "cross-compile") ||
880881
(name == "endian-big" && util::is_big_endian(&self.target)) ||
881882
(self.remote_test_client.is_some() && name == "remote") ||

src/tools/compiletest/src/header/tests.rs

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn config() -> Config {
5555
"--llvm-components=",
5656
"--android-cross-path=",
5757
"--target=x86_64-unknown-linux-gnu",
58+
"--channel=nightly",
5859
];
5960
let args = args.iter().map(ToString::to_string).collect();
6061
crate::parse_config(args)
@@ -234,6 +235,20 @@ fn asm_support() {
234235
assert!(!parse_rs(&config, "// needs-asm-support").ignore);
235236
}
236237

238+
#[test]
239+
fn channel() {
240+
let mut config = config();
241+
config.channel = "beta".into();
242+
243+
assert!(parse_rs(&config, "// ignore-beta").ignore);
244+
assert!(parse_rs(&config, "// only-nightly").ignore);
245+
assert!(parse_rs(&config, "// only-stable").ignore);
246+
247+
assert!(!parse_rs(&config, "// only-beta").ignore);
248+
assert!(!parse_rs(&config, "// ignore-nightly").ignore);
249+
assert!(!parse_rs(&config, "// ignore-stable").ignore);
250+
}
251+
237252
#[test]
238253
fn test_extract_version_range() {
239254
use super::{extract_llvm_version, extract_version_range};

src/tools/compiletest/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
144144
"enable this to generate a Rustfix coverage file, which is saved in \
145145
`./<build_base>/rustfix_missing_coverage.txt`",
146146
)
147-
.optflag("h", "help", "show this message");
147+
.optflag("h", "help", "show this message")
148+
.reqopt("", "channel", "current Rust channel", "CHANNEL");
148149

149150
let (argv0, args_) = args.split_first().unwrap();
150151
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
@@ -278,6 +279,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
278279
compare_mode: matches.opt_str("compare-mode").map(CompareMode::parse),
279280
rustfix_coverage: matches.opt_present("rustfix-coverage"),
280281
has_tidy,
282+
channel: matches.opt_str("channel").unwrap(),
281283

282284
cc: matches.opt_str("cc").unwrap(),
283285
cxx: matches.opt_str("cxx").unwrap(),

0 commit comments

Comments
 (0)