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.
This commit is contained in:
commit
14f33a5996
@ -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 {
|
||||
|
@ -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() {}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user