Run rustfmt on modified tests

This commit is contained in:
Esteban Küber 2024-05-07 19:45:51 +00:00
parent d1d585d039
commit ee5a157b4a
23 changed files with 122 additions and 110 deletions

View File

@ -5,13 +5,10 @@ struct Foo {
}
impl Foo {
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
x
//~^ ERROR lifetime may not live long enough
}
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
x
//~^ ERROR lifetime may not live long enough
}
}
fn main() {}

View File

@ -5,13 +5,10 @@ struct Foo {
}
impl Foo {
fn foo<'a>(&self, x: &'a i32) -> &i32 {
x
//~^ ERROR lifetime may not live long enough
}
fn foo<'a>(&self, x: &'a i32) -> &i32 {
x
//~^ ERROR lifetime may not live long enough
}
}
fn main() {}

View File

@ -1,18 +1,17 @@
error: lifetime may not live long enough
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:10:5
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:9:9
|
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
| -- - let's call the lifetime of this reference `'1`
| |
| lifetime `'a` defined here
LL |
LL | x
| ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
| -- - let's call the lifetime of this reference `'1`
| |
| lifetime `'a` defined here
LL | x
| ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
|
help: consider introducing a named lifetime parameter and update trait if needed
|
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
| ++ ++
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
| ++ ++
error: aborting due to 1 previous error

View File

@ -1,14 +1,14 @@
//@ run-rustfix
#![allow(dead_code)]
struct Foo {
field: i32,
field: i32,
}
impl Foo {
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
x
//~^ ERROR lifetime may not live long enough
}
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
x
//~^ ERROR lifetime may not live long enough
}
}
fn main() { }
fn main() {}

View File

@ -1,14 +1,14 @@
//@ run-rustfix
#![allow(dead_code)]
struct Foo {
field: i32,
field: i32,
}
impl Foo {
fn foo<'a>(&self, x: &i32) -> &i32 {
x
//~^ ERROR lifetime may not live long enough
}
fn foo<'a>(&self, x: &i32) -> &i32 {
x
//~^ ERROR lifetime may not live long enough
}
}
fn main() { }
fn main() {}

View File

@ -1,17 +1,17 @@
error: lifetime may not live long enough
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:5
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:9
|
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
| - - let's call the lifetime of this reference `'1`
| |
| let's call the lifetime of this reference `'2`
LL | x
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
| - - let's call the lifetime of this reference `'1`
| |
| let's call the lifetime of this reference `'2`
LL | x
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
help: consider introducing a named lifetime parameter and update trait if needed
|
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
| ++ ++ ++
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
| ++ ++ ++
error: aborting due to 1 previous error

View File

@ -3,20 +3,23 @@ use std::pin::Pin;
struct Foo;
impl Foo {
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
//~^ lifetime may not live long enough
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo {
f //~ ERROR lifetime may not live long enough
}
// For this suggestion to be right, we'd need to also suggest `self: Pin<&'a Self>`, which we
// don't, but we provide a follow up suggestion to do so, so I condider that good at least for
// now.
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
//~^ lifetime may not live long enough
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) {
(self, f) //~ ERROR lifetime may not live long enough
}
}
type Alias<T> = Pin<T>;
impl Foo {
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
//~^ lifetime may not live long enough
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() {
arg //~ ERROR lifetime may not live long enough
}
}
fn main() {}

View File

@ -1,42 +1,46 @@
error: lifetime may not live long enough
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:7:9
|
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
| - - ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
| | |
| | let's call the lifetime of this reference `'1`
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo {
| - - let's call the lifetime of this reference `'1`
| |
| let's call the lifetime of this reference `'2`
LL | f
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
help: consider introducing a named lifetime parameter and update trait if needed
|
LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { f }
LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:12:69
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:9
|
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
| - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
| | |
| | let's call the lifetime of this reference `'1`
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) {
| - - let's call the lifetime of this reference `'1`
| |
| let's call the lifetime of this reference `'2`
LL | (self, f)
| ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
|
help: consider introducing a named lifetime parameter and update trait if needed
|
LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { (self, f) }
LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) {
| ++++ ++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:18:58
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:9
|
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
| -- ---- has type `Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() {
| -- ---- has type `Pin<&'1 Foo>`
| |
| lifetime `'a` defined here
LL | arg
| ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
|
help: consider introducing a named lifetime parameter and update trait if needed
|
LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { arg }
LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () {
| ++ ++
error: aborting due to 3 previous errors

View File

@ -4,7 +4,9 @@
use std::pin::Pin;
struct Struct<'a> { data: &'a u32 }
struct Struct<'a> {
data: &'a u32,
}
impl<'a> Struct<'a> {
// Test using `&self` sugar:
@ -42,4 +44,4 @@ impl<'a> Struct<'a> {
}
}
fn main() { }
fn main() {}

View File

