compiletest: Avoid ignoring empty diagnostics in one more place
This catches some silly notes emitted by rustc, which should ideally be fixed
This commit is contained in:
parent
5c160f511e
commit
fd854a772e
12 changed files with 27 additions and 18 deletions
|
@ -810,8 +810,7 @@ impl<'test> TestCx<'test> {
|
||||||
expect_help: bool,
|
expect_help: bool,
|
||||||
expect_note: bool,
|
expect_note: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
!actual_error.msg.is_empty()
|
actual_error.require_annotation
|
||||||
&& actual_error.require_annotation
|
|
||||||
&& match actual_error.kind {
|
&& match actual_error.kind {
|
||||||
Some(ErrorKind::Help) => expect_help,
|
Some(ErrorKind::Help) => expect_help,
|
||||||
Some(ErrorKind::Note) => expect_note,
|
Some(ErrorKind::Note) => expect_note,
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub struct Foo;
|
||||||
|
|
||||||
pub fn consume_foo(_: Foo) {}
|
pub fn consume_foo(_: Foo) {}
|
||||||
//[cfail2]~^ NOTE function defined here
|
//[cfail2]~^ NOTE function defined here
|
||||||
|
//[cfail2]~| NOTE
|
||||||
|
|
||||||
pub fn produce_foo() -> Foo {
|
pub fn produce_foo() -> Foo {
|
||||||
Foo
|
Foo
|
||||||
|
|
|
@ -93,6 +93,7 @@ fn main() {
|
||||||
//~| NOTE constant of non-structural type
|
//~| NOTE constant of non-structural type
|
||||||
|
|
||||||
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
|
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
|
||||||
|
//~^ NOTE
|
||||||
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||||
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||||
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
|
|
|
@ -118,14 +118,14 @@ LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: constant of non-structural type `NoDerive` in a pattern
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:97:28
|
--> $DIR/reject_non_structural.rs:98:28
|
||||||
|
|
|
|
||||||
LL | struct NoDerive;
|
LL | struct NoDerive;
|
||||||
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
...
|
...
|
||||||
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
|
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
|
||||||
| ------------------ ------------------------- constant defined here
|
| ------------------ ------------------------- constant defined here
|
||||||
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
...
|
||||||
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
|
@ -136,7 +136,7 @@ LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: constant of non-structural type `NoDerive` in a pattern
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:102:28
|
--> $DIR/reject_non_structural.rs:103:28
|
||||||
|
|
|
|
||||||
LL | struct NoDerive;
|
LL | struct NoDerive;
|
||||||
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
| --------------- `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 } }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: constant of non-structural type `NoDerive` in a pattern
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:107:29
|
--> $DIR/reject_non_structural.rs:108:29
|
||||||
|
|
|
|
||||||
LL | struct NoDerive;
|
LL | struct NoDerive;
|
||||||
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn foo(x: i32, y: u32, z: i32);
|
fn foo(x: i32, y: u32, z: i32);
|
||||||
//~^ NOTE function defined here
|
//~^ NOTE function defined here
|
||||||
|
//~| NOTE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
|
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
|
||||||
--> $DIR/param-mismatch-foreign.rs:7:5
|
--> $DIR/param-mismatch-foreign.rs:8:5
|
||||||
|
|
|
|
||||||
LL | foo(1i32, 2i32);
|
LL | foo(1i32, 2i32);
|
||||||
| ^^^ ---- argument #2 of type `u32` is missing
|
| ^^^ ---- argument #2 of type `u32` is missing
|
||||||
|
|
|
@ -4,8 +4,9 @@ struct bool; //~ NOTE the other `bool` is defined in the current crate
|
||||||
struct str; //~ NOTE the other `str` is defined in the current crate
|
struct str; //~ NOTE the other `str` is defined in the current crate
|
||||||
|
|
||||||
fn foo(_: bool) {} //~ NOTE function defined here
|
fn foo(_: bool) {} //~ NOTE function defined here
|
||||||
|
//~^ NOTE
|
||||||
fn bar(_: &str) {} //~ NOTE function defined here
|
fn bar(_: &str) {} //~ NOTE function defined here
|
||||||
|
//~^ NOTE
|
||||||
fn main() {
|
fn main() {
|
||||||
foo(true);
|
foo(true);
|
||||||
//~^ ERROR mismatched types [E0308]
|
//~^ ERROR mismatched types [E0308]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/similar_paths_primitive.rs:10:9
|
--> $DIR/similar_paths_primitive.rs:11:9
|
||||||
|
|
|
|
||||||
LL | foo(true);
|
LL | foo(true);
|
||||||
| --- ^^^^ expected `bool`, found a different `bool`
|
| --- ^^^^ expected `bool`, found a different `bool`
|
||||||
|
@ -20,7 +20,7 @@ LL | fn foo(_: bool) {}
|
||||||
| ^^^ -------
|
| ^^^ -------
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/similar_paths_primitive.rs:16:9
|
--> $DIR/similar_paths_primitive.rs:17:9
|
||||||
|
|
|
|
||||||
LL | bar("hello");
|
LL | bar("hello");
|
||||||
| --- ^^^^^^^ expected `str`, found a different `str`
|
| --- ^^^^^^^ expected `str`, found a different `str`
|
||||||
|
@ -35,7 +35,7 @@ note: the other `str` is defined in the current crate
|
||||||
LL | struct str;
|
LL | struct str;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> $DIR/similar_paths_primitive.rs:7:4
|
--> $DIR/similar_paths_primitive.rs:8:4
|
||||||
|
|
|
|
||||||
LL | fn bar(_: &str) {}
|
LL | fn bar(_: &str) {}
|
||||||
| ^^^ -------
|
| ^^^ -------
|
||||||
|
|
|
@ -9,6 +9,8 @@ fn foo() {
|
||||||
//~| NOTE inside of this loop
|
//~| NOTE inside of this loop
|
||||||
//~| HELP consider moving the expression out of the loop
|
//~| HELP consider moving the expression out of the loop
|
||||||
//~| NOTE in this expansion of desugaring of `for` loop
|
//~| NOTE in this expansion of desugaring of `for` loop
|
||||||
|
//~| NOTE
|
||||||
|
//~| NOTE
|
||||||
baz.push(foo);
|
baz.push(foo);
|
||||||
//~^ NOTE value moved here
|
//~^ NOTE value moved here
|
||||||
//~| HELP consider cloning the value
|
//~| HELP consider cloning the value
|
||||||
|
@ -30,17 +32,19 @@ fn main() {
|
||||||
for foo in foos {
|
for foo in foos {
|
||||||
//~^ NOTE this reinitialization might get skipped
|
//~^ NOTE this reinitialization might get skipped
|
||||||
//~| NOTE move occurs because `foo` has type `String`
|
//~| NOTE move occurs because `foo` has type `String`
|
||||||
|
//~| NOTE
|
||||||
for bar in &bars {
|
for bar in &bars {
|
||||||
//~^ NOTE inside of this loop
|
//~^ NOTE inside of this loop
|
||||||
//~| HELP consider moving the expression out of the loop
|
//~| HELP consider moving the expression out of the loop
|
||||||
//~| NOTE in this expansion of desugaring of `for` loop
|
//~| NOTE in this expansion of desugaring of `for` loop
|
||||||
|
//~| NOTE
|
||||||
if foo == *bar {
|
if foo == *bar {
|
||||||
baz.push(foo);
|
baz.push(foo);
|
||||||
//~^ NOTE value moved here
|
//~^ NOTE value moved here
|
||||||
//~| HELP consider cloning the value
|
//~| HELP consider cloning the value
|
||||||
continue;
|
continue;
|
||||||
//~^ NOTE verify that your loop breaking logic is correct
|
//~^ NOTE verify that your loop breaking logic is correct
|
||||||
//~| NOTE this `continue` advances the loop at line 33
|
//~| NOTE this `continue` advances the loop at line 36
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qux.push(foo);
|
qux.push(foo);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0382]: use of moved value: `foo`
|
error[E0382]: use of moved value: `foo`
|
||||||
--> $DIR/nested-loop-moved-value-wrong-continue.rs:19:14
|
--> $DIR/nested-loop-moved-value-wrong-continue.rs:21:14
|
||||||
|
|
|
|
||||||
LL | for foo in foos { for bar in &bars { if foo == *bar {
|
LL | for foo in foos { for bar in &bars { if foo == *bar {
|
||||||
| --- ---------------- inside of this loop
|
| --- ---------------- inside of this loop
|
||||||
|
@ -14,13 +14,13 @@ LL | qux.push(foo);
|
||||||
| ^^^ value used here after move
|
| ^^^ value used here after move
|
||||||
|
|
|
|
||||||
note: verify that your loop breaking logic is correct
|
note: verify that your loop breaking logic is correct
|
||||||
--> $DIR/nested-loop-moved-value-wrong-continue.rs:15:9
|
--> $DIR/nested-loop-moved-value-wrong-continue.rs:17:9
|
||||||
|
|
|
|
||||||
LL | for foo in foos { for bar in &bars { if foo == *bar {
|
LL | for foo in foos { for bar in &bars { if foo == *bar {
|
||||||
| --------------- ----------------
|
| --------------- ----------------
|
||||||
...
|
...
|
||||||
LL | continue;
|
LL | continue;
|
||||||
| ^^^^^^^^ this `continue` advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 18:8
|
| ^^^^^^^^ this `continue` advances the loop at $DIR/nested-loop-moved-value-wrong-continue.rs:6:23: 20:8
|
||||||
help: consider moving the expression out of the loop so it is only moved once
|
help: consider moving the expression out of the loop so it is only moved once
|
||||||
|
|
|
|
||||||
LL ~ for foo in foos { let mut value = baz.push(foo);
|
LL ~ for foo in foos { let mut value = baz.push(foo);
|
||||||
|
@ -36,7 +36,7 @@ LL | baz.push(foo.clone());
|
||||||
| ++++++++
|
| ++++++++
|
||||||
|
|
||||||
error[E0382]: use of moved value: `foo`
|
error[E0382]: use of moved value: `foo`
|
||||||
--> $DIR/nested-loop-moved-value-wrong-continue.rs:46:18
|
--> $DIR/nested-loop-moved-value-wrong-continue.rs:50:18
|
||||||
|
|
|
|
||||||
LL | for foo in foos {
|
LL | for foo in foos {
|
||||||
| ---
|
| ---
|
||||||
|
@ -54,7 +54,7 @@ LL | qux.push(foo);
|
||||||
| ^^^ value used here after move
|
| ^^^ value used here after move
|
||||||
|
|
|
|
||||||
note: verify that your loop breaking logic is correct
|
note: verify that your loop breaking logic is correct
|
||||||
--> $DIR/nested-loop-moved-value-wrong-continue.rs:41:17
|
--> $DIR/nested-loop-moved-value-wrong-continue.rs:45:17
|
||||||
|
|
|
|
||||||
LL | for foo in foos {
|
LL | for foo in foos {
|
||||||
| ---------------
|
| ---------------
|
||||||
|
@ -63,7 +63,7 @@ LL | for bar in &bars {
|
||||||
| ----------------
|
| ----------------
|
||||||
...
|
...
|
||||||
LL | continue;
|
LL | continue;
|
||||||
| ^^^^^^^^ this `continue` advances the loop at line 33
|
| ^^^^^^^^ this `continue` advances the loop at line 36
|
||||||
help: consider moving the expression out of the loop so it is only moved once
|
help: consider moving the expression out of the loop so it is only moved once
|
||||||
|
|
|
|
||||||
LL ~ let mut value = baz.push(foo);
|
LL ~ let mut value = baz.push(foo);
|
||||||
|
|
|
@ -10,5 +10,6 @@ const async const fn test() {}
|
||||||
//~| ERROR functions cannot be both `const` and `async`
|
//~| ERROR functions cannot be both `const` and `async`
|
||||||
//~| NOTE `const` because of this
|
//~| NOTE `const` because of this
|
||||||
//~| NOTE `async` because of this
|
//~| NOTE `async` because of this
|
||||||
|
//~| NOTE
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -15,5 +15,6 @@ async unsafe const fn test() {}
|
||||||
//~| ERROR functions cannot be both `const` and `async`
|
//~| ERROR functions cannot be both `const` and `async`
|
||||||
//~| NOTE `const` because of this
|
//~| NOTE `const` because of this
|
||||||
//~| NOTE `async` because of this
|
//~| NOTE `async` because of this
|
||||||
|
//~| NOTE
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue