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
This commit is contained in:
parent
77afccf73b
commit
a4a79500b5
16 changed files with 134 additions and 141 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
@ -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`.
|
||||
|
|
@ -1,22 +1,41 @@
|
|||
//@ dont-require-annotations: NOTE
|
||||
//! regression test for <https://github.com/rust-lang/rust/issues/17740>
|
||||
|
||||
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() {}
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -1,5 +1,22 @@
|
|||
fn b(foo: u32, &mut self) { }
|
||||
//! regression test for <https://github.com/rust-lang/rust/issues/55972>
|
||||
|
||||
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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
//! related issue: <https://github.com/rust-lang/rust/issues/40313>
|
||||
//@ compile-flags: -Zwrite-long-types-to-disk=yes
|
||||
use std::cell::Cell;
|
||||
use std::panic::catch_unwind;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the type `UnsafeCell<i32>` 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<i32>` 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<i32>`
|
|||
--> $SRC_DIR/core/src/cell.rs:LL:COL
|
||||
= note: required for `&Cell<i32>` 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); });
|
||||
| ^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue