Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
compiletest: Avoid ignoring empty diagnostics in one more place
This catches some silly notes emitted by rustc, which should ideally be fixed
  • Loading branch information
petrochenkov committed Apr 7, 2025
commit fd854a772e12ee51c0028e9dbb9443d831e28327
3 changes: 1 addition & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,7 @@ impl<'test> TestCx<'test> {
expect_help: bool,
expect_note: bool,
) -> bool {
!actual_error.msg.is_empty()
&& actual_error.require_annotation
actual_error.require_annotation
&& match actual_error.kind {
Some(ErrorKind::Help) => expect_help,
Some(ErrorKind::Note) => expect_note,
Expand Down
1 change: 1 addition & 0 deletions tests/incremental/circular-dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Foo;

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

pub fn produce_foo() -> Foo {
Foo
Expand Down
1 change: 1 addition & 0 deletions tests/ui/consts/const_in_pattern/reject_non_structural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn main() {
//~| NOTE constant of non-structural type

trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
//~^ NOTE
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/consts/const_in_pattern/reject_non_structural.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
--> $DIR/reject_non_structural.rs:97:28
--> $DIR/reject_non_structural.rs:98:28
|
LL | struct NoDerive;
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
| ------------------ ------------------------- 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"), };
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
Expand All @@ -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
--> $DIR/reject_non_structural.rs:102:28
--> $DIR/reject_non_structural.rs:103:28
|
LL | struct NoDerive;
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
Expand All @@ -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
--> $DIR/reject_non_structural.rs:107:29
--> $DIR/reject_non_structural.rs:108:29
|
LL | struct NoDerive;
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
Expand Down
1 change: 1 addition & 0 deletions tests/ui/fn/param-mismatch-foreign.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern "C" {
fn foo(x: i32, y: u32, z: i32);
//~^ NOTE function defined here
//~| NOTE
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/fn/param-mismatch-foreign.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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);
| ^^^ ---- argument #2 of type `u32` is missing
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/mismatched_types/similar_paths_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

fn foo(_: bool) {} //~ NOTE function defined here
//~^ NOTE
fn bar(_: &str) {} //~ NOTE function defined here

//~^ NOTE
fn main() {
foo(true);
//~^ ERROR mismatched types [E0308]
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/mismatched_types/similar_paths_primitive.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/similar_paths_primitive.rs:10:9
--> $DIR/similar_paths_primitive.rs:11:9
|
LL | foo(true);
| --- ^^^^ expected `bool`, found a different `bool`
Expand All @@ -20,7 +20,7 @@ LL | fn foo(_: bool) {}
| ^^^ -------

error[E0308]: mismatched types
--> $DIR/similar_paths_primitive.rs:16:9
--> $DIR/similar_paths_primitive.rs:17:9
|
LL | bar("hello");
| --- ^^^^^^^ expected `str`, found a different `str`
Expand All @@ -35,7 +35,7 @@ note: the other `str` is defined in the current crate
LL | struct str;
| ^^^^^^^^^^
note: function defined here
--> $DIR/similar_paths_primitive.rs:7:4
--> $DIR/similar_paths_primitive.rs:8:4
|
LL | fn bar(_: &str) {}
| ^^^ -------
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/moves/nested-loop-moved-value-wrong-continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fn foo() {
//~| NOTE inside of this loop
//~| HELP consider moving the expression out of the loop
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE
//~| NOTE
baz.push(foo);
//~^ NOTE value moved here
//~| HELP consider cloning the value
Expand All @@ -30,17 +32,19 @@ fn main() {
for foo in foos {
//~^ NOTE this reinitialization might get skipped
//~| NOTE move occurs because `foo` has type `String`
//~| NOTE
for bar in &bars {
//~^ NOTE inside of this loop
//~| HELP consider moving the expression out of the loop
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE
if foo == *bar {
baz.push(foo);
//~^ NOTE value moved here
//~| HELP consider cloning the value
continue;
//~^ 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);
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/moves/nested-loop-moved-value-wrong-continue.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 {
| --- ---------------- inside of this loop
Expand All @@ -14,13 +14,13 @@ LL | qux.push(foo);
| ^^^ value used here after move
|
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 | 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
|
LL ~ for foo in foos { let mut value = baz.push(foo);
Expand All @@ -36,7 +36,7 @@ LL | baz.push(foo.clone());
| ++++++++

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 {
| ---
Expand All @@ -54,7 +54,7 @@ LL | qux.push(foo);
| ^^^ value used here after move
|
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 {
| ---------------
Expand All @@ -63,7 +63,7 @@ LL | for bar in &bars {
| ----------------
...
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
|
LL ~ let mut value = baz.push(foo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ const async const fn test() {}
//~| ERROR functions cannot be both `const` and `async`
//~| NOTE `const` because of this
//~| NOTE `async` because of this
//~| NOTE

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ async unsafe const fn test() {}
//~| ERROR functions cannot be both `const` and `async`
//~| NOTE `const` because of this
//~| NOTE `async` because of this
//~| NOTE

fn main() {}
Loading