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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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
}

0 commit comments

Comments
 (0)