Skip to content

Commit 8baad70

Browse files
authored
Rollup merge of #147934 - Zalathar:directive, r=jieyouxu
compiletest: More directive handling tweaks - Follow-up to #147903. --- These are some more preparatory changes that were extracted from a larger overhaul of directive handling that I'm still working on. --- The revision check was introduced by #61778, and later modified by #113603. It doesn't appear to be doing anything particularly load-bearing (since a bogus mode seems to cause a panic later anyway), and getting rid of it avoids the need to pass the current test revision to directive-handling code. - #61778 - #113603 r? jieyouxu
2 parents e2110d8 + 860a84c commit 8baad70

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/tools/compiletest/src/directives.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ mod directives {
256256
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
257257
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
258258
pub const CORE_STUBS_COMPILE_FLAGS: &'static str = "core-stubs-compile-flags";
259-
// This isn't a real directive, just one that is probably mistyped often
260-
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
261259
pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
262260
pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines";
263261
}
@@ -418,9 +416,6 @@ impl TestProps {
418416
}
419417
self.compile_flags.extend(flags);
420418
}
421-
if config.parse_name_value_directive(ln, INCORRECT_COMPILER_FLAGS).is_some() {
422-
panic!("`compiler-flags` directive should be spelled `compile-flags`");
423-
}
424419

425420
if let Some(range) = parse_edition_range(config, ln) {
426421
self.edition = Some(range.edition_to_test(config.edition));
@@ -504,7 +499,7 @@ impl TestProps {
504499
&mut self.check_test_line_numbers_match,
505500
);
506501

507-
self.update_pass_mode(ln, test_revision, config);
502+
self.update_pass_mode(ln, config);
508503
self.update_fail_mode(ln, config);
509504

510505
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
@@ -686,9 +681,6 @@ impl TestProps {
686681
panic!("`{}-fail` directive is only supported in UI tests", mode);
687682
}
688683
};
689-
if config.mode == TestMode::Ui && config.parse_name_directive(ln, "compile-fail") {
690-
panic!("`compile-fail` directive is useless in UI tests");
691-
}
692684
let fail_mode = if config.parse_name_directive(ln, "check-fail") {
693685
check_ui("check");
694686
Some(FailMode::Check)
@@ -714,18 +706,15 @@ impl TestProps {
714706
}
715707
}
716708

717-
fn update_pass_mode(
718-
&mut self,
719-
ln: &DirectiveLine<'_>,
720-
revision: Option<&str>,
721-
config: &Config,
722-
) {
709+
fn update_pass_mode(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
723710
let check_no_run = |s| match (config.mode, s) {
724711
(TestMode::Ui, _) => (),
725712
(TestMode::Crashes, _) => (),
726713
(TestMode::Codegen, "build-pass") => (),
727714
(TestMode::Incremental, _) => {
728-
if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) {
715+
// FIXME(Zalathar): This only detects forbidden directives that are
716+
// declared _after_ the incompatible `//@ revisions:` directive(s).
717+
if self.revisions.iter().any(|r| !r.starts_with("cfail")) {
729718
panic!("`{s}` directive is only supported in `cfail` incremental tests")
730719
}
731720
}
@@ -812,6 +801,11 @@ fn check_directive<'a>(
812801
.map(|remark| remark.trim_start().split(' ').next().unwrap())
813802
.filter(|token| KNOWN_DIRECTIVE_NAMES.contains(token));
814803

804+
// FIXME(Zalathar): Consider emitting specialized error/help messages for
805+
// bogus directive names that are similar to real ones, e.g.:
806+
// - *`compiler-flags` => `compile-flags`
807+
// - *`compile-fail` => `check-fail` or `build-fail`
808+
815809
CheckDirectiveResult { is_known_directive, trailing_directive }
816810
}
817811

0 commit comments

Comments
 (0)