Skip to content

Commit fd854a7

Browse files
committed
compiletest: Avoid ignoring empty diagnostics in one more place
This catches some silly notes emitted by rustc, which should ideally be fixed
1 parent 5c160f5 commit fd854a7

12 files changed

+27
-18
lines changed

src/tools/compiletest/src/runtest.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,7 @@ impl<'test> TestCx<'test> {
810810
expect_help: bool,
811811
expect_note: bool,
812812
) -> bool {
813-
!actual_error.msg.is_empty()
814-
&& actual_error.require_annotation
813+
actual_error.require_annotation
815814
&& match actual_error.kind {
816815
Some(ErrorKind::Help) => expect_help,
817816
Some(ErrorKind::Note) => expect_note,

tests/incremental/circular-dependencies.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct Foo;
1515

1616
pub fn consume_foo(_: Foo) {}
1717
//[cfail2]~^ NOTE function defined here
18+
//[cfail2]~| NOTE
1819

1920
pub fn produce_foo() -> Foo {
2021
Foo

tests/ui/consts/const_in_pattern/reject_non_structural.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ fn main() {
9393
//~| NOTE constant of non-structural type
9494

9595
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
96+
//~^ NOTE
9697
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
9798
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
9899
//~^ ERROR constant of non-structural type `NoDerive` in a pattern

tests/ui/consts/const_in_pattern/reject_non_structural.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
118118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
119119

120120
error: constant of non-structural type `NoDerive` in a pattern
121-
--> $DIR/reject_non_structural.rs:97:28
121+
--> $DIR/reject_non_structural.rs:98:28
122122
|
123123
LL | struct NoDerive;
124124
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
125125
...
126126
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
127127
| ------------------ ------------------------- constant defined here
128-
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
128+
...
129129
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
130130
| ^^^^^^^^^^^^^^^ constant of non-structural type
131131
|
@@ -136,7 +136,7 @@ LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
136136
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
137137

138138
error: constant of non-structural type `NoDerive` in a pattern
139-
--> $DIR/reject_non_structural.rs:102:28
139+
--> $DIR/reject_non_structural.rs:103:28
140140
|
141141
LL | struct NoDerive;
142142
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
@@ -153,7 +153,7 @@ LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
153153
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
154154

155155
error: constant of non-structural type `NoDerive` in a pattern
156-
--> $DIR/reject_non_structural.rs:107:29
156+
--> $DIR/reject_non_structural.rs:108:29
157157
|
158158
LL | struct NoDerive;
159159
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns

tests/ui/fn/param-mismatch-foreign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extern "C" {
22
fn foo(x: i32, y: u32, z: i32);
33
//~^ NOTE function defined here
4+
//~| NOTE
45
}
56

67
fn main() {

tests/ui/fn/param-mismatch-foreign.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
2-
--> $DIR/param-mismatch-foreign.rs:7:5
2+
--> $DIR/param-mismatch-foreign.rs:8:5
33
|
44
LL | foo(1i32, 2i32);
55
| ^^^ ---- argument #2 of type `u32` is missing

tests/ui/mismatched_types/similar_paths_primitive.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ struct bool; //~ NOTE the other `bool` is defined in the current crate
44
struct str; //~ NOTE the other `str` is defined in the current crate
55

66
fn foo(_: bool) {} //~ NOTE function defined here
7+
//~^ NOTE
78
fn bar(_: &str) {} //~ NOTE function defined here
8-
9+
//~^ NOTE
910
fn main() {
1011
foo(true);
1112
//~^ ERROR mismatched types [E0308]

tests/ui/mismatched_types/similar_paths_primitive.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/similar_paths_primitive.rs:10:9
2+
--> $DIR/similar_paths_primitive.rs:11:9
33
|
44
LL | foo(true);
55
| --- ^^^^ expected `bool`, found a different `bool`
@@ -20,7 +20,7 @@ LL | fn foo(_: bool) {}
2020
| ^^^ -------
2121

2222
error[E0308]: mismatched types
23-
--> $DIR/similar_paths_primitive.rs:16:9
23+
--> $DIR/similar_paths_primitive.rs:17:9
2424
|
2525
LL | bar("hello");
2626
| --- ^^^^^^^ expected `str`, found a different `str`
@@ -35,7 +35,7 @@ note: the other `str` is defined in the current crate
3535
LL | struct str;
3636
| ^^^^^^^^^^
3737
note: function defined here
38-
--> $DIR/similar_paths_primitive.rs:7:4
38+
--> $DIR/similar_paths_primitive.rs:8:4
3939
|
4040
LL | fn bar(_: &str) {}
4141
| ^^^ -------

tests/ui/moves/nested-loop-moved-value-wrong-continue.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ fn foo() {
99
//~| NOTE inside of this loop
1010
//~| HELP consider moving the expression out of the loop
1111
//~| NOTE in this expansion of desugaring of `for` loop
12+
//~| NOTE
13+
//~| NOTE
1214
baz.push(foo);
1315
//~^ NOTE value moved here
1416
//~| HELP consider cloning the value
@@ -30,17 +32,19 @@ fn main() {
3032
for foo in foos {
3133
//~^ NOTE this reinitialization might get skipped
3234
//~| NOTE move occurs because `foo` has type `String`
35+
//~| NOTE
3336
for bar in &bars {
3437
//~^ NOTE inside of this loop
3538
//~| HELP consider moving the expression out of the loop
3639
//~| NOTE in this expansion of desugaring of `for` loop
40+
//~| NOTE
3741
if foo == *bar {
3842
baz.push(foo);
3943
//~^ NOTE value moved here
4044
//~| HELP consider cloning the value
4145
continue;
4246
//~^ NOTE verify that your loop breaking logic is correct
43-
//~| NOTE this `continue` advances the loop at line 33
47+
//~| NOTE this `continue` advances the loop at line 36
4448
}
4549
}
4650
qux.push(foo);

tests/ui/moves/nested-loop-moved-value-wrong-continue.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0382]: use of moved value: `foo`
2-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:19:14
2+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:21:14
33
|
44
LL | for foo in foos { for bar in &bars { if foo == *bar {
55
| --- ---------------- inside of this loop
@@ -14,13 +14,13 @@ LL | qux.push(foo);
1414
| ^^^ value used here after move
1515
|
1616
note: verify that your loop breaking logic is correct
17-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:15:9
17+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:17:9
1818
|
1919
LL | for foo in foos { for bar in &bars { if foo == *bar {
2020
| --------------- ----------------
2121
...
2222
LL | continue;
23-
| ^^^^^^^^ this `continue` advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 18:8
23+
| ^^^^^^^^ this `continue` advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 20:8
2424
help: consider moving the expression out of the loop so it is only moved once
2525
|
2626
LL ~ for foo in foos { let mut value = baz.push(foo);
@@ -36,7 +36,7 @@ LL | baz.push(foo.clone());
3636
| ++++++++
3737

3838
error[E0382]: use of moved value: `foo`
39-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:46:18
39+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:50:18
4040
|
4141
LL | for foo in foos {
4242
| ---
@@ -54,7 +54,7 @@ LL | qux.push(foo);
5454
| ^^^ value used here after move
5555
|
5656
note: verify that your loop breaking logic is correct
57-
--> $DIR/nested-loop-moved-value-wrong-continue.rs:41:17
57+
--> $DIR/nested-loop-moved-value-wrong-continue.rs:45:17
5858
|
5959
LL | for foo in foos {
6060
| ---------------
@@ -63,7 +63,7 @@ LL | for bar in &bars {
6363
| ----------------
6464
...
6565
LL | continue;
66-
| ^^^^^^^^ this `continue` advances the loop at line 33
66+
| ^^^^^^^^ this `continue` advances the loop at line 36
6767
help: consider moving the expression out of the loop so it is only moved once
6868
|
6969
LL ~ let mut value = baz.push(foo);

tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ const async const fn test() {}
1010
//~| ERROR functions cannot be both `const` and `async`
1111
//~| NOTE `const` because of this
1212
//~| NOTE `async` because of this
13+
//~| NOTE
1314

1415
fn main() {}

tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ async unsafe const fn test() {}
1515
//~| ERROR functions cannot be both `const` and `async`
1616
//~| NOTE `const` because of this
1717
//~| NOTE `async` because of this
18+
//~| NOTE
1819

1920
fn main() {}

0 commit comments

Comments
 (0)