Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expect all help/note messages are specified in a cfail test #30778

Merged
merged 3 commits into from
Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, the logic here is that "if there is a help, then all help must be present", plus "if there is a note, then all notes must be present."

In hindsight I had thought that what we were discussing was "if there is either a help or a note, then all help and notes must be present."

I suspect that the logic you have chosen is actually more convenient in practice than what I was expecting, but I still figured I should point it out explicitly, in case someone else was as confused as I was about the proposal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks for making that clear. I probably should have been more specific in the description. By the way, is there a place to document this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pnkfelix:

In hindsight I had thought that what we were discussing was "if there is either a help or a note, then all help and notes must be present."

I actually wondered later which version we meant, and figured I'd probably be ok with either one...

@fhahn

By the way, is there a place to document this?

We've gone back and forth on this. I know that @brson has been working on making some kind of "wiki-like" page for compiler internal docs and the like, I'm not sure what's the current status on that? I'm not sure what happened to the existing docs on the compiletest infrastruture, but it seems like it should go in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Should we delay merging this PR until there's a place for the documentation?

ee.kind == "note:"));

fn prefix_matches(line: &str, prefix: &str) -> bool {
use std::ascii::AsciiExt;
// On windows just translate all '\' path separators to '/'
Expand Down Expand Up @@ -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);
}
Expand All @@ -1009,16 +1016,15 @@ 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(),
_ => line,
};

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) &&
Expand All @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/changing-crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
// 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
// aux-build:changing-crates-a2.rs

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() {}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/test/compile-fail/privacy1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-lit.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-significant-cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-significant-cfg.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-trait-bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-trait-bound.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-type-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-type-arg.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-type-ret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-type-ret.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-change-type-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// 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
// aux-build:svh-a-change-type-static.rs

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()
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/svh-use-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down