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

Stop ignoring expected note/help messages in compiletest suite. #32263

Merged
merged 1 commit into from
Mar 17, 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
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ fn check_expected_errors(revision: Option<&str>,
expected_errors.iter()
.fold((false, false),
Copy link
Contributor

Choose a reason for hiding this comment

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

Pre-existing, but can't we use any here instead of fold? Seems like it more clearly expresses the intent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Given this code block:

fn main() {
  let i = 1; //~ NOTE: some note
  let j = 2; //~ HELP: some help 
}

The current implementation checks for note and help in one pass through. I'm not sure how it'd be possible using any unless we were expecting both help and note on the same line. I agree it's not clean, and I'm willing to clean it up, but would rather do that in a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do it in two passes?

On Wed, Mar 16, 2016 at 12:25:23PM -0700, Corey Farwell wrote:

@@ -1013,8 +1013,8 @@ fn check_expected_errors(revision: Option<&str>,
expected_errors.iter()
.fold((false, false),

Given this code block:

fn main() {
  let i = 1; //~ NOTE: some note
  let j = 2; //~ HELP: some help 
}

The current implementation checks for note and help in one pass through. I'm not sure how it'd be possible using any unless we were expecting both help and note on the same line. I agree it's not clean, and I'm willing to clean it up, but would rather do that in a different PR.


You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub:
https://github.com/rust-lang/rust/pull/32263/files/fb96cc8b5d83da8c32cdaf51a5f53edb74152024#r56398787

Copy link
Member Author

Choose a reason for hiding this comment

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

Spoke with you on IRC. Going to do it in a follow-up PR.

|(acc_help, acc_note), ee|
(acc_help || ee.kind == "help:", acc_note ||
ee.kind == "note:"));
(acc_help || ee.kind == "help:" || ee.kind == "help",
acc_note || ee.kind == "note:" || ee.kind == "note"));
Copy link
Member Author

Choose a reason for hiding this comment

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

I have a separate branch that cleans up this "kind" logic by using enums. I plan to open it up as a follow-up PR if this merges.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should make the opt-in work for note and help as well, but it is still opt-in and notes and help messages are only checked in files with help and note annotations.

When making this changes, it seems like I overlooked note and help (and assumed there is more normalization going on). I think using enums there would make it clearer 👍


// Scan and extract our error/warning messages,
// which look like:
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/asm-out-assign-imm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn main() {
unsafe {
asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR re-assignment of immutable variable `x`
//~| NOTE in this expansion of asm!
}
foo(x);
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,80 +54,97 @@ fn borrow_after_move() {
fn move_after_borrow() {
let a: Box<_> = box B { x: box 0, y: box 1 };
let _x = &a.x;
//~^ NOTE borrow of `a.x` occurs here
let _y = a.y; //~ ERROR cannot move
}

fn copy_after_mut_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let _x = &mut a.x;
//~^ NOTE borrow of `a.x` occurs here
let _y = a.y; //~ ERROR cannot use
}

fn move_after_mut_borrow() {
let mut a: Box<_> = box B { x: box 0, y: box 1 };
let _x = &mut a.x;
//~^ NOTE borrow of `a.x` occurs here
let _y = a.y; //~ ERROR cannot move
}

fn borrow_after_mut_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let _x = &mut a.x;
//~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`);
let _y = &a.y; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here

fn mut_borrow_after_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let _x = &a.x;
//~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`)
let _y = &mut a.y; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here

fn copy_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
let _y = a.y; //~ ERROR use of collaterally moved
}

fn move_after_move_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
let _y = a.y; //~ ERROR use of collaterally moved
}

fn borrow_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
let _y = &a.y; //~ ERROR use of collaterally moved
}

fn move_after_borrow_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let _x = &a.x.x;
//~^ NOTE borrow of `a.x.x` occurs here
let _y = a.y; //~ ERROR cannot move
}

fn copy_after_mut_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = &mut a.x.x;
//~^ NOTE borrow of `a.x.x` occurs here
let _y = a.y; //~ ERROR cannot use
}

fn move_after_mut_borrow_nested() {
let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let _x = &mut a.x.x;
//~^ NOTE borrow of `a.x.x` occurs here
let _y = a.y; //~ ERROR cannot move
}

fn borrow_after_mut_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = &mut a.x.x;
//~^ NOTE previous borrow of `a.x.x` occurs here; the mutable borrow prevents
let _y = &a.y; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here

fn mut_borrow_after_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = &a.x.x;
//~^ NOTE previous borrow of `a.x.x` occurs here; the immutable borrow prevents
let _y = &mut a.y; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here

