diff options
| author | bors <bors@rust-lang.org> | 2016-01-30 18:51:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-30 18:51:13 +0000 |
| commit | 14f33a5996054c817349c8ae95abbbe17347a6be (patch) | |
| tree | e34a52b52f29db4568470083d07d0225f28dd51c /src | |
| parent | 449e8bf3048d144fd5b82dd1a1a1060ff86b2877 (diff) | |
| parent | 526965aee54166dfba1b14b9bc475da8abcd66a3 (diff) | |
| download | rust-14f33a5996054c817349c8ae95abbbe17347a6be.tar.gz rust-14f33a5996054c817349c8ae95abbbe17347a6be.zip | |
Auto merge of #30778 - fhahn:issue-21195-expect-help, r=nikomatsakis
This is a PR for #21195. It changes the way unspecified `help` and `ǹote` messages are handled in compile-fail tests as suggested by @oli-obk in the issue: if there are some `note` or `help` annotations, there must be annotations for all `help` or `note` messages of this test. Maybe it makes also sense to add an option to specify that the this test should fail if there are unspecified `help` or `note` messages.
With this change, the following tests fail:
[compile-fail] compile-fail/changing-crates.rs
[compile-fail] compile-fail/default_ty_param_conflict_cross_crate.rs
[compile-fail] compile-fail/lifetime-inference-give-expl-lifetime-param.rs
[compile-fail] compile-fail/privacy1.rs
[compile-fail] compile-fail/svh-change-lit.rs
[compile-fail] compile-fail/svh-change-significant-cfg.rs
[compile-fail] compile-fail/svh-change-trait-bound.rs
[compile-fail] compile-fail/svh-change-type-arg.rs
[compile-fail] compile-fail/svh-change-type-ret.rs
[compile-fail] compile-fail/svh-change-type-static.rs
[compile-fail] compile-fail/svh-use-trait.rs
I'll add the missing annotations if we decide to accept this change.
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiletest/runtest.rs | 21 | ||||
| -rw-r--r-- | src/test/compile-fail/changing-crates.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/default_ty_param_conflict_cross_crate.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/privacy1.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-lit.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-significant-cfg.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-trait-bound.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-type-arg.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-type-ret.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-change-type-static.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/svh-use-trait.rs | 6 |
12 files changed, 63 insertions, 15 deletions
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index c7561248eb7..4abc4cce727 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -929,6 +929,13 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>, format!("{}:{}:", testfile.display(), ee.line) }).collect::<Vec<String>>(); + let (expect_help, expect_note) = + expected_errors.iter() + .fold((false, false), + |(acc_help, acc_note), ee| + (acc_help || ee.kind == "help:", acc_note || + ee.kind == "note:")); + fn prefix_matches(line: &str, prefix: &str) -> bool { use std::ascii::AsciiExt; // On windows just translate all '\' path separators to '/' @@ -992,8 +999,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>, was_expected = true; } - if !was_expected && is_compiler_error_or_warning(line) { - fatal_proc_rec(&format!("unexpected compiler error or warning: '{}'", + if !was_expected && is_unexpected_compiler_message(line, expect_help, expect_note) { + fatal_proc_rec(&format!("unexpected compiler message: '{}'", line), proc_res); } @@ -1009,7 +1016,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>, } } -fn is_compiler_error_or_warning(line: &str) -> bool { +fn is_unexpected_compiler_message(line: &str, expect_help: bool, expect_note: bool) -> bool { let mut c = Path::new(line).components(); let line = match c.next() { Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(), @@ -1017,8 +1024,7 @@ fn is_compiler_error_or_warning(line: &str) -> bool { }; let mut i = 0; - return - scan_until_char(line, ':', &mut i) && + return scan_until_char(line, ':', &mut i) && scan_char(line, ':', &mut i) && scan_integer(line, &mut i) && scan_char(line, ':', &mut i) && @@ -1030,7 +1036,10 @@ fn is_compiler_error_or_warning(line: &str) -> bool { scan_integer(line, &mut i) && scan_char(line, ' ', &mut i) && (scan_string(line, "error", &mut i) || - scan_string(line, "warning", &mut i)); + scan_string(line, "warning", &mut i) || + (expect_help && scan_string(line, "help", &mut i)) || + (expect_note && scan_string(line, "note", &mut i)) + ); } fn scan_until_char(haystack: &str, needle: char, idx: &mut usize) -> bool { diff --git a/src/test/compile-fail/changing-crates.rs b/src/test/compile-fail/changing-crates.rs index ae3ef760667..0b420158488 100644 --- a/src/test/compile-fail/changing-crates.rs +++ b/src/test/compile-fail/changing-crates.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:changing-crates-a1.rs // aux-build:changing-crates-b.rs @@ -15,6 +17,8 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() {} diff --git a/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs b/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs index 4d60724372a..fc2c49d65af 100644 --- a/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs +++ b/src/test/compile-fail/default_ty_param_conflict_cross_crate.rs @@ -26,4 +26,5 @@ fn main() { meh(foo); //~^ ERROR: mismatched types: //~| NOTE: conflicting type parameter defaults `bool` and `char` + //~| NOTE: ...that was applied to an unconstrained type variable here } diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs index a85776a938b..e32ed1c42a0 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs @@ -49,6 +49,7 @@ struct Baz<'x> { impl<'a> Baz<'a> { fn baz2<'b>(&self, x: &isize) -> (&'b isize, &'b isize) { + //~^ HELP: parameter as shown: fn baz2<'b>(&self, x: &'b isize) -> (&'a isize, &'a isize) // The lifetime that gets assigned to `x` seems somewhat random. // I have disabled this test for the time being. --pcwalton (self.bar, x) //~ ERROR: cannot infer diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 593068c2aea..495cdc3fe62 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -129,12 +129,17 @@ mod foo { ::bar::baz::foo(); //~ ERROR: function `foo` is inaccessible //~^ NOTE: module `baz` is private ::bar::baz::bar(); //~ ERROR: function `bar` is inaccessible + //~^ NOTE: module `baz` is private } fn test2() { use bar::baz::{foo, bar}; //~^ ERROR: function `foo` is inaccessible - //~^^ ERROR: function `bar` is inaccessible + //~| NOTE: module `baz` is private + //~| ERROR: function `bar` is inaccessible + //~| NOTE: module `baz` is private + + foo(); bar(); } diff --git a/src/test/compile-fail/svh-change-lit.rs b/src/test/compile-fail/svh-change-lit.rs index c839ade75cf..eb92bcf065d 100644 --- a/src/test/compile-fail/svh-change-lit.rs +++ b/src/test/compile-fail/svh-change-lit.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-significant-cfg.rs b/src/test/compile-fail/svh-change-significant-cfg.rs index df0adf36ce2..7c9e0d3a92c 100644 --- a/src/test/compile-fail/svh-change-significant-cfg.rs +++ b/src/test/compile-fail/svh-change-significant-cfg.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-trait-bound.rs b/src/test/compile-fail/svh-change-trait-bound.rs index 4774384fecd..1e6a7232904 100644 --- a/src/test/compile-fail/svh-change-trait-bound.rs +++ b/src/test/compile-fail/svh-change-trait-bound.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-arg.rs b/src/test/compile-fail/svh-change-type-arg.rs index 51d3fd0a73a..73c35ee6f82 100644 --- a/src/test/compile-fail/svh-change-type-arg.rs +++ b/src/test/compile-fail/svh-change-type-arg.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-ret.rs b/src/test/compile-fail/svh-change-type-ret.rs index 609e0f3689e..b8908e2cbd1 100644 --- a/src/test/compile-fail/svh-change-type-ret.rs +++ b/src/test/compile-fail/svh-change-type-ret.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-change-type-static.rs b/src/test/compile-fail/svh-change-type-static.rs index c42714609b6..291e441aa5e 100644 --- a/src/test/compile-fail/svh-change-type-static.rs +++ b/src/test/compile-fail/svh-change-type-static.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-a-base.rs // aux-build:svh-b.rs @@ -15,7 +17,9 @@ extern crate a; extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled +//~| NOTE: crate `a` path #1: +//~| NOTE: crate `b` path #1: fn main() { b::foo() diff --git a/src/test/compile-fail/svh-use-trait.rs b/src/test/compile-fail/svh-use-trait.rs index 7fdbf35fc6d..ed816a93c52 100644 --- a/src/test/compile-fail/svh-use-trait.rs +++ b/src/test/compile-fail/svh-use-trait.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-msvc FIXME #31306 + // note that these aux-build directives must be in this order // aux-build:svh-uta-base.rs // aux-build:svh-utb.rs @@ -20,7 +22,9 @@ extern crate uta; extern crate utb; //~ ERROR: found possibly newer version of crate `uta` which `utb` depends -//~^ NOTE: perhaps this crate needs to be recompiled +//~| NOTE: perhaps this crate needs to be recompiled? +//~| NOTE: crate `uta` path #1: +//~| NOTE: crate `utb` path #1: fn main() { utb::foo() |
