Skip to content

Commit be989ac

Browse files
committed
Auto merge of #32263 - frewsxcv:compiletest-ignored-expected, r=nikomatsakis
Stop ignoring expected note/help messages in compiletest suite. Original issue: #21195 Relevant PR: #30778 Prior to this commit, if a compiletest testcase included the text "HELP:" or "NOTE:" (note the colons), then it would indicate to the compiletest suite that we should verify "help" and "note" expected messages. This commit updates this check to also check "HELP" and "NOTE" (not the absense of colons) so that we always verify "help" and "note" expected messages.
2 parents abb1515 + abd1cea commit be989ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+141
-6
lines changed

src/compiletest/runtest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1013,8 +1013,8 @@ fn check_expected_errors(revision: Option<&str>,
10131013
expected_errors.iter()
10141014
.fold((false, false),
10151015
|(acc_help, acc_note), ee|
1016-
(acc_help || ee.kind == "help:", acc_note ||
1017-
ee.kind == "note:"));
1016+
(acc_help || ee.kind == "help:" || ee.kind == "help",
1017+
acc_note || ee.kind == "note:" || ee.kind == "note"));
10181018

10191019
// Scan and extract our error/warning messages,
10201020
// which look like:

src/test/compile-fail/asm-out-assign-imm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn main() {
2323
unsafe {
2424
asm!("mov $1, $0" : "=r"(x) : "r"(5));
2525
//~^ ERROR re-assignment of immutable variable `x`
26+
//~| NOTE in this expansion of asm!
2627
}
2728
foo(x);
2829
}

src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs

