From a4a79500b5e8e848bb9a0db67604d03e9de38ad9 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 30 Nov 2025 14:36:05 +0900 Subject: [PATCH] Cleaned up some tests fix explicit-call-to-dtor.rs fix explicit-call-to-supertrait-dtor.rs merge issues/issue-17740.rs with lifetimes/explicit-self-lifetime-mismatch.rs merge bare-fn-start.rs and trait-fn.rs into invalid-self-argument.rs add comment tests/ui/traits/catch-unwind-cell-interior-mut --- tests/ui/drop/explicit-call-to-dtor.fixed | 4 +- tests/ui/drop/explicit-call-to-dtor.rs | 4 +- .../explicit-call-to-supertrait-dtor.fixed | 4 +- .../drop/explicit-call-to-supertrait-dtor.rs | 4 +- tests/ui/issues/issue-17740.rs | 20 ------ tests/ui/issues/issue-17740.stderr | 41 ----------- .../explicit-self-lifetime-mismatch.rs | 45 ++++++++---- .../explicit-self-lifetime-mismatch.stderr | 72 ++++++++++++++----- tests/ui/self/bare-fn-start.rs | 6 -- tests/ui/self/bare-fn-start.stderr | 10 --- tests/ui/self/invalid-self-argument.rs | 21 +++++- tests/ui/self/invalid-self-argument.stderr | 20 +++++- tests/ui/self/trait-fn.rs | 11 --- tests/ui/self/trait-fn.stderr | 8 --- .../traits/catch-unwind-cell-interior-mut.rs | 1 + .../catch-unwind-cell-interior-mut.stderr | 4 +- 16 files changed, 134 insertions(+), 141 deletions(-) delete mode 100644 tests/ui/issues/issue-17740.rs delete mode 100644 tests/ui/issues/issue-17740.stderr delete mode 100644 tests/ui/self/bare-fn-start.rs delete mode 100644 tests/ui/self/bare-fn-start.stderr delete mode 100644 tests/ui/self/trait-fn.rs delete mode 100644 tests/ui/self/trait-fn.stderr diff --git a/tests/ui/drop/explicit-call-to-dtor.fixed b/tests/ui/drop/explicit-call-to-dtor.fixed index 4c4142c79811..167f557a6125 100644 --- a/tests/ui/drop/explicit-call-to-dtor.fixed +++ b/tests/ui/drop/explicit-call-to-dtor.fixed @@ -1,6 +1,6 @@ //@ run-rustfix struct Foo { - x: isize + x: isize, } impl Drop for Foo { @@ -12,5 +12,5 @@ impl Drop for Foo { fn main() { let x = Foo { x: 3 }; println!("{}", x.x); - drop(x); //~ ERROR explicit use of destructor method + drop(x); //~ ERROR explicit use of destructor method } diff --git a/tests/ui/drop/explicit-call-to-dtor.rs b/tests/ui/drop/explicit-call-to-dtor.rs index 262dde54c7f6..2c4e013f5c94 100644 --- a/tests/ui/drop/explicit-call-to-dtor.rs +++ b/tests/ui/drop/explicit-call-to-dtor.rs @@ -1,6 +1,6 @@ //@ run-rustfix struct Foo { - x: isize + x: isize, } impl Drop for Foo { @@ -12,5 +12,5 @@ impl Drop for Foo { fn main() { let x = Foo { x: 3 }; println!("{}", x.x); - x.drop(); //~ ERROR explicit use of destructor method + x.drop(); //~ ERROR explicit use of destructor method } diff --git a/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed b/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed index 57cb858aa089..1526f7b46ea1 100644 --- a/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed +++ b/tests/ui/drop/explicit-call-to-supertrait-dtor.fixed @@ -4,7 +4,7 @@ #![allow(dropping_references)] struct Foo { - x: isize + x: isize, } #[allow(drop_bounds)] @@ -20,7 +20,7 @@ impl Drop for Foo { impl Bar for Foo { fn blah(&self) { - drop(self); //~ ERROR explicit use of destructor method + drop(self); //~ ERROR explicit use of destructor method } } diff --git a/tests/ui/drop/explicit-call-to-supertrait-dtor.rs b/tests/ui/drop/explicit-call-to-supertrait-dtor.rs index bb29e4952420..2de3d008aaae 100644 --- a/tests/ui/drop/explicit-call-to-supertrait-dtor.rs +++ b/tests/ui/drop/explicit-call-to-supertrait-dtor.rs @@ -4,7 +4,7 @@ #![allow(dropping_references)] struct Foo { - x: isize + x: isize, } #[allow(drop_bounds)] @@ -20,7 +20,7 @@ impl Drop for Foo { impl Bar for Foo { fn blah(&self) { - self.drop(); //~ ERROR explicit use of destructor method + self.drop(); //~ ERROR explicit use of destructor method } } diff --git a/tests/ui/issues/issue-17740.rs b/tests/ui/issues/issue-17740.rs deleted file mode 100644 index 20a73756ea3e..000000000000 --- a/tests/ui/issues/issue-17740.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ dont-require-annotations: NOTE - -struct Foo<'a> { - data: &'a[u8], -} - -impl <'a> Foo<'a>{ - fn bar(self: &mut Foo) { - //~^ ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a>` - //~| NOTE found struct `Foo<'_>` - //~| NOTE lifetime mismatch - //~| ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a>` - //~| NOTE found struct `Foo<'_>` - //~| NOTE lifetime mismatch - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-17740.stderr b/tests/ui/issues/issue-17740.stderr deleted file mode 100644 index 198d7d5b37cc..000000000000 --- a/tests/ui/issues/issue-17740.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:8:18 - | -LL | fn bar(self: &mut Foo) { - | ^^^^^^^^ lifetime mismatch - | - = note: expected struct `Foo<'a>` - found struct `Foo<'_>` -note: the anonymous lifetime defined here... - --> $DIR/issue-17740.rs:8:23 - | -LL | fn bar(self: &mut Foo) { - | ^^^ -note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/issue-17740.rs:7:7 - | -LL | impl <'a> Foo<'a>{ - | ^^ - -error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:8:18 - | -LL | fn bar(self: &mut Foo) { - | ^^^^^^^^ lifetime mismatch - | - = note: expected struct `Foo<'a>` - found struct `Foo<'_>` -note: the lifetime `'a` as defined here... - --> $DIR/issue-17740.rs:7:7 - | -LL | impl <'a> Foo<'a>{ - | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-17740.rs:8:23 - | -LL | fn bar(self: &mut Foo) { - | ^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs index aa5e352b6ebe..88b9d86a9fdf 100644 --- a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs +++ b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.rs @@ -1,22 +1,41 @@ //@ dont-require-annotations: NOTE +//! regression test for -struct Foo<'a,'b> { +struct Foo<'a, 'b> { x: &'a isize, y: &'b isize, } -impl<'a,'b> Foo<'a,'b> { - fn bar(self: - Foo<'b,'a> - //~^ ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a, 'b>` - //~| NOTE found struct `Foo<'b, 'a>` - //~| NOTE lifetime mismatch - //~| ERROR mismatched `self` parameter type - //~| NOTE expected struct `Foo<'a, 'b>` - //~| NOTE found struct `Foo<'b, 'a>` - //~| NOTE lifetime mismatch - ) {} +impl<'a, 'b> Foo<'a, 'b> { + fn bar( + self: Foo<'b, 'a>, + //~^ ERROR mismatched `self` parameter type + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch + //~| ERROR mismatched `self` parameter type + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch + ) { + } +} + +struct Bar<'a> { + data: &'a [u8], +} + +impl<'a> Bar<'a> { + fn bar(self: &mut Bar) { + //~^ ERROR mismatched `self` parameter type + //~| NOTE expected struct `Bar<'a>` + //~| NOTE found struct `Bar<'_>` + //~| NOTE lifetime mismatch + //~| ERROR mismatched `self` parameter type + //~| NOTE expected struct `Bar<'a>` + //~| NOTE found struct `Bar<'_>` + //~| NOTE lifetime mismatch + } } fn main() {} diff --git a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr index a20901e8c74d..ebd6383cb4de 100644 --- a/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr +++ b/tests/ui/lifetimes/explicit-self-lifetime-mismatch.stderr @@ -1,41 +1,79 @@ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:11:15 | -LL | Foo<'b,'a> - | ^^^^^^^^^^ lifetime mismatch +LL | self: Foo<'b, 'a>, + | ^^^^^^^^^^^ lifetime mismatch | = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'b` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:10 | -LL | impl<'a,'b> Foo<'a,'b> { - | ^^ +LL | impl<'a, 'b> Foo<'a, 'b> { + | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:6 | -LL | impl<'a,'b> Foo<'a,'b> { +LL | impl<'a, 'b> Foo<'a, 'b> { | ^^ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:11:15 | -LL | Foo<'b,'a> - | ^^^^^^^^^^ lifetime mismatch +LL | self: Foo<'b, 'a>, + | ^^^^^^^^^^^ lifetime mismatch | = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'a` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:6 | -LL | impl<'a,'b> Foo<'a,'b> { +LL | impl<'a, 'b> Foo<'a, 'b> { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:9:10 | -LL | impl<'a,'b> Foo<'a,'b> { - | ^^ +LL | impl<'a, 'b> Foo<'a, 'b> { + | ^^ -error: aborting due to 2 previous errors +error[E0308]: mismatched `self` parameter type + --> $DIR/explicit-self-lifetime-mismatch.rs:29:18 + | +LL | fn bar(self: &mut Bar) { + | ^^^^^^^^ lifetime mismatch + | + = note: expected struct `Bar<'a>` + found struct `Bar<'_>` +note: the anonymous lifetime defined here... + --> $DIR/explicit-self-lifetime-mismatch.rs:29:23 + | +LL | fn bar(self: &mut Bar) { + | ^^^ +note: ...does not necessarily outlive the lifetime `'a` as defined here + --> $DIR/explicit-self-lifetime-mismatch.rs:28:6 + | +LL | impl<'a> Bar<'a> { + | ^^ + +error[E0308]: mismatched `self` parameter type + --> $DIR/explicit-self-lifetime-mismatch.rs:29:18 + | +LL | fn bar(self: &mut Bar) { + | ^^^^^^^^ lifetime mismatch + | + = note: expected struct `Bar<'a>` + found struct `Bar<'_>` +note: the lifetime `'a` as defined here... + --> $DIR/explicit-self-lifetime-mismatch.rs:28:6 + | +LL | impl<'a> Bar<'a> { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime defined here + --> $DIR/explicit-self-lifetime-mismatch.rs:29:23 + | +LL | fn bar(self: &mut Bar) { + | ^^^ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/self/bare-fn-start.rs b/tests/ui/self/bare-fn-start.rs deleted file mode 100644 index 7c580bc5a5de..000000000000 --- a/tests/ui/self/bare-fn-start.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn a(&self) { } -//~^ ERROR `self` parameter is only allowed in associated functions -//~| NOTE not semantically valid as function parameter -//~| NOTE associated functions are those in `impl` or `trait` definitions - -fn main() { } diff --git a/tests/ui/self/bare-fn-start.stderr b/tests/ui/self/bare-fn-start.stderr deleted file mode 100644 index bf7160bcd2d3..000000000000 --- a/tests/ui/self/bare-fn-start.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `self` parameter is only allowed in associated functions - --> $DIR/bare-fn-start.rs:1:6 - | -LL | fn a(&self) { } - | ^^^^^ not semantically valid as function parameter - | - = note: associated functions are those in `impl` or `trait` definitions - -error: aborting due to 1 previous error - diff --git a/tests/ui/self/invalid-self-argument.rs b/tests/ui/self/invalid-self-argument.rs index 342bdc31a7c8..fef687e194cb 100644 --- a/tests/ui/self/invalid-self-argument.rs +++ b/tests/ui/self/invalid-self-argument.rs @@ -1,5 +1,22 @@ -fn b(foo: u32, &mut self) { } +//! regression test for + +fn a(&self) {} +//~^ ERROR `self` parameter is only allowed in associated functions +//~| NOTE not semantically valid as function parameter +//~| NOTE associated functions are those in `impl` or `trait` definitions + +fn b(foo: u32, &mut self) {} //~^ ERROR unexpected `self` parameter in function //~| NOTE must be the first parameter of an associated function -fn main() { } +struct Foo {} + +impl Foo { + fn c(foo: u32, self) {} + //~^ ERROR unexpected `self` parameter in function + //~| NOTE must be the first parameter of an associated function + + fn good(&mut self, foo: u32) {} +} + +fn main() {} diff --git a/tests/ui/self/invalid-self-argument.stderr b/tests/ui/self/invalid-self-argument.stderr index 7abb56602d4b..c92e5b2492bf 100644 --- a/tests/ui/self/invalid-self-argument.stderr +++ b/tests/ui/self/invalid-self-argument.stderr @@ -1,8 +1,22 @@ error: unexpected `self` parameter in function - --> $DIR/bare-fn.rs:1:16 + --> $DIR/invalid-self-argument.rs:8:16 | -LL | fn b(foo: u32, &mut self) { } +LL | fn b(foo: u32, &mut self) {} | ^^^^^^^^^ must be the first parameter of an associated function -error: aborting due to 1 previous error +error: unexpected `self` parameter in function + --> $DIR/invalid-self-argument.rs:15:20 + | +LL | fn c(foo: u32, self) {} + | ^^^^ must be the first parameter of an associated function + +error: `self` parameter is only allowed in associated functions + --> $DIR/invalid-self-argument.rs:3:6 + | +LL | fn a(&self) {} + | ^^^^^ not semantically valid as function parameter + | + = note: associated functions are those in `impl` or `trait` definitions + +error: aborting due to 3 previous errors diff --git a/tests/ui/self/trait-fn.rs b/tests/ui/self/trait-fn.rs deleted file mode 100644 index 5ccea589561c..000000000000 --- a/tests/ui/self/trait-fn.rs +++ /dev/null @@ -1,11 +0,0 @@ -struct Foo {} - -impl Foo { - fn c(foo: u32, self) {} - //~^ ERROR unexpected `self` parameter in function - //~| NOTE must be the first parameter of an associated function - - fn good(&mut self, foo: u32) {} -} - -fn main() { } diff --git a/tests/ui/self/trait-fn.stderr b/tests/ui/self/trait-fn.stderr deleted file mode 100644 index c9d0a338ef42..000000000000 --- a/tests/ui/self/trait-fn.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unexpected `self` parameter in function - --> $DIR/trait-fn.rs:4:20 - | -LL | fn c(foo: u32, self) {} - | ^^^^ must be the first parameter of an associated function - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/catch-unwind-cell-interior-mut.rs b/tests/ui/traits/catch-unwind-cell-interior-mut.rs index 7e4fe76852d7..cfc52322399f 100644 --- a/tests/ui/traits/catch-unwind-cell-interior-mut.rs +++ b/tests/ui/traits/catch-unwind-cell-interior-mut.rs @@ -1,3 +1,4 @@ +//! related issue: //@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::panic::catch_unwind; diff --git a/tests/ui/traits/catch-unwind-cell-interior-mut.stderr b/tests/ui/traits/catch-unwind-cell-interior-mut.stderr index b307d608a1fd..6f58c880554a 100644 --- a/tests/ui/traits/catch-unwind-cell-interior-mut.stderr +++ b/tests/ui/traits/catch-unwind-cell-interior-mut.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:6:18 + --> $DIR/catch-unwind-cell-interior-mut.rs:7:18 | LL | catch_unwind(|| { x.set(23); }); | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary @@ -11,7 +11,7 @@ note: required because it appears within the type `Cell` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell` to implement `UnwindSafe` note: required because it's used within this closure - --> $DIR/interior-mutability.rs:6:18 + --> $DIR/catch-unwind-cell-interior-mut.rs:7:18 | LL | catch_unwind(|| { x.set(23); }); | ^^