fn main() {
copy_after_move();
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck/borrowck-let-suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn f() {
let x = [1].iter(); //~ ERROR borrowed value does not live long enough
//~^ NOTE reference must be valid for the block suffix following statement
//~^^ HELP consider using a `let` binding to increase its lifetime
//~^^^ NOTE ...but borrowed value is only valid for the statement at 12:4
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn main() {
// Original borrow ends at end of function
let mut x = 1;
let y = &mut x;
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
let z = &x; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here
Expand All @@ -23,6 +24,7 @@ fn foo() {
// Original borrow ends at end of match arm
let mut x = 1;
let y = &x;
//~^ previous borrow of `x` occurs here; the immutable borrow prevents
let z = &mut x; //~ ERROR cannot borrow
}
//~^ NOTE previous borrow ends here
Expand All @@ -35,6 +37,7 @@ fn bar() {
|| {
let mut x = 1;
let y = &mut x;
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
let z = &mut x; //~ ERROR cannot borrow
};
//~^ NOTE previous borrow ends here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fn a() {
let mut vec = [box 1, box 2, box 3];
match vec {
[box ref _a, _, _] => {
//~^ borrow of `vec[..]` occurs here
vec[0] = box 4; //~ ERROR cannot assign
}
}
Expand All @@ -27,6 +28,7 @@ fn b() {
let vec: &mut [Box<isize>] = &mut vec;
match vec {
[_b..] => {
//~^ borrow of `vec[..]` occurs here
vec[0] = box 4; //~ ERROR cannot assign
}
}
Expand All @@ -48,6 +50,7 @@ fn c() {
_ => {}
}
let a = vec[0]; //~ ERROR cannot move out
//~^ NOTE attempting to move value to here
}

fn d() {
Expand All @@ -59,6 +62,7 @@ fn d() {
_ => {}
}
let a = vec[0]; //~ ERROR cannot move out
//~^ NOTE attempting to move value to here
}

fn e() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/cast-as-bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ fn main() {
let u = 5 as bool;
//~^ ERROR cannot cast as `bool`
//~^^ HELP compare with zero instead
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
}
8 changes: 8 additions & 0 deletions src/test/compile-fail/cast-rfc0401.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ fn main()
let _ = 3 as bool;
//~^ ERROR cannot cast as `bool`
//~^^ HELP compare with zero
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
let _ = E::A as bool;
//~^ ERROR cannot cast as `bool`
//~^^ HELP compare with zero
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
let _ = 0x61u32 as char; //~ ERROR only `u8` can be cast

let _ = false as f32;
Expand All @@ -90,6 +92,9 @@ fn main()
let _ = v as *const [u8]; //~ ERROR cannot cast
let _ = fat_v as *const Foo;
//~^ ERROR `core::marker::Sized` is not implemented for the type `[u8]`
//~^^ HELP run `rustc --explain E0277` to see a detailed explanation
//~^^^ NOTE `[u8]` does not have a constant size known at compile-time
//~^^^^ NOTE required for the cast to the object type `Foo`
let _ = foo as *const str; //~ ERROR casting
let _ = foo as *mut str; //~ ERROR casting
let _ = main as *mut str; //~ ERROR casting
Expand All @@ -102,6 +107,9 @@ fn main()
let a : *const str = "hello";
let _ = a as *const Foo;
//~^ ERROR `core::marker::Sized` is not implemented for the type `str`
//~^^ HELP run `rustc --explain E0277` to see a detailed explanation
//~^^^ NOTE `str` does not have a constant size known at compile-time
//~^^^^ NOTE required for the cast to the object type `Foo`

// check no error cascade
let _ = main.f as *const u32; //~ ERROR attempted access of field
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/fat-ptr-cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() {
let q = a.as_ptr();

a as usize; //~ ERROR casting
//~^ HELP cast through a raw pointer first
b as usize; //~ ERROR non-scalar cast
p as usize;
//~^ ERROR casting
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/feature-gate-negate-unsigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ const _MAX: usize = -1;
fn main() {
let x = 5u8;
let _y = -x; //~ ERROR unary negation of unsigned integer
//~^ HELP use a cast or the `!` operator
-S; // should not trigger the gate; issue 26840
}
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-11714.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

fn blah() -> i32 { //~ ERROR not all control paths return a value
//~^ HELP run `rustc --explain E0269` to see a detailed explanation
1

; //~ HELP consider removing this semicolon:
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-13058.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ fn main() {
//~| found `(_, _)`
//~| expected &-ptr
//~| found tuple
//~| HELP run `rustc --explain E0308` to see a detailed explanation
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-13428.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// Regression test for #13428

fn foo() -> String { //~ ERROR not all control paths return a value
//~^ HELP run `rustc --explain E0269` to see a detailed explanation
format!("Hello {}",
"world")
// Put the trailing semicolon on its own line to test that the
Expand All @@ -19,6 +20,7 @@ fn foo() -> String { //~ ERROR not all control paths return a value
}

fn bar() -> String { //~ ERROR not all control paths return a value
//~^ HELP run `rustc --explain E0269` to see a detailed explanation
"foobar".to_string()
; //~ HELP consider removing this semicolon
}
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-15260.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn main() {

let Foo {
a, //~ NOTE field `a` previously bound here
//~^ NOTE field `a` previously bound here
a: _, //~ ERROR field `a` bound multiple times in the pattern
a: x //~ ERROR field `a` bound multiple times in the pattern
} = Foo { a: 29 };
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-16747.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct List<'a, T: ListItem<'a>> {
//~^ ERROR the parameter type `T` may not live long enough
//~| HELP consider adding an explicit lifetime bound
//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
//~| HELP run `rustc --explain E0309` to see a detailed explanation
}
impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
fn len(&self) -> usize {
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-17263.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ fn main() {
//~^ ERROR cannot borrow `foo` (here through borrowing `foo.b`) as immutable
//~^^ NOTE previous borrow of `foo` occurs here (through borrowing `foo.a`)
}
//~^ NOTE previous borrow ends here
//~^^ NOTE previous borrow ends here
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-19707.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

type foo = fn(&u8, &u8) -> &u8; //~ ERROR missing lifetime specifier
//~^ HELP the signature does not say whether it is borrowed from argument 1 or argument 2
//~^^ HELP run `rustc --explain E0106` to see a detailed explanation

fn bar<F: Fn(&u8, &u8) -> &u8>(f: &F) {} //~ ERROR missing lifetime specifier
//~^ HELP the signature does not say whether it is borrowed from argument 1 or argument 2
//~^^ HELP run `rustc --explain E0106` to see a detailed explanation

fn main() {}
7 changes: 7 additions & 0 deletions src/test/compile-fail/issue-21221-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl Mul for Foo {
//~| HELP `mul1::Mul`
//~| HELP `mul2::Mul`
//~| HELP `std::ops::Mul`
//~| HELP run `rustc --explain E0405` to see a detailed explanation
//~| HELP you can import several candidates into scope (`use ...;`):
}

// BEFORE, we got:
Expand All @@ -75,17 +77,22 @@ fn getMul() -> Mul {
//~| HELP `mul3::Mul`
//~| HELP `mul4::Mul`
//~| HELP and 2 other candidates
//~| HELP run `rustc --explain E0412` to see a detailed explanation
//~| HELP you can import several candidates into scope (`use ...;`):
}

// Let's also test what happens if the trait doesn't exist:
impl ThisTraitReallyDoesntExistInAnyModuleReally for Foo {
//~^ ERROR trait `ThisTraitReallyDoesntExistInAnyModuleReally` is not in scope
//~^^ HELP run `rustc --explain E0405` to see a detailed explanation
//~^^^ HELP no candidates by the name of `ThisTraitReallyDoesntExistInAnyModuleReally` found
}

// Let's also test what happens if there's just one alternative:
impl Div for Foo {
//~^ ERROR trait `Div` is not in scope
//~| HELP `use std::ops::Div;`
//~| HELP run `rustc --explain E0405` to see a detailed explanation
}

fn main() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-21221-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ struct Foo;
impl T for Foo { }
//~^ ERROR trait `T` is not in scope
//~| HELP you can to import it into scope: `use foo::bar::T;`.
//~| HELP run `rustc --explain E0405` to see a detailed explanation
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-21221-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct Foo;
impl OuterTrait for Foo {}
//~^ ERROR trait `OuterTrait` is not in scope
//~| HELP you can to import it into scope: `use issue_21221_3::outer::OuterTrait;`.
//~| HELP run `rustc --explain E0405` to see a detailed explanation
fn main() {
println!("Hello, world!");
}
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-21221-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct Foo;
impl T for Foo {}
//~^ ERROR trait `T` is not in scope
//~| HELP you can to import it into scope: `use issue_21221_4::T;`.
//~| HELP run `rustc --explain E0405` to see a detailed explanation

fn main() {
println!("Hello, world!");
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/issue-21600.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ fn main() {
call_it(|| x.gen());
call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer
//~^ ERROR cannot borrow data mutably in a captured outer
//~^^ HELP run `rustc --explain E0387` to see a detailed explanation
//~^^^ HELP run `rustc --explain E0387` to see a detailed explanation
//~^^^^ HELP consider changing this closure to take self by mutable reference
});
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/issue-24036.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ fn closure_to_loc() {
//~^ ERROR mismatched types
//~| NOTE no two closures, even if identical, have the same type
//~| HELP consider boxing your closure and/or using it as a trait object
//~| HELP run `rustc --explain E0308` to see a detailed explanation
}

fn closure_from_match() {
let x = match 1usize {
1 => |c| c + 1,
2 => |c| c - 1,
//~^ NOTE match arm with an incompatible type
_ => |c| c - 1
};
//~^^^^^ ERROR match arms have incompatible types
//~^^^^^^ ERROR match arms have incompatible types
//~| NOTE no two closures, even if identical, have the same type
//~| HELP consider boxing your closure and/or using it as a trait object
//~| HELP run `rustc --explain E0308` to see a detailed explanation
}

fn main() { }
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-25385.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ fn main() {

foo!(1i32.foo());
//~^ ERROR no method named `foo` found for type `i32` in the current scope
//~^^ NOTE in this expansion of foo!
}
2 changes: 0 additions & 2 deletions src/test/compile-fail/issue-25386.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ macro_rules! check_ptr_exist {
fn main() {
let item = stuff::Item::new();
println!("{}", check_ptr_exist!(item, name));
//~^ NOTE in this expansion of check_ptr_exist!
//~^^ NOTE in this expansion of check_ptr_exist!
}
Loading