+17
Original file line numberDiff line numberDiff line change
@@ -54,80 +54,97 @@ fn borrow_after_move() {
5454
fn move_after_borrow() {
5555
let a: Box<_> = box B { x: box 0, y: box 1 };
5656
let _x = &a.x;
57+
//~^ NOTE borrow of `a.x` occurs here
5758
let _y = a.y; //~ ERROR cannot move
5859
}
5960

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

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

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

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

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

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

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

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

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

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

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

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

132149
fn main() {
133150
copy_after_move();

src/test/compile-fail/borrowck/borrowck-let-suggestion.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn f() {
1212
let x = [1].iter(); //~ ERROR borrowed value does not live long enough
1313
//~^ NOTE reference must be valid for the block suffix following statement
1414
//~^^ HELP consider using a `let` binding to increase its lifetime
15+
//~^^^ NOTE ...but borrowed value is only valid for the statement at 12:4
1516
}
1617

1718
fn main() {

src/test/compile-fail/borrowck/borrowck-report-with-custom-diagnostic.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn main() {
1313
// Original borrow ends at end of function
1414
let mut x = 1;
1515
let y = &mut x;
16+
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
1617
let z = &x; //~ ERROR cannot borrow
1718
}
1819
//~^ NOTE previous borrow ends here
@@ -23,6 +24,7 @@ fn foo() {
2324
// Original borrow ends at end of match arm
2425
let mut x = 1;
2526
let y = &x;
27+
//~^ previous borrow of `x` occurs here; the immutable borrow prevents
2628
let z = &mut x; //~ ERROR cannot borrow
2729
}
2830
//~^ NOTE previous borrow ends here
@@ -35,6 +37,7 @@ fn bar() {
3537
|| {
3638
let mut x = 1;
3739
let y = &mut x;
40+
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
3841
let z = &mut x; //~ ERROR cannot borrow
3942
};
4043
//~^ NOTE previous borrow ends here

src/test/compile-fail/borrowck/borrowck-vec-pattern-nesting.rs

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn a() {
1717
let mut vec = [box 1, box 2, box 3];
1818
match vec {
1919
[box ref _a, _, _] => {
20+
//~^ borrow of `vec[..]` occurs here
2021
vec[0] = box 4; //~ ERROR cannot assign
2122
}
2223
}
@@ -27,6 +28,7 @@ fn b() {
2728
let vec: &mut [Box<isize>] = &mut vec;
2829
match vec {
2930
[_b..] => {
31+
//~^ borrow of `vec[..]` occurs here
3032
vec[0] = box 4; //~ ERROR cannot assign
3133
}
3234
}
@@ -48,6 +50,7 @@ fn c() {
4850
_ => {}
4951
}
5052
let a = vec[0]; //~ ERROR cannot move out
53+
//~^ NOTE attempting to move value to here
5154
}
5255

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

6468
fn e() {

src/test/compile-fail/cast-as-bool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ fn main() {
1212
let u = 5 as bool;
1313
//~^ ERROR cannot cast as `bool`
1414
//~^^ HELP compare with zero instead
15+
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
1516
}

src/test/compile-fail/cast-rfc0401.rs

+8
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ fn main()
6161
let _ = 3 as bool;
6262
//~^ ERROR cannot cast as `bool`
6363
//~^^ HELP compare with zero
64+
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
6465
let _ = E::A as bool;
6566
//~^ ERROR cannot cast as `bool`
6667
//~^^ HELP compare with zero
68+
//~^^^ HELP run `rustc --explain E0054` to see a detailed explanation
6769
let _ = 0x61u32 as char; //~ ERROR only `u8` can be cast
6870

6971
let _ = false as f32;
@@ -90,6 +92,9 @@ fn main()
9092
let _ = v as *const [u8]; //~ ERROR cannot cast
9193
let _ = fat_v as *const Foo;
9294
//~^ ERROR `core::marker::Sized` is not implemented for the type `[u8]`
95+
//~^^ HELP run `rustc --explain E0277` to see a detailed explanation
96+
//~^^^ NOTE `[u8]` does not have a constant size known at compile-time
97+
//~^^^^ NOTE required for the cast to the object type `Foo`
9398
let _ = foo as *const str; //~ ERROR casting
9499
let _ = foo as *mut str; //~ ERROR casting
95100
let _ = main as *mut str; //~ ERROR casting
@@ -102,6 +107,9 @@ fn main()
102107
let a : *const str = "hello";
103108
let _ = a as *const Foo;
104109
//~^ ERROR `core::marker::Sized` is not implemented for the type `str`
110+
//~^^ HELP run `rustc --explain E0277` to see a detailed explanation
111+
//~^^^ NOTE `str` does not have a constant size known at compile-time
112+
//~^^^^ NOTE required for the cast to the object type `Foo`
105113

106114
// check no error cascade
107115
let _ = main.f as *const u32; //~ ERROR attempted access of field

src/test/compile-fail/fat-ptr-cast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
let q = a.as_ptr();
1919

2020
a as usize; //~ ERROR casting
21+
//~^ HELP cast through a raw pointer first
2122
b as usize; //~ ERROR non-scalar cast
2223
p as usize;
2324
//~^ ERROR casting

src/test/compile-fail/feature-gate-negate-unsigned.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ const _MAX: usize = -1;
2323
fn main() {
2424
let x = 5u8;
2525
let _y = -x; //~ ERROR unary negation of unsigned integer
26+
//~^ HELP use a cast or the `!` operator
2627
-S; // should not trigger the gate; issue 26840
2728
}

src/test/compile-fail/issue-11714.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

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

1415
; //~ HELP consider removing this semicolon:

src/test/compile-fail/issue-13058.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ fn main() {
4040
//~| found `(_, _)`
4141
//~| expected &-ptr
4242
//~| found tuple
43+
//~| HELP run `rustc --explain E0308` to see a detailed explanation
4344
}

src/test/compile-fail/issue-13428.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// Regression test for #13428
1212

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

2122
fn bar() -> String { //~ ERROR not all control paths return a value
23+
//~^ HELP run `rustc --explain E0269` to see a detailed explanation
2224
"foobar".to_string()
2325
; //~ HELP consider removing this semicolon
2426
}

src/test/compile-fail/issue-15260.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn main() {
2525

2626
let Foo {
2727
a, //~ NOTE field `a` previously bound here
28+
//~^ NOTE field `a` previously bound here
2829
a: _, //~ ERROR field `a` bound multiple times in the pattern
2930
a: x //~ ERROR field `a` bound multiple times in the pattern
3031
} = Foo { a: 29 };

src/test/compile-fail/issue-16747.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct List<'a, T: ListItem<'a>> {
1919
//~^ ERROR the parameter type `T` may not live long enough
2020
//~| HELP consider adding an explicit lifetime bound
2121
//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
22+
//~| HELP run `rustc --explain E0309` to see a detailed explanation
2223
}
2324
impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
2425
fn len(&self) -> usize {

src/test/compile-fail/issue-17263.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ fn main() {
2323
//~^ ERROR cannot borrow `foo` (here through borrowing `foo.b`) as immutable
2424
//~^^ NOTE previous borrow of `foo` occurs here (through borrowing `foo.a`)
2525
}
26+
//~^ NOTE previous borrow ends here
27+
//~^^ NOTE previous borrow ends here

src/test/compile-fail/issue-19707.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313

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

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

2022
fn main() {}

src/test/compile-fail/issue-21221-1.rs

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ impl Mul for Foo {
5555
//~| HELP `mul1::Mul`
5656
//~| HELP `mul2::Mul`
5757
//~| HELP `std::ops::Mul`
58+
//~| HELP run `rustc --explain E0405` to see a detailed explanation
59+
//~| HELP you can import several candidates into scope (`use ...;`):
5860
}
5961

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

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

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

9198
fn main() {

src/test/compile-fail/issue-21221-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ struct Foo;
2828
impl T for Foo { }
2929
//~^ ERROR trait `T` is not in scope
3030
//~| HELP you can to import it into scope: `use foo::bar::T;`.
31+
//~| HELP run `rustc --explain E0405` to see a detailed explanation

src/test/compile-fail/issue-21221-3.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct Foo;
2525
impl OuterTrait for Foo {}
2626
//~^ ERROR trait `OuterTrait` is not in scope
2727
//~| HELP you can to import it into scope: `use issue_21221_3::outer::OuterTrait;`.
28+
//~| HELP run `rustc --explain E0405` to see a detailed explanation
2829
fn main() {
2930
println!("Hello, world!");
3031
}

src/test/compile-fail/issue-21221-4.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct Foo;
2020
impl T for Foo {}
2121
//~^ ERROR trait `T` is not in scope
2222
//~| HELP you can to import it into scope: `use issue_21221_4::T;`.
23+
//~| HELP run `rustc --explain E0405` to see a detailed explanation
2324

2425
fn main() {
2526
println!("Hello, world!");

src/test/compile-fail/issue-21600.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ fn main() {
2323
call_it(|| x.gen());
2424
call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer
2525
//~^ ERROR cannot borrow data mutably in a captured outer
26+
//~^^ HELP run `rustc --explain E0387` to see a detailed explanation
27+
//~^^^ HELP run `rustc --explain E0387` to see a detailed explanation
28+
//~^^^^ HELP consider changing this closure to take self by mutable reference
2629
});
2730
}

src/test/compile-fail/issue-24036.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ fn closure_to_loc() {
1414
//~^ ERROR mismatched types
1515
//~| NOTE no two closures, even if identical, have the same type
1616
//~| HELP consider boxing your closure and/or using it as a trait object
17+
//~| HELP run `rustc --explain E0308` to see a detailed explanation
1718
}
1819

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

3033
fn main() { }

src/test/compile-fail/issue-25385.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ fn main() {
2121

2222
foo!(1i32.foo());
2323
//~^ ERROR no method named `foo` found for type `i32` in the current scope
24+
//~^^ NOTE in this expansion of foo!
2425
}

src/test/compile-fail/issue-25386.rs

-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ macro_rules! check_ptr_exist {
3535
fn main() {
3636
let item = stuff::Item::new();
3737
println!("{}", check_ptr_exist!(item, name));
38-
//~^ NOTE in this expansion of check_ptr_exist!
39-
//~^^ NOTE in this expansion of check_ptr_exist!
4038
}

0 commit comments

Comments
 (0)