@ -4,7 +4,9 @@
use std::pin::Pin;
struct Struct<'a> { data: &'a u32 }
struct Struct<'a> {
data: &'a u32,
}
impl<'a> Struct<'a> {
// Test using `&self` sugar:
@ -42,4 +44,4 @@ impl<'a> Struct<'a> {
}
}
fn main() { }
fn main() {}

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:13:9
--> $DIR/lt-ref-self-async.rs:15:9
|
LL | async fn ref_self(&self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -14,7 +14,7 @@ LL | async fn ref_self<'b>(&'b self, f: &'b u32) -> &u32 {
| ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:20:9
--> $DIR/lt-ref-self-async.rs:22:9
|
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -29,7 +29,7 @@ LL | async fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &u32 {
| ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:25:9
--> $DIR/lt-ref-self-async.rs:27:9
|
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -44,7 +44,7 @@ LL | async fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &u32 {
| ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:30:9
--> $DIR/lt-ref-self-async.rs:32:9
|
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -59,7 +59,7 @@ LL | async fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &u32 {
| ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:35:9
--> $DIR/lt-ref-self-async.rs:37:9
|
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -74,7 +74,7 @@ LL | async fn box_box_ref_Self<'b>(self: Box<Box<&'b Self>>, f: &'b u32) ->
| ++++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self-async.rs:40:9
--> $DIR/lt-ref-self-async.rs:42:9
|
LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`

View File

@ -3,7 +3,9 @@
use std::pin::Pin;
struct Struct<'a> { data: &'a u32 }
struct Struct<'a> {
data: &'a u32,
}
impl<'a> Struct<'a> {
// Test using `&self` sugar:
@ -41,4 +43,4 @@ impl<'a> Struct<'a> {
}
}
fn main() { }
fn main() {}

View File

@ -3,7 +3,9 @@
use std::pin::Pin;
struct Struct<'a> { data: &'a u32 }
struct Struct<'a> {
data: &'a u32,
}
impl<'a> Struct<'a> {
// Test using `&self` sugar:
@ -41,4 +43,4 @@ impl<'a> Struct<'a> {
}
}
fn main() { }
fn main() {}

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:12:9
--> $DIR/lt-ref-self.rs:14:9
|
LL | fn ref_self(&self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -14,7 +14,7 @@ LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:19:9
--> $DIR/lt-ref-self.rs:21:9
|
LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -29,7 +29,7 @@ LL | fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:24:9
--> $DIR/lt-ref-self.rs:26:9
|
LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -44,7 +44,7 @@ LL | fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:29:9
--> $DIR/lt-ref-self.rs:31:9
|
LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:34:9
--> $DIR/lt-ref-self.rs:36:9
|
LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'b>(self: Box<Box<&'b Self>>, f: &'b u32) -> &'b u3
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/lt-ref-self.rs:39:9
--> $DIR/lt-ref-self.rs:41:9
|
LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&mut self` sugar:
@ -41,4 +41,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&mut self` sugar:
@ -41,4 +41,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&mut Struct` explicitly:
@ -34,4 +34,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&mut Struct` explicitly:
@ -34,4 +34,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -12,7 +12,9 @@ struct Wrap<T, P>(T, PhantomData<P>);
impl<T, P> Deref for Wrap<T, P> {
type Target = T;
fn deref(&self) -> &T { &self.0 }
fn deref(&self) -> &T {
&self.0
}
}
impl Struct {
@ -56,4 +58,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -12,7 +12,9 @@ struct Wrap<T, P>(T, PhantomData<P>);
impl<T, P> Deref for Wrap<T, P> {
type Target = T;
fn deref(&self) -> &T { &self.0 }
fn deref(&self) -> &T {
&self.0
}
}
impl Struct {
@ -56,4 +58,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/ref-self.rs:22:9
--> $DIR/ref-self.rs:24:9
|
LL | fn ref_self(&self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -14,7 +14,7 @@ LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:29:9
--> $DIR/ref-self.rs:31:9
|
LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -29,7 +29,7 @@ LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:34:9
--> $DIR/ref-self.rs:36:9
|
LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -44,7 +44,7 @@ LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:39:9
--> $DIR/ref-self.rs:41:9
|
LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 {
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:44:9
--> $DIR/ref-self.rs:46:9
|
LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &'a u3
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:49:9
--> $DIR/ref-self.rs:51:9
|
LL | fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
| - - let's call the lifetime of this reference `'1`
@ -89,7 +89,7 @@ LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &'a u3
| ++++ ++ ++ ++
error: lifetime may not live long enough
--> $DIR/ref-self.rs:54:9
--> $DIR/ref-self.rs:56:9
|
LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
| - - let's call the lifetime of this reference `'1`

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&Struct` explicitly:
@ -34,4 +34,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}

View File

@ -3,7 +3,7 @@
use std::pin::Pin;
struct Struct { }
struct Struct {}
impl Struct {
// Test using `&Struct` explicitly:
@ -34,4 +34,4 @@ impl Struct {
}
}
fn main() { }
fn main() {}