From a1df1329ced590a287558510878feb17509e09b5 Mon Sep 17 00:00:00 2001 From: chansuke Date: Thu, 18 Jul 2019 01:43:10 +0900 Subject: [PATCH 01/32] Deduplicate some error messages --- src/librustc_mir/const_eval.rs | 11 +++++++---- src/librustc_mir/interpret/intern.rs | 6 +----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 37d4c5b2f09ce..78be2de019ab7 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -527,6 +527,12 @@ pub fn error_to_const_error<'mir, 'tcx>( ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span } } +pub fn note_on_undefined_behavior_error() -> &'static str { + "The rules on what exactly is undefined behavior aren't clear, \ + so this check might be overzealous. Please open an issue on the rust compiler \ + repository if you believe it should not be considered undefined behavior" +} + fn validate_and_turn_into_const<'tcx>( tcx: TyCtxt<'tcx>, constant: RawConst<'tcx>, @@ -567,10 +573,7 @@ fn validate_and_turn_into_const<'tcx>( let err = error_to_const_error(&ecx, error); match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") { Ok(mut diag) => { - diag.note("The rules on what exactly is undefined behavior aren't clear, \ - so this check might be overzealous. Please open an issue on the rust compiler \ - repository if you believe it should not be considered undefined behavior", - ); + diag.note(note_on_undefined_behavior_error()); diag.emit(); ErrorHandled::Reported } diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index bcd36ac547c73..ea32bd0d52ae1 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -297,11 +297,7 @@ pub fn intern_const_alloc_recursive( let err = crate::const_eval::error_to_const_error(&ecx, error); match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") { Ok(mut diag) => { - diag.note("The rules on what exactly is undefined behavior aren't clear, \ - so this check might be overzealous. Please open an issue on the rust \ - compiler repository if you believe it should not be considered \ - undefined behavior", - ); + diag.note(crate::const_eval::note_on_undefined_behavior_error()); diag.emit(); } Err(ErrorHandled::TooGeneric) | From 43a2cbdfd33b02be90ab1616e1b706142fa5d498 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 15:06:26 +0200 Subject: [PATCH 02/32] lifetime elision: add conforming-to-fn tests. --- src/test/ui/self/elision/alias-async.rs | 39 +++++++++++++++ src/test/ui/self/elision/assoc-async.rs | 43 +++++++++++++++++ src/test/ui/self/elision/lt-alias-async.rs | 41 ++++++++++++++++ src/test/ui/self/elision/lt-assoc-async.rs | 53 +++++++++++++++++++++ src/test/ui/self/elision/lt-self-async.rs | 52 ++++++++++++++++++++ src/test/ui/self/elision/lt-struct-async.rs | 39 +++++++++++++++ src/test/ui/self/elision/self-async.rs | 39 +++++++++++++++ src/test/ui/self/elision/struct-async.rs | 35 ++++++++++++++ 8 files changed, 341 insertions(+) create mode 100644 src/test/ui/self/elision/alias-async.rs create mode 100644 src/test/ui/self/elision/assoc-async.rs create mode 100644 src/test/ui/self/elision/lt-alias-async.rs create mode 100644 src/test/ui/self/elision/lt-assoc-async.rs create mode 100644 src/test/ui/self/elision/lt-self-async.rs create mode 100644 src/test/ui/self/elision/lt-struct-async.rs create mode 100644 src/test/ui/self/elision/self-async.rs create mode 100644 src/test/ui/self/elision/struct-async.rs diff --git a/src/test/ui/self/elision/alias-async.rs b/src/test/ui/self/elision/alias-async.rs new file mode 100644 index 0000000000000..3d5b24a8946aa --- /dev/null +++ b/src/test/ui/self/elision/alias-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +type Alias = Struct; + +impl Struct { + // Test using an alias for `Struct`: + + async fn alias(self: Alias, f: &u32) -> &u32 { + f + } + + async fn box_Alias(self: Box, f: &u32) -> &u32 { + f + } + + async fn rc_Alias(self: Rc, f: &u32) -> &u32 { + f + } + + async fn box_box_Alias(self: Box>, f: &u32) -> &u32 { + f + } + + async fn box_rc_Alias(self: Box>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/assoc-async.rs b/src/test/ui/self/elision/assoc-async.rs new file mode 100644 index 0000000000000..0f33f2887726c --- /dev/null +++ b/src/test/ui/self/elision/assoc-async.rs @@ -0,0 +1,43 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +trait Trait { + type AssocType; +} + +struct Struct { } + +impl Trait for Struct { + type AssocType = Self; +} + +impl Struct { + async fn assoc(self: ::AssocType, f: &u32) -> &u32 { + f + } + + async fn box_AssocType(self: Box<::AssocType>, f: &u32) -> &u32 { + f + } + + async fn rc_AssocType(self: Rc<::AssocType>, f: &u32) -> &u32 { + f + } + + async fn box_box_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + f + } + + async fn box_rc_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-alias-async.rs b/src/test/ui/self/elision/lt-alias-async.rs new file mode 100644 index 0000000000000..5a8989f078ef3 --- /dev/null +++ b/src/test/ui/self/elision/lt-alias-async.rs @@ -0,0 +1,41 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct<'a> { x: &'a u32 } + +type Alias<'a> = Struct<'a>; + +impl<'a> Alias<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Alias(self: Alias<'a>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Alias(self: Box>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Alias(self: Box>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Alias(self: Rc>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Alias(self: Box>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-assoc-async.rs b/src/test/ui/self/elision/lt-assoc-async.rs new file mode 100644 index 0000000000000..98c9aa3b6c26a --- /dev/null +++ b/src/test/ui/self/elision/lt-assoc-async.rs @@ -0,0 +1,53 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +trait Trait { + type AssocType; +} + +struct Struct<'a> { x: &'a u32 } + +impl<'a> Trait for Struct<'a> { + type AssocType = Self; +} + +impl<'a> Struct<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_AssocType(self: as Trait>::AssocType, f: &u32) -> &u32 { + f + } + + async fn take_Box_AssocType(self: Box< as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_AssocType( + self: Box as Trait>::AssocType>>, + f: &u32 + ) -> &u32 { + f + } + + async fn take_Rc_AssocType(self: Rc< as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_AssocType( + self: Box as Trait>::AssocType>>, + f: &u32 + ) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-self-async.rs b/src/test/ui/self/elision/lt-self-async.rs new file mode 100644 index 0000000000000..0202db8a63526 --- /dev/null +++ b/src/test/ui/self/elision/lt-self-async.rs @@ -0,0 +1,52 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; +use std::rc::Rc; + +struct Struct<'a> { + x: &'a u32 +} + +impl<'a> Struct<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Self(self: Self, f: &u32) -> &u32 { + f + } + + async fn take_Box_Self(self: Box, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Self(self: Box>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Self(self: Rc, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Self(self: Box>, f: &u32) -> &u32 { + f + } + + // N/A + //fn take_Pin_Self(self: Pin, f: &u32) -> &u32 { + // f + //} + + // N/A + //fn take_Box_Pin_Self(self: Box>, f: &u32) -> &u32 { + // f + //} +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-struct-async.rs b/src/test/ui/self/elision/lt-struct-async.rs new file mode 100644 index 0000000000000..c0fc63d423257 --- /dev/null +++ b/src/test/ui/self/elision/lt-struct-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct<'a> { x: &'a u32 } + +impl<'a> Struct<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Struct(self: Struct<'a>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Struct(self: Box>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Struct(self: Box>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Struct(self: Rc>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Struct(self: Box>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/self-async.rs b/src/test/ui/self/elision/self-async.rs new file mode 100644 index 0000000000000..d1dc050be0d1e --- /dev/null +++ b/src/test/ui/self/elision/self-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +impl Struct { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Self(self: Self, f: &u32) -> &u32 { + f + } + + async fn take_Box_Self(self: Box, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Self(self: Box>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Self(self: Rc, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Self(self: Box>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/struct-async.rs b/src/test/ui/self/elision/struct-async.rs new file mode 100644 index 0000000000000..f7c8591ebd31d --- /dev/null +++ b/src/test/ui/self/elision/struct-async.rs @@ -0,0 +1,35 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +impl Struct { + async fn ref_Struct(self: Struct, f: &u32) -> &u32 { + f + } + + async fn box_Struct(self: Box, f: &u32) -> &u32 { + f + } + + async fn rc_Struct(self: Rc, f: &u32) -> &u32 { + f + } + + async fn box_box_Struct(self: Box>, f: &u32) -> &u32 { + f + } + + async fn box_rc_Struct(self: Box>, f: &u32) -> &u32 { + f + } +} + +fn main() { } From a69478242d152558a9fd60c8d1c4a20cc530a081 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 15:57:32 +0200 Subject: [PATCH 03/32] lifetime elision: add non-conforming-to-fn tests. --- .../self/elision/lt-ref-self-async.nll.stderr | 51 +++++ src/test/ui/self/elision/lt-ref-self-async.rs | 54 +++++ .../ui/self/elision/lt-ref-self-async.stderr | 159 +++++++++++++++ .../multiple-ref-self-async.nll.stderr | 43 ++++ .../self/elision/multiple-ref-self-async.rs | 55 ++++++ .../elision/multiple-ref-self-async.stderr | 133 +++++++++++++ .../self/elision/ref-alias-async.nll.stderr | 43 ++++ src/test/ui/self/elision/ref-alias-async.rs | 51 +++++ .../ui/self/elision/ref-alias-async.stderr | 133 +++++++++++++ .../self/elision/ref-assoc-async.nll.stderr | 43 ++++ src/test/ui/self/elision/ref-assoc-async.rs | 52 +++++ .../ui/self/elision/ref-assoc-async.stderr | 133 +++++++++++++ .../elision/ref-mut-alias-async.nll.stderr | 43 ++++ .../ui/self/elision/ref-mut-alias-async.rs | 48 +++++ .../self/elision/ref-mut-alias-async.stderr | 133 +++++++++++++ .../elision/ref-mut-self-async.nll.stderr | 51 +++++ .../ui/self/elision/ref-mut-self-async.rs | 54 +++++ .../ui/self/elision/ref-mut-self-async.stderr | 159 +++++++++++++++ .../elision/ref-mut-struct-async.nll.stderr | 43 ++++ .../ui/self/elision/ref-mut-struct-async.rs | 46 +++++ .../self/elision/ref-mut-struct-async.stderr | 133 +++++++++++++ .../ui/self/elision/ref-self-async.nll.stderr | 59 ++++++ src/test/ui/self/elision/ref-self-async.rs | 69 +++++++ .../ui/self/elision/ref-self-async.stderr | 185 ++++++++++++++++++ .../self/elision/ref-struct-async.nll.stderr | 43 ++++ src/test/ui/self/elision/ref-struct-async.rs | 46 +++++ .../ui/self/elision/ref-struct-async.stderr | 133 +++++++++++++ 27 files changed, 2195 insertions(+) create mode 100644 src/test/ui/self/elision/lt-ref-self-async.nll.stderr create mode 100644 src/test/ui/self/elision/lt-ref-self-async.rs create mode 100644 src/test/ui/self/elision/lt-ref-self-async.stderr create mode 100644 src/test/ui/self/elision/multiple-ref-self-async.nll.stderr create mode 100644 src/test/ui/self/elision/multiple-ref-self-async.rs create mode 100644 src/test/ui/self/elision/multiple-ref-self-async.stderr create mode 100644 src/test/ui/self/elision/ref-alias-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-alias-async.rs create mode 100644 src/test/ui/self/elision/ref-alias-async.stderr create mode 100644 src/test/ui/self/elision/ref-assoc-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-assoc-async.rs create mode 100644 src/test/ui/self/elision/ref-assoc-async.stderr create mode 100644 src/test/ui/self/elision/ref-mut-alias-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-mut-alias-async.rs create mode 100644 src/test/ui/self/elision/ref-mut-alias-async.stderr create mode 100644 src/test/ui/self/elision/ref-mut-self-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-mut-self-async.rs create mode 100644 src/test/ui/self/elision/ref-mut-self-async.stderr create mode 100644 src/test/ui/self/elision/ref-mut-struct-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-mut-struct-async.rs create mode 100644 src/test/ui/self/elision/ref-mut-struct-async.stderr create mode 100644 src/test/ui/self/elision/ref-self-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-self-async.rs create mode 100644 src/test/ui/self/elision/ref-self-async.stderr create mode 100644 src/test/ui/self/elision/ref-struct-async.nll.stderr create mode 100644 src/test/ui/self/elision/ref-struct-async.rs create mode 100644 src/test/ui/self/elision/ref-struct-async.stderr diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr new file mode 100644 index 0000000000000..d3aeb73b9b7c2 --- /dev/null +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -0,0 +1,51 @@ +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:15:42 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:23:48 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:29:57 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:35:57 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:41:66 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:47:62 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/lt-ref-self-async.rs b/src/test/ui/self/elision/lt-ref-self-async.rs new file mode 100644 index 0000000000000..84b91ba08b75d --- /dev/null +++ b/src/test/ui/self/elision/lt-ref-self-async.rs @@ -0,0 +1,54 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct<'a> { data: &'a u32 } + +impl<'a> Struct<'a> { + // Test using `&self` sugar: + + async fn ref_self(&self, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } + + // Test using `&Self` explicitly: + + async fn ref_Self(self: &Self, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } + + async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } + + async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } + + async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } + + async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-ref-self-async.stderr b/src/test/ui/self/elision/lt-ref-self-async.stderr new file mode 100644 index 0000000000000..56595d008a6bf --- /dev/null +++ b/src/test/ui/self/elision/lt-ref-self-async.stderr @@ -0,0 +1,159 @@ +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:15:42 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:23:48 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:29:57 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:35:57 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:41:66 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/lt-ref-self-async.rs:47:62 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:15:30 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 + --> $DIR/lt-ref-self-async.rs:15:23 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:23:36 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 + --> $DIR/lt-ref-self-async.rs:23:29 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:29:45 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 + --> $DIR/lt-ref-self-async.rs:29:37 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:35:45 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 + --> $DIR/lt-ref-self-async.rs:35:37 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:41:54 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 + --> $DIR/lt-ref-self-async.rs:41:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/lt-ref-self-async.rs:47:50 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 47:41 + --> $DIR/lt-ref-self-async.rs:47:41 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:41 + | +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr b/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr new file mode 100644 index 0000000000000..00e16cd7f99fb --- /dev/null +++ b/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:24:74 + | +LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:30:84 + | +LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:36:84 + | +LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:42:93 + | +LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:48:93 + | +LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.rs b/src/test/ui/self/elision/multiple-ref-self-async.rs new file mode 100644 index 0000000000000..3cc146c5dc7b2 --- /dev/null +++ b/src/test/ui/self/elision/multiple-ref-self-async.rs @@ -0,0 +1,55 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::marker::PhantomData; +use std::ops::Deref; +use std::pin::Pin; + +struct Struct { } + +struct Wrap(T, PhantomData

); + +impl Deref for Wrap { + type Target = T; + fn deref(&self) -> &T { &self.0 } +} + +impl Struct { + // Test using multiple `&Self`: + + async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/multiple-ref-self-async.stderr b/src/test/ui/self/elision/multiple-ref-self-async.stderr new file mode 100644 index 0000000000000..2a89ed3feba62 --- /dev/null +++ b/src/test/ui/self/elision/multiple-ref-self-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:24:74 + | +LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:30:84 + | +LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:36:84 + | +LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:42:93 + | +LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/multiple-ref-self-async.rs:48:93 + | +LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/multiple-ref-self-async.rs:24:63 + | +LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { + | ^ --- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 24:48 + --> $DIR/multiple-ref-self-async.rs:24:48 + | +LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:48 + | +LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 + '_ { + | ^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/multiple-ref-self-async.rs:30:72 + | +LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 30:56 + --> $DIR/multiple-ref-self-async.rs:30:56 + | +LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 30:56 + | +LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/multiple-ref-self-async.rs:36:72 + | +LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 36:56 + --> $DIR/multiple-ref-self-async.rs:36:56 + | +LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 36:56 + | +LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/multiple-ref-self-async.rs:42:81 + | +LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 42:64 + --> $DIR/multiple-ref-self-async.rs:42:64 + | +LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 42:64 + | +LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/multiple-ref-self-async.rs:48:81 + | +LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 48:64 + --> $DIR/multiple-ref-self-async.rs:48:64 + | +LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 48:64 + | +LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.nll.stderr b/src/test/ui/self/elision/ref-alias-async.nll.stderr new file mode 100644 index 0000000000000..7e47b3794035f --- /dev/null +++ b/src/test/ui/self/elision/ref-alias-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:20:50 + | +LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:26:59 + | +LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:32:59 + | +LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:38:68 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:44:68 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.rs b/src/test/ui/self/elision/ref-alias-async.rs new file mode 100644 index 0000000000000..224151b9b0c55 --- /dev/null +++ b/src/test/ui/self/elision/ref-alias-async.rs @@ -0,0 +1,51 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct { } + +type Alias = Struct; + +impl Struct { + // Test using an alias for `Struct`: + // + // FIXME. We currently fail to recognize this as the self type, which + // feels like a bug. + + async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-alias-async.stderr b/src/test/ui/self/elision/ref-alias-async.stderr new file mode 100644 index 0000000000000..a3250562c6fff --- /dev/null +++ b/src/test/ui/self/elision/ref-alias-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:20:50 + | +LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:26:59 + | +LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:32:59 + | +LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:38:68 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-alias-async.rs:44:68 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-alias-async.rs:20:38 + | +LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 20:30 + --> $DIR/ref-alias-async.rs:20:30 + | +LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 20:30 + | +LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-alias-async.rs:26:47 + | +LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 26:38 + --> $DIR/ref-alias-async.rs:26:38 + | +LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 26:38 + | +LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-alias-async.rs:32:47 + | +LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 32:38 + --> $DIR/ref-alias-async.rs:32:38 + | +LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:38 + | +LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-alias-async.rs:38:56 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 38:46 + --> $DIR/ref-alias-async.rs:38:46 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:46 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-alias-async.rs:44:56 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 44:46 + --> $DIR/ref-alias-async.rs:44:46 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:46 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.nll.stderr b/src/test/ui/self/elision/ref-assoc-async.nll.stderr new file mode 100644 index 0000000000000..25c8bf652d84b --- /dev/null +++ b/src/test/ui/self/elision/ref-assoc-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:21:77 + | +LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:27:86 + | +LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:33:86 + | +LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:39:95 + | +LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:45:95 + | +LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.rs b/src/test/ui/self/elision/ref-assoc-async.rs new file mode 100644 index 0000000000000..380937e61ca3f --- /dev/null +++ b/src/test/ui/self/elision/ref-assoc-async.rs @@ -0,0 +1,52 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +trait Trait { + type AssocType; +} + +struct Struct { } + +impl Trait for Struct { + type AssocType = Self; +} + +impl Struct { + async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-assoc-async.stderr b/src/test/ui/self/elision/ref-assoc-async.stderr new file mode 100644 index 0000000000000..c2e893a3f58bf --- /dev/null +++ b/src/test/ui/self/elision/ref-assoc-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:21:77 + | +LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:27:86 + | +LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:33:86 + | +LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:39:95 + | +LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-assoc-async.rs:45:95 + | +LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-assoc-async.rs:21:65 + | +LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 21:34 + --> $DIR/ref-assoc-async.rs:21:34 + | +LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:34 + | +LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-assoc-async.rs:27:74 + | +LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 27:42 + --> $DIR/ref-assoc-async.rs:27:42 + | +LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:42 + | +LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-assoc-async.rs:33:74 + | +LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 33:42 + --> $DIR/ref-assoc-async.rs:33:42 + | +LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:42 + | +LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-assoc-async.rs:39:83 + | +LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 39:50 + --> $DIR/ref-assoc-async.rs:39:50 + | +LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:50 + | +LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-assoc-async.rs:45:83 + | +LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 45:50 + --> $DIR/ref-assoc-async.rs:45:50 + | +LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 45:50 + | +LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr b/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr new file mode 100644 index 0000000000000..1026a0b492f34 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:17:54 + | +LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:23:63 + | +LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:29:63 + | +LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:35:72 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:41:72 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.rs b/src/test/ui/self/elision/ref-mut-alias-async.rs new file mode 100644 index 0000000000000..ce66313bddd12 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-alias-async.rs @@ -0,0 +1,48 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct { } + +type Alias = Struct; + +impl Struct { + // Test using an alias for `Struct`: + + async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-mut-alias-async.stderr b/src/test/ui/self/elision/ref-mut-alias-async.stderr new file mode 100644 index 0000000000000..678bf74518606 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-alias-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:17:54 + | +LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:23:63 + | +LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:29:63 + | +LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:35:72 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-alias-async.rs:41:72 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-alias-async.rs:17:42 + | +LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 17:30 + --> $DIR/ref-mut-alias-async.rs:17:30 + | +LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 17:30 + | +LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-alias-async.rs:23:51 + | +LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 23:38 + --> $DIR/ref-mut-alias-async.rs:23:38 + | +LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:38 + | +LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-alias-async.rs:29:51 + | +LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 29:38 + --> $DIR/ref-mut-alias-async.rs:29:38 + | +LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:38 + | +LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-alias-async.rs:35:60 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 35:46 + --> $DIR/ref-mut-alias-async.rs:35:46 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:46 + | +LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-alias-async.rs:41:60 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 41:46 + --> $DIR/ref-mut-alias-async.rs:41:46 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:46 + | +LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr new file mode 100644 index 0000000000000..35969659b19d1 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -0,0 +1,51 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:15:46 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:23:52 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:29:61 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:35:61 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:41:70 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:47:70 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.rs b/src/test/ui/self/elision/ref-mut-self-async.rs new file mode 100644 index 0000000000000..7d143e1b35e45 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-self-async.rs @@ -0,0 +1,54 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&mut self` sugar: + + async fn ref_self(&mut self, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + // Test using `&mut Self` explicitly: + + async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr new file mode 100644 index 0000000000000..15f5f8dd0dd48 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -0,0 +1,159 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:15:46 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:23:52 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:29:61 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:35:61 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:41:70 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-self-async.rs:47:70 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:15:34 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 + --> $DIR/ref-mut-self-async.rs:15:23 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:23:40 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 + --> $DIR/ref-mut-self-async.rs:23:29 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:29:49 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 + --> $DIR/ref-mut-self-async.rs:29:37 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 + | +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:35:49 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 + --> $DIR/ref-mut-self-async.rs:35:37 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 + | +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:41:58 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 + --> $DIR/ref-mut-self-async.rs:41:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-self-async.rs:47:58 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 47:45 + --> $DIR/ref-mut-self-async.rs:47:45 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:45 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr new file mode 100644 index 0000000000000..a70dcf5b0ad19 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:15:56 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:21:65 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:27:65 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:33:74 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:39:74 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.rs b/src/test/ui/self/elision/ref-mut-struct-async.rs new file mode 100644 index 0000000000000..3ba9c95d35ff4 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-struct-async.rs @@ -0,0 +1,46 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&mut Struct` explicitly: + + async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-mut-struct-async.stderr b/src/test/ui/self/elision/ref-mut-struct-async.stderr new file mode 100644 index 0000000000000..fd2581eba9434 --- /dev/null +++ b/src/test/ui/self/elision/ref-mut-struct-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:15:56 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:21:65 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:27:65 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:33:74 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-mut-struct-async.rs:39:74 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-struct-async.rs:15:44 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 + --> $DIR/ref-mut-struct-async.rs:15:31 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-struct-async.rs:21:53 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 + --> $DIR/ref-mut-struct-async.rs:21:39 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-struct-async.rs:27:53 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 + --> $DIR/ref-mut-struct-async.rs:27:39 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 + | +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-struct-async.rs:33:62 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 + --> $DIR/ref-mut-struct-async.rs:33:47 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-mut-struct-async.rs:39:62 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 39:47 + --> $DIR/ref-mut-struct-async.rs:39:47 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:47 + | +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr new file mode 100644 index 0000000000000..ae17ba9839d22 --- /dev/null +++ b/src/test/ui/self/elision/ref-self-async.nll.stderr @@ -0,0 +1,59 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:24:42 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:32:48 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:38:57 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:44:57 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:50:66 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:56:66 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:62:69 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-self-async.rs b/src/test/ui/self/elision/ref-self-async.rs new file mode 100644 index 0000000000000..6cca5494ff784 --- /dev/null +++ b/src/test/ui/self/elision/ref-self-async.rs @@ -0,0 +1,69 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::marker::PhantomData; +use std::ops::Deref; +use std::pin::Pin; + +struct Struct { } + +struct Wrap(T, PhantomData

); + +impl Deref for Wrap { + type Target = T; + fn deref(&self) -> &T { &self.0 } +} + +impl Struct { + // Test using `&self` sugar: + + async fn ref_self(&self, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + // Test using `&Self` explicitly: + + async fn ref_Self(self: &Self, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr new file mode 100644 index 0000000000000..eab77cfacd956 --- /dev/null +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -0,0 +1,185 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:24:42 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:32:48 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:38:57 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:44:57 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:50:66 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:56:66 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-self-async.rs:62:69 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:24:30 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 24:23 + --> $DIR/ref-self-async.rs:24:23 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:23 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:32:36 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 32:29 + --> $DIR/ref-self-async.rs:32:29 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:29 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:38:45 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 38:37 + --> $DIR/ref-self-async.rs:38:37 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:37 + | +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:44:45 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 44:37 + --> $DIR/ref-self-async.rs:44:37 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:37 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:50:54 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 50:45 + --> $DIR/ref-self-async.rs:50:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 50:45 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:56:54 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 56:45 + --> $DIR/ref-self-async.rs:56:45 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 56:45 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-self-async.rs:62:58 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ^ --- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 62:44 + --> $DIR/ref-self-async.rs:62:44 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 62:44 + | +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 + '_ { + | ^^^^^^^^ + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr new file mode 100644 index 0000000000000..b4f12d7057db4 --- /dev/null +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -0,0 +1,43 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:15:52 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:21:61 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:27:61 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:33:70 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:39:66 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-struct-async.rs b/src/test/ui/self/elision/ref-struct-async.rs new file mode 100644 index 0000000000000..cd0f5a2a6058d --- /dev/null +++ b/src/test/ui/self/elision/ref-struct-async.rs @@ -0,0 +1,46 @@ +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&Struct` explicitly: + + async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } + + async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/ref-struct-async.stderr b/src/test/ui/self/elision/ref-struct-async.stderr new file mode 100644 index 0000000000000..966e102fa5f27 --- /dev/null +++ b/src/test/ui/self/elision/ref-struct-async.stderr @@ -0,0 +1,133 @@ +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:15:52 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:21:61 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:27:61 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:33:70 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/ref-struct-async.rs:39:66 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/ref-struct-async.rs:15:40 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 + --> $DIR/ref-struct-async.rs:15:31 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-struct-async.rs:21:49 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 + --> $DIR/ref-struct-async.rs:21:39 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-struct-async.rs:27:49 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 + --> $DIR/ref-struct-async.rs:27:39 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 + | +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-struct-async.rs:33:58 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 + --> $DIR/ref-struct-async.rs:33:47 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 + | +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/ref-struct-async.rs:39:54 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 39:43 + --> $DIR/ref-struct-async.rs:39:43 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:43 + | +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 + '_ { + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0106`. From d9294a284d6f10170effe2f29c2cd7ae94992d36 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 16:00:46 +0200 Subject: [PATCH 04/32] lifetime elision: document conformance of 'async fn' to 'fn'. --- src/test/ui/self/elision/README.md | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/ui/self/elision/README.md b/src/test/ui/self/elision/README.md index 7ace2e0c89039..c4f06433ba709 100644 --- a/src/test/ui/self/elision/README.md +++ b/src/test/ui/self/elision/README.md @@ -42,3 +42,34 @@ In each case, we test the following patterns: - `self: Box>` In the non-reference cases, `Pin` causes errors so we substitute `Rc`. + +### `async fn` + +For each of the tests above we also check that `async fn` behaves as an `fn` would. +These tests are in files named `*-async.rs`. + +Legends: +- ✓ ⟹ Yes / Pass +- X ⟹ No +- α ⟹ lifetime mismatch +- β ⟹ cannot infer an appropriate lifetime +- γ ⟹ missing lifetime specifier + +| `async` file | Pass? | Conforms to `fn`? | How does it diverge?
`fn` ⟶ `async fn` | +| --- | --- | --- | --- | +| `self-async.rs` | ✓ | ✓ | N/A | +| `struct-async.rs`| ✓ | ✓ | N/A | +| `alias-async.rs`| ✓ | ✓ | N/A | +| `assoc-async.rs`| ✓ | ✓ | N/A | +| `ref-self-async.rs` | X | X | α ⟶ β + γ | +| `ref-mut-self-async.rs` | X | X | α ⟶ β + γ | +| `ref-struct-async.rs` | X | X | α ⟶ β + γ | +| `ref-mut-struct-async.rs` | X | X | α ⟶ β + γ | +| `ref-alias-async.rs` | X | X | ✓ ⟶ β + γ | +| `ref-assoc-async.rs` | X | X | ✓ ⟶ β + γ | +| `ref-mut-alias-async.rs` | X | X | ✓ ⟶ β + γ | +| `lt-self-async.rs` | ✓ | ✓ | N/A +| `lt-struct-async.rs` | ✓ | ✓ | N/A +| `lt-alias-async.rs` | ✓ | ✓ | N/A +| `lt-assoc-async.rs` | ✓ | ✓ | N/A +| `lt-ref-self-async.rs` | X | X | α ⟶ β + γ From f3957876c81ce45c31895316060e23149c6fb964 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 17:08:30 +0200 Subject: [PATCH 05/32] Add async version of self_lifetime.rs test. --- .../ui/self/self_lifetime-async.nll.stderr | 11 ++++++ src/test/ui/self/self_lifetime-async.rs | 20 ++++++++++ src/test/ui/self/self_lifetime-async.stderr | 39 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/test/ui/self/self_lifetime-async.nll.stderr create mode 100644 src/test/ui/self/self_lifetime-async.rs create mode 100644 src/test/ui/self/self_lifetime-async.stderr diff --git a/src/test/ui/self/self_lifetime-async.nll.stderr b/src/test/ui/self/self_lifetime-async.nll.stderr new file mode 100644 index 0000000000000..805d2433f87ac --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.nll.stderr @@ -0,0 +1,11 @@ +error[E0106]: missing lifetime specifier + --> $DIR/self_lifetime-async.rs:9:44 + | +LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/self_lifetime-async.rs b/src/test/ui/self/self_lifetime-async.rs new file mode 100644 index 0000000000000..71eba01fe1a02 --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.rs @@ -0,0 +1,20 @@ +// FIXME: Investigate why `self_lifetime.rs` is check-pass but this isn't. + +// edition:2018 + +#![feature(async_await)] + +struct Foo<'a>(&'a ()); +impl<'a> Foo<'a> { + async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime +} + +type Alias = Foo<'static>; +impl Alias { + async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } + //~^ ERROR lifetime mismatch +} + +fn main() {} diff --git a/src/test/ui/self/self_lifetime-async.stderr b/src/test/ui/self/self_lifetime-async.stderr new file mode 100644 index 0000000000000..e3ec1abd44763 --- /dev/null +++ b/src/test/ui/self/self_lifetime-async.stderr @@ -0,0 +1,39 @@ +error[E0106]: missing lifetime specifier + --> $DIR/self_lifetime-async.rs:9:44 + | +LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/self_lifetime-async.rs:9:22 + | +LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } + | ^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 8:6... + --> $DIR/self_lifetime-async.rs:8:6 + | +LL | impl<'a> Foo<'a> { + | ^^ + = note: ...so that the expression is assignable: + expected &Foo<'_> + found &'b Foo<'a> + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the types are compatible: + expected &() + found &'static () + +error[E0623]: lifetime mismatch + --> $DIR/self_lifetime-async.rs:16:52 + | +LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } + | ------ ^^^ + | | | + | | ...but data from `arg` is returned here + | this parameter and the return type are declared with different lifetimes... + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0106`. From 5ce8f7a1f98072d9df9fb562526151b83ecfe879 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 8 Aug 2019 18:21:08 +0200 Subject: [PATCH 06/32] Add async versions of arbitrary_self_types_pin_lifetime tests. --- ...arbitrary_self_types_pin_lifetime-async.rs | 37 ++++++++ ...s_pin_lifetime_impl_trait-async.nll.stderr | 14 +++ ...elf_types_pin_lifetime_impl_trait-async.rs | 16 ++++ ...types_pin_lifetime_impl_trait-async.stderr | 20 +++++ ...pes_pin_lifetime_mismatch-async.nll.stderr | 27 ++++++ ..._self_types_pin_lifetime_mismatch-async.rs | 28 ++++++ ...f_types_pin_lifetime_mismatch-async.stderr | 88 +++++++++++++++++++ 7 files changed, 230 insertions(+) create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.nll.stderr create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs create mode 100644 src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs new file mode 100644 index 0000000000000..b853f88a96dde --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime-async.rs @@ -0,0 +1,37 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +use std::pin::Pin; +use std::task::{Context, Poll}; + +struct Foo; + +impl Foo { + async fn pin_ref(self: Pin<&Self>) -> Pin<&Self> { self } + + async fn pin_mut(self: Pin<&mut Self>) -> Pin<&mut Self> { self } + + async fn pin_pin_pin_ref(self: Pin>>) -> Pin>> { self } + + async fn pin_ref_impl_trait(self: Pin<&Self>) -> impl Clone + '_ { self } + + fn b(self: Pin<&Foo>, f: &Foo) -> Pin<&Foo> { self } +} + +type Alias = Pin; +impl Foo { + async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> Alias<&Self> { self } +} + +// FIXME(Centril): extend with the rest of the non-`async fn` test +// when we allow `async fn`s inside traits and trait implementations. + +fn main() { + let mut foo = Foo; + { Pin::new(&foo).pin_ref() }; + { Pin::new(&mut foo).pin_mut() }; + { Pin::new(Pin::new(Pin::new(&foo))).pin_pin_pin_ref() }; + { Pin::new(&foo).pin_ref_impl_trait() }; +} diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.nll.stderr new file mode 100644 index 0000000000000..2421632c664c1 --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.nll.stderr @@ -0,0 +1,14 @@ +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:10:48 + | +LL | async fn f(self: Pin<&Self>) -> impl Clone { self } + | - ^^^^^^^^ returning this value requires that `'_` must outlive `'static` + | | + | lifetime `'_` defined here +help: to allow this `impl Trait` to capture borrowed data with lifetime `'_`, add `'_` as a constraint + | +LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self } + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs new file mode 100644 index 0000000000000..aecb82325c1f2 --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.rs @@ -0,0 +1,16 @@ +// edition:2018 + +#![feature(async_await)] + +use std::pin::Pin; + +struct Foo; + +impl Foo { + async fn f(self: Pin<&Self>) -> impl Clone { self } + //~^ ERROR cannot infer an appropriate lifetime +} + +fn main() { + { Pin::new(&Foo).f() }; +} diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr new file mode 100644 index 0000000000000..f0032449db14e --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -0,0 +1,20 @@ +error: cannot infer an appropriate lifetime + --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:10:16 + | +LL | async fn f(self: Pin<&Self>) -> impl Clone { self } + | ^^^^ ---------- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 10:26 + --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:10:26 + | +LL | async fn f(self: Pin<&Self>) -> impl Clone { self } + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 10:26 + | +LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self } + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr new file mode 100644 index 0000000000000..6585609555675 --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -0,0 +1,27 @@ +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs new file mode 100644 index 0000000000000..93870b7cdcf28 --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs @@ -0,0 +1,28 @@ +// edition:2018 + +#![feature(async_await)] + +use std::pin::Pin; + +struct Foo; + +impl Foo { + async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + // FIXME: should be E0623? + + async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + //~^ ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + //~| ERROR missing lifetime specifier + //~| ERROR cannot infer an appropriate lifetime + // FIXME: should be E0623? +} + +type Alias = Pin; +impl Foo { + async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr new file mode 100644 index 0000000000000..c7d10e7fc780d --- /dev/null +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -0,0 +1,88 @@ +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error[E0106]: missing lifetime specifier + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ + | + = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + +error: cannot infer an appropriate lifetime + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:33 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | ^ ---- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 10:26 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:26 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 10:26 + | +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo + '_ { f } + | ^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:16 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^^^^ ...but this borrow... ----------------- this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:26 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:26 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:34 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ ----------------- this return type evaluates to the `'static` lifetime... + | | + | ...but this borrow... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 15:26 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:26 + | +LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0623]: lifetime mismatch + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:25:58 + | +LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | ----- ^^^ + | | | + | | ...but data from `arg` is returned here + | this parameter and the return type are declared with different lifetimes... + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0106`. From 2644205578b6d5259c59c099cc3d29ab03364931 Mon Sep 17 00:00:00 2001 From: sd234678 Date: Fri, 9 Aug 2019 23:07:51 +0100 Subject: [PATCH 07/32] Remove unneeded comment in src/libcore/hash/mod.rs --- src/libcore/hash/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index c4cbf40a93a15..685540ba6fc26 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -553,8 +553,6 @@ impl PartialEq for BuildHasherDefault { #[stable(since = "1.29.0", feature = "build_hasher_eq")] impl Eq for BuildHasherDefault {} -////////////////////////////////////////////////////////////////////////////// - mod impls { use crate::mem; use crate::slice; From 51ce121592f85a22b8f8f1905525efaa89d07d20 Mon Sep 17 00:00:00 2001 From: Clar Fon Date: Fri, 9 Aug 2019 14:58:09 -0400 Subject: [PATCH 08/32] Implement Clone, Display for ascii::EscapeDefault --- src/libcore/ascii.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/ascii.rs b/src/libcore/ascii.rs index e6a6fdde54042..4087333e2cf6d 100644 --- a/src/libcore/ascii.rs +++ b/src/libcore/ascii.rs @@ -14,6 +14,7 @@ use crate::fmt; use crate::ops::Range; use crate::iter::FusedIterator; +use crate::str::from_utf8_unchecked; /// An iterator over the escaped version of a byte. /// @@ -22,6 +23,7 @@ use crate::iter::FusedIterator; /// /// [`escape_default`]: fn.escape_default.html #[stable(feature = "rust1", since = "1.0.0")] +#[derive(Clone)] pub struct EscapeDefault { range: Range, data: [u8; 4], @@ -130,6 +132,13 @@ impl ExactSizeIterator for EscapeDefault {} #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for EscapeDefault {} +#[stable(feature = "ascii_escape_display", since = "1.39.0")] +impl fmt::Display for EscapeDefault { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(unsafe { from_utf8_unchecked(&self.data[self.range.clone()]) }) + } +} + #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for EscapeDefault { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { From fa7a40cc6ee7e16c948a804dbb487d36b3d0ccc9 Mon Sep 17 00:00:00 2001 From: Observer42 Date: Mon, 12 Aug 2019 16:07:13 +0800 Subject: [PATCH 09/32] Document From trait for BinaryHeap --- src/liballoc/collections/binary_heap.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 9f531f5b83c75..cc6c69d5738ea 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -1163,6 +1163,9 @@ impl FusedIterator for Drain<'_, T> {} #[stable(feature = "binary_heap_extras_15", since = "1.5.0")] impl From> for BinaryHeap { + /// Converts a `Vec` into a `BinaryHeap`. + /// + /// This conversion happens in-place, and has O(n) time complexity. fn from(vec: Vec) -> BinaryHeap { let mut heap = BinaryHeap { data: vec }; heap.rebuild(); From eb832b2a3244166c81d8e00d94805525f3bd7526 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 12 Aug 2019 09:41:06 +0200 Subject: [PATCH 10/32] ci: move mirrors to their standalone bucket Currently mirrors are stored in the rust-lang-ci2 S3 bucket along with CI toolchains. This is problematic for multiple reasons: - CI IAM credentials are allowed to both edit and delete those files. A malicious user gaining access to those credentials would be able to change our mirrored dependencies, possibly backdooring the compiler. - Contents of the rust-lang-ci2 bucket are disposable except for the mirrors' content. When we implement backups for S3 buckets we'd have to replicate just that part of the bucket, complicating the backup logic and increasing the chance of mistakes. A standalone bucket will be way easier to backup. This commit switches our CI to use the new rust-lang-ci-mirrors bucket. --- src/ci/azure-pipelines/auto.yml | 12 ++++++------ src/ci/azure-pipelines/steps/install-clang.yml | 2 +- src/ci/azure-pipelines/steps/install-sccache.yml | 4 ++-- .../steps/install-windows-build-deps.yml | 6 +++--- src/ci/docker/armhf-gnu/Dockerfile | 2 +- src/ci/docker/dist-various-1/install-mips-musl.sh | 2 +- src/ci/docker/dist-various-2/build-wasi-toolchain.sh | 2 +- src/ci/docker/dist-x86_64-linux/build-openssl.sh | 2 +- .../dist-x86_64-netbsd/build-netbsd-toolchain.sh | 2 +- src/ci/docker/scripts/android-sdk-manager.py | 8 +++++--- src/ci/docker/scripts/freebsd-toolchain.sh | 2 +- src/ci/docker/scripts/sccache.sh | 2 +- src/ci/install-awscli.sh | 2 +- 13 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/ci/azure-pipelines/auto.yml b/src/ci/azure-pipelines/auto.yml index 687856cca6b62..06fa3bd9f4347 100644 --- a/src/ci/azure-pipelines/auto.yml +++ b/src/ci/azure-pipelines/auto.yml @@ -273,7 +273,7 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-1 - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 # FIXME(#59637) @@ -283,14 +283,14 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-2 - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 x86_64-mingw-1: MSYS_BITS: 64 SCRIPT: make ci-subset-1 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 # FIXME(#59637) @@ -300,7 +300,7 @@ jobs: MSYS_BITS: 64 SCRIPT: make ci-subset-2 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 @@ -327,7 +327,7 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools --enable-profiler SCRIPT: python x.py dist - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 DIST_REQUIRE_ALL_TOOLS: 1 @@ -336,7 +336,7 @@ jobs: MSYS_BITS: 64 SCRIPT: python x.py dist RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler - MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror + MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 DIST_REQUIRE_ALL_TOOLS: 1 diff --git a/src/ci/azure-pipelines/steps/install-clang.yml b/src/ci/azure-pipelines/steps/install-clang.yml index 45ec767e0b875..14daf81b43075 100644 --- a/src/ci/azure-pipelines/steps/install-clang.yml +++ b/src/ci/azure-pipelines/steps/install-clang.yml @@ -36,7 +36,7 @@ steps: set -e mkdir -p citools cd citools - curl -f https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-7.0.0-win64.tar.gz | tar xzf - + curl -f https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/LLVM-7.0.0-win64.tar.gz | tar xzf - echo "##vso[task.setvariable variable=RUST_CONFIGURE_ARGS]$RUST_CONFIGURE_ARGS --set llvm.clang-cl=`pwd`/clang-rust/bin/clang-cl.exe" condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['MINGW_URL'],'')) displayName: Install clang (Windows) diff --git a/src/ci/azure-pipelines/steps/install-sccache.yml b/src/ci/azure-pipelines/steps/install-sccache.yml index 427e50f571f76..d4679c1c6733e 100644 --- a/src/ci/azure-pipelines/steps/install-sccache.yml +++ b/src/ci/azure-pipelines/steps/install-sccache.yml @@ -2,14 +2,14 @@ steps: - bash: | set -e - curl -fo /usr/local/bin/sccache https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin + curl -fo /usr/local/bin/sccache https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-02-sccache-x86_64-apple-darwin chmod +x /usr/local/bin/sccache displayName: Install sccache (OSX) condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) - script: | md sccache - powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-26-sccache-x86_64-pc-windows-msvc" echo ##vso[task.prependpath]%CD%\sccache displayName: Install sccache (Windows) condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) diff --git a/src/ci/azure-pipelines/steps/install-windows-build-deps.yml b/src/ci/azure-pipelines/steps/install-windows-build-deps.yml index c42c2311b493f..9aaeb4b79d634 100644 --- a/src/ci/azure-pipelines/steps/install-windows-build-deps.yml +++ b/src/ci/azure-pipelines/steps/install-windows-build-deps.yml @@ -4,7 +4,7 @@ steps: # https://github.com/wixtoolset/wix3 originally - bash: | set -e - curl -O https://rust-lang-ci2.s3-us-west-1.amazonaws.com/rust-ci-mirror/wix311-binaries.zip + curl -O https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/wix311-binaries.zip echo "##vso[task.setvariable variable=WIX]`pwd`/wix" mkdir -p wix/bin cd wix/bin @@ -18,7 +18,7 @@ steps: # one is MSI installers and one is EXE, but they're not used so frequently at # this point anyway so perhaps it's a wash! - script: | - powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf is-install.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-08-22-is.exe" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf is-install.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-08-22-is.exe" is-install.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- echo ##vso[task.prependpath]C:\Program Files (x86)\Inno Setup 5 displayName: Install InnoSetup @@ -109,7 +109,7 @@ steps: # Note that this is originally from the github releases patch of Ninja - script: | md ninja - powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-03-15-ninja-win.zip https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-03-15-ninja-win.zip" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-03-15-ninja-win.zip https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-03-15-ninja-win.zip" 7z x -oninja 2017-03-15-ninja-win.zip del 2017-03-15-ninja-win.zip set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja diff --git a/src/ci/docker/armhf-gnu/Dockerfile b/src/ci/docker/armhf-gnu/Dockerfile index 235920833f839..9493b33698708 100644 --- a/src/ci/docker/armhf-gnu/Dockerfile +++ b/src/ci/docker/armhf-gnu/Dockerfile @@ -72,7 +72,7 @@ RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static # TODO: What is this?! # Source of the file: https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/vexpress-v2p-ca15-tc1.dtb -RUN curl -O https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/vexpress-v2p-ca15-tc1.dtb +RUN curl -O https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/vexpress-v2p-ca15-tc1.dtb COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/dist-various-1/install-mips-musl.sh b/src/ci/docker/dist-various-1/install-mips-musl.sh index 60a96e3b8e952..29cfb5d96083e 100755 --- a/src/ci/docker/dist-various-1/install-mips-musl.sh +++ b/src/ci/docker/dist-various-1/install-mips-musl.sh @@ -5,7 +5,7 @@ mkdir /usr/local/mips-linux-musl # originally from # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/ # OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2 -URL="https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror" +URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc" FILE="OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2" curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mips-linux-musl --strip-components=2 diff --git a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh index 7bf8946c4f136..f04ee78157167 100755 --- a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh @@ -5,7 +5,7 @@ set -ex # Originally from https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz -curl https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \ +curl https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \ tar xJf - export PATH=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH diff --git a/src/ci/docker/dist-x86_64-linux/build-openssl.sh b/src/ci/docker/dist-x86_64-linux/build-openssl.sh index 13dae6169053a..be8a6c93945e9 100755 --- a/src/ci/docker/dist-x86_64-linux/build-openssl.sh +++ b/src/ci/docker/dist-x86_64-linux/build-openssl.sh @@ -4,7 +4,7 @@ set -ex source shared.sh VERSION=1.0.2k -URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/openssl-$VERSION.tar.gz +URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/openssl-$VERSION.tar.gz curl $URL | tar xzf - diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index 2e9b9dcc2344e..797f674b954f2 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -25,7 +25,7 @@ cd netbsd mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot -URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror +URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz curl $URL/2018-03-01-netbsd-src.tgz | tar xzf - diff --git a/src/ci/docker/scripts/android-sdk-manager.py b/src/ci/docker/scripts/android-sdk-manager.py index 7c9a8b82e9282..c9e2961f6eb15 100755 --- a/src/ci/docker/scripts/android-sdk-manager.py +++ b/src/ci/docker/scripts/android-sdk-manager.py @@ -23,8 +23,9 @@ HOST_OS = "linux" # Mirroring options -MIRROR_BUCKET = "rust-lang-ci2" -MIRROR_BASE_DIR = "rust-ci-mirror/android/" +MIRROR_BUCKET = "rust-lang-ci-mirrors" +MIRROR_BUCKET_REGION = "us-west-1" +MIRROR_BASE_DIR = "rustc/android/" import argparse import hashlib @@ -144,7 +145,8 @@ def cli_install(args): lockfile = Lockfile(args.lockfile) for package in lockfile.packages.values(): # Download the file from the mirror into a temp file - url = "https://" + MIRROR_BUCKET + ".s3.amazonaws.com/" + MIRROR_BASE_DIR + url = "https://" + MIRROR_BUCKET + ".s3-" + MIRROR_BUCKET_REGION + \ + ".amazonaws.com/" + MIRROR_BASE_DIR downloaded = package.download(url) # Extract the file in a temporary directory extract_dir = tempfile.mkdtemp() diff --git a/src/ci/docker/scripts/freebsd-toolchain.sh b/src/ci/docker/scripts/freebsd-toolchain.sh index 8cef69d9c26bb..70155e770a960 100755 --- a/src/ci/docker/scripts/freebsd-toolchain.sh +++ b/src/ci/docker/scripts/freebsd-toolchain.sh @@ -59,7 +59,7 @@ done # Originally downloaded from: # https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz -URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz +URL=https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}" # Fix up absolute symlinks from the system image. This can be removed diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index 194de3c339f8c..efeb0ed0d72d0 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -1,6 +1,6 @@ set -ex curl -fo /usr/local/bin/sccache \ - https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-unknown-linux-musl + https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2018-04-02-sccache-x86_64-unknown-linux-musl chmod +x /usr/local/bin/sccache diff --git a/src/ci/install-awscli.sh b/src/ci/install-awscli.sh index d491b9fbcdcf8..69c8d2e3099ab 100755 --- a/src/ci/install-awscli.sh +++ b/src/ci/install-awscli.sh @@ -16,7 +16,7 @@ set -euo pipefail IFS=$'\n\t' -MIRROR="https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2019-07-27-awscli.tar" +MIRROR="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2019-07-27-awscli.tar" DEPS_DIR="/tmp/awscli-deps" pip="pip" From 91af5c2daf950bd6f99e17dd2e0d23e7cd45e131 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 11 Aug 2019 23:37:05 +0200 Subject: [PATCH 11/32] Bring back suggestion for splitting `<-` into `< -` Closes #62632 --- src/libsyntax/parse/parser/expr.rs | 17 +++++++++++++++++ src/libsyntax/util/parser.rs | 2 ++ src/test/ui/obsolete-in-place/bad.rs | 2 +- src/test/ui/obsolete-in-place/bad.stderr | 8 ++++++-- src/test/ui/placement-syntax.rs | 2 +- src/test/ui/placement-syntax.stderr | 10 ++++++---- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 4432c1329cbfe..4fdb000ed9029 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -224,6 +224,10 @@ impl<'a> Parser<'a> { self.err_dotdotdot_syntax(self.token.span); } + if self.token == token::LArrow { + self.err_larrow_operator(self.token.span); + } + self.bump(); if op.is_comparison() { self.check_no_chained_comparison(&lhs, &op); @@ -1702,6 +1706,19 @@ impl<'a> Parser<'a> { .emit(); } + fn err_larrow_operator(&self, span: Span) { + self.struct_span_err( + span, + "unexpected token: `<-`" + ).span_suggestion( + span, + "if you meant to write a comparison against a negative value, add a \ + space in between `<` and `-`", + "< -".to_string(), + Applicability::MaybeIncorrect + ).emit(); + } + fn mk_assign_op(&self, binop: BinOp, lhs: P, rhs: P) -> ExprKind { ExprKind::AssignOp(binop, lhs, rhs) } diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index d71358f45c470..a501541c95909 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -97,6 +97,8 @@ impl AssocOp { // DotDotDot is no longer supported, but we need some way to display the error token::DotDotDot => Some(DotDotEq), token::Colon => Some(Colon), + // `<-` should probably be `< -` + token::LArrow => Some(Less), _ if t.is_keyword(kw::As) => Some(As), _ => None } diff --git a/src/test/ui/obsolete-in-place/bad.rs b/src/test/ui/obsolete-in-place/bad.rs index 3530862f76787..a491bb21a57a0 100644 --- a/src/test/ui/obsolete-in-place/bad.rs +++ b/src/test/ui/obsolete-in-place/bad.rs @@ -2,7 +2,7 @@ fn foo() { let (x, y) = (0, 0); - x <- y; //~ ERROR expected one of + x <- y; //~ ERROR unexpected token: `<-` } fn main() { diff --git a/src/test/ui/obsolete-in-place/bad.stderr b/src/test/ui/obsolete-in-place/bad.stderr index 373b7ea42183d..8a731b6240b2f 100644 --- a/src/test/ui/obsolete-in-place/bad.stderr +++ b/src/test/ui/obsolete-in-place/bad.stderr @@ -1,8 +1,12 @@ -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `<-` +error: unexpected token: `<-` --> $DIR/bad.rs:5:7 | LL | x <- y; - | ^^ expected one of 8 possible tokens here + | ^^ +help: if you meant to write a comparison against a negative value, add a space in between `<` and `-` + | +LL | x < - y; + | ^^^ error: expected expression, found keyword `in` --> $DIR/bad.rs:10:5 diff --git a/src/test/ui/placement-syntax.rs b/src/test/ui/placement-syntax.rs index 2edd78ec8ab3d..4df96dedbd45b 100644 --- a/src/test/ui/placement-syntax.rs +++ b/src/test/ui/placement-syntax.rs @@ -1,6 +1,6 @@ fn main() { let x = -5; - if x<-1 { //~ ERROR expected `{`, found `<-` + if x<-1 { //~ ERROR unexpected token: `<-` println!("ok"); } } diff --git a/src/test/ui/placement-syntax.stderr b/src/test/ui/placement-syntax.stderr index e90acce168e47..e26931e60d88f 100644 --- a/src/test/ui/placement-syntax.stderr +++ b/src/test/ui/placement-syntax.stderr @@ -1,10 +1,12 @@ -error: expected `{`, found `<-` +error: unexpected token: `<-` --> $DIR/placement-syntax.rs:3:9 | LL | if x<-1 { - | -- ^^ expected `{` - | | - | this `if` statement has a condition, but no block + | ^^ +help: if you meant to write a comparison against a negative value, add a space in between `<` and `-` + | +LL | if x< -1 { + | ^^^ error: aborting due to previous error From fecf30586786e21f381a8056b08ad1c2c5183736 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 12 Aug 2019 10:53:09 +0200 Subject: [PATCH 12/32] DiagnosticBuilder docs --- src/librustc_errors/diagnostic.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 424d7c0038389..e11ba75da9866 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -120,6 +120,9 @@ impl Diagnostic { } /// Adds a span/label to be included in the resulting snippet. + /// This label will be shown together with the original span/label used when creating the + /// diagnostic, *not* a span added by one of the `span_*` methods. + /// /// This is pushed onto the `MultiSpan` that was created when the /// diagnostic was first built. If you don't call this function at /// all, and you just supplied a `Span` to create the diagnostic, @@ -196,6 +199,7 @@ impl Diagnostic { self } + /// Prints the span with a note above it. pub fn span_note>(&mut self, sp: S, msg: &str) @@ -209,6 +213,7 @@ impl Diagnostic { self } + /// Prints the span with a warn above it. pub fn span_warn>(&mut self, sp: S, msg: &str) @@ -222,6 +227,7 @@ impl Diagnostic { self } + /// Prints the span with some help above it. pub fn span_help>(&mut self, sp: S, msg: &str) From e30480ca864c5810c89bbf1f475eb0bc2999c251 Mon Sep 17 00:00:00 2001 From: Observer42 Date: Mon, 12 Aug 2019 18:07:14 +0800 Subject: [PATCH 13/32] Apply suggestions from code review Co-Authored-By: Mazdak Farrokhzad --- src/liballoc/collections/binary_heap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index cc6c69d5738ea..3d04f30e7bde5 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -1163,9 +1163,9 @@ impl FusedIterator for Drain<'_, T> {} #[stable(feature = "binary_heap_extras_15", since = "1.5.0")] impl From> for BinaryHeap { - /// Converts a `Vec` into a `BinaryHeap`. + /// Converts a `Vec` into a `BinaryHeap`. /// - /// This conversion happens in-place, and has O(n) time complexity. + /// This conversion happens in-place, and has `O(n)` time complexity. fn from(vec: Vec) -> BinaryHeap { let mut heap = BinaryHeap { data: vec }; heap.rebuild(); From 34dcca20e5909513f08d1c21df1168357c3b6b6a Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 11 Aug 2019 08:25:30 +0300 Subject: [PATCH 14/32] syntax: account for CVarArgs being in the argument list. --- src/libsyntax/parse/parser.rs | 2 +- src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs | 6 ++++++ src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs create mode 100644 src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1c1428c5713f7..2286e74e63304 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1236,7 +1236,7 @@ impl<'a> Parser<'a> { let args: Vec<_> = args.into_iter().filter_map(|x| x).collect(); - if c_variadic && args.is_empty() { + if c_variadic && args.len() <= 1 { self.span_err(sp, "C-variadic function must be declared with at least one named argument"); } diff --git a/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs new file mode 100644 index 0000000000000..e3b642a9d418d --- /dev/null +++ b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.rs @@ -0,0 +1,6 @@ +extern { + fn foo(...); + //~^ ERROR C-variadic function must be declared with at least one named argument +} + +fn main() {} diff --git a/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr new file mode 100644 index 0000000000000..cb6060525fc0d --- /dev/null +++ b/src/test/ui/c-variadic/variadic-ffi-no-fixed-args.stderr @@ -0,0 +1,8 @@ +error: C-variadic function must be declared with at least one named argument + --> $DIR/variadic-ffi-no-fixed-args.rs:2:11 + | +LL | fn foo(...); + | ^ + +error: aborting due to previous error + From 861d1bb365419c4a9ae8eb14257323e9877e5d42 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 21 Jul 2019 14:37:13 +0100 Subject: [PATCH 15/32] typeck: Prohibit RPIT types that inherit lifetimes This commit prohibits return position `impl Trait` types that "inherit lifetimes" from the parent scope. The intent is to forbid cases that are challenging until they can be addressed properly. --- src/librustc_typeck/check/mod.rs | 84 ++++++++++++++++++- .../issue-61949-self-return-type.rs | 28 +++++++ .../issue-61949-self-return-type.stderr | 8 ++ .../ui/impl-trait/bound-normalization-fail.rs | 4 +- .../bound-normalization-fail.stderr | 14 +++- 5 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/async-await/issue-61949-self-return-type.rs create mode 100644 src/test/ui/async-await/issue-61949-self-return-type.stderr diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4fb28db6e94fa..14fc0d6347e4b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1325,12 +1325,94 @@ fn check_union(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) { check_packed(tcx, span, def_id); } +/// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo` +/// projections that would result in "inheriting lifetimes". fn check_opaque<'tcx>( tcx: TyCtxt<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, span: Span, - origin: &hir::OpaqueTyOrigin + origin: &hir::OpaqueTyOrigin, +) { + check_opaque_for_inheriting_lifetimes(tcx, def_id, span); + check_opaque_for_cycles(tcx, def_id, substs, span, origin); +} + +/// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result +/// in "inheriting lifetimes". +fn check_opaque_for_inheriting_lifetimes( + tcx: TyCtxt<'tcx>, + def_id: DefId, + span: Span, +) { + let item = tcx.hir().expect_item( + tcx.hir().as_local_hir_id(def_id).expect("opaque type is not local")); + debug!("check_opaque_for_inheriting_lifetimes: def_id={:?} span={:?} item={:?}", + def_id, span, item); + + #[derive(Debug)] + struct ProhibitOpaqueVisitor<'tcx> { + opaque_identity_ty: Ty<'tcx>, + generics: &'tcx ty::Generics, + }; + + impl<'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> { + fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { + debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t); + if t == self.opaque_identity_ty { false } else { t.super_visit_with(self) } + } + + fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { + debug!("check_opaque_for_inheriting_lifetimes: (visit_region) r={:?}", r); + if let RegionKind::ReEarlyBound(ty::EarlyBoundRegion { index, .. }) = r { + return *index < self.generics.parent_count as u32; + } + + r.super_visit_with(self) + } + } + + let prohibit_opaque = match item.node { + ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::AsyncFn, .. }) | + ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn, .. }) => { + let mut visitor = ProhibitOpaqueVisitor { + opaque_identity_ty: tcx.mk_opaque( + def_id, InternalSubsts::identity_for_item(tcx, def_id)), + generics: tcx.generics_of(def_id), + }; + debug!("check_opaque_for_inheriting_lifetimes: visitor={:?}", visitor); + + tcx.predicates_of(def_id).predicates.iter().any( + |(predicate, _)| predicate.visit_with(&mut visitor)) + }, + _ => false, + }; + + debug!("check_opaque_for_inheriting_lifetimes: prohibit_opaque={:?}", prohibit_opaque); + if prohibit_opaque { + let is_async = match item.node { + ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => match origin { + hir::OpaqueTyOrigin::AsyncFn => true, + _ => false, + }, + _ => unreachable!(), + }; + + tcx.sess.span_err(span, &format!( + "`{}` return type cannot contain a projection or `Self` that references lifetimes from \ + a parent scope", + if is_async { "async fn" } else { "impl Trait" }, + )); + } +} + +/// Checks that an opaque type does not contain cycles. +fn check_opaque_for_cycles<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: DefId, + substs: SubstsRef<'tcx>, + span: Span, + origin: &hir::OpaqueTyOrigin, ) { if let Err(partially_expanded_type) = tcx.try_expand_impl_trait_type(def_id, substs) { if let hir::OpaqueTyOrigin::AsyncFn = origin { diff --git a/src/test/ui/async-await/issue-61949-self-return-type.rs b/src/test/ui/async-await/issue-61949-self-return-type.rs new file mode 100644 index 0000000000000..c5a66d5d4a312 --- /dev/null +++ b/src/test/ui/async-await/issue-61949-self-return-type.rs @@ -0,0 +1,28 @@ +// ignore-tidy-linelength +// edition:2018 +#![feature(async_await)] + +// This test checks that `Self` is prohibited as a return type. See #61949 for context. + +pub struct Foo<'a> { + pub bar: &'a i32, +} + +impl<'a> Foo<'a> { + pub async fn new(_bar: &'a i32) -> Self { + //~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + Foo { + bar: &22 + } + } +} + +async fn foo() { + let x = { + let bar = 22; + Foo::new(&bar).await + }; + drop(x); +} + +fn main() { } diff --git a/src/test/ui/async-await/issue-61949-self-return-type.stderr b/src/test/ui/async-await/issue-61949-self-return-type.stderr new file mode 100644 index 0000000000000..a9ae544502d08 --- /dev/null +++ b/src/test/ui/async-await/issue-61949-self-return-type.stderr @@ -0,0 +1,8 @@ +error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + --> $DIR/issue-61949-self-return-type.rs:12:40 + | +LL | pub async fn new(_bar: &'a i32) -> Self { + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/impl-trait/bound-normalization-fail.rs b/src/test/ui/impl-trait/bound-normalization-fail.rs index c33261bfd0909..9ba7c91fc7201 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.rs +++ b/src/test/ui/impl-trait/bound-normalization-fail.rs @@ -1,4 +1,5 @@ // compile-fail +// ignore-tidy-linelength // edition:2018 #![feature(async_await)] @@ -44,7 +45,8 @@ mod lifetimes { /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { - //~^ ERROR: type mismatch + //~^ ERROR: type mismatch + //~^^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope Foo(()) } } diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index aa306a7e08a4c..b5c8e078f0f13 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -1,5 +1,5 @@ warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash - --> $DIR/bound-normalization-fail.rs:5:12 + --> $DIR/bound-normalization-fail.rs:6:12 | LL | #![feature(impl_trait_in_bindings)] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #![feature(impl_trait_in_bindings)] = note: `#[warn(incomplete_features)]` on by default error[E0271]: type mismatch resolving ` as FooLike>::Output == ::Assoc` - --> $DIR/bound-normalization-fail.rs:29:32 + --> $DIR/bound-normalization-fail.rs:30:32 | LL | fn foo_fail() -> impl FooLike { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type @@ -16,8 +16,14 @@ LL | fn foo_fail() -> impl FooLike { found type `::Assoc` = note: the return type of a function must have a statically known size +error: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + --> $DIR/bound-normalization-fail.rs:47:41 + | +LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0271]: type mismatch resolving ` as FooLike>::Output == >::Assoc` - --> $DIR/bound-normalization-fail.rs:46:41 + --> $DIR/bound-normalization-fail.rs:47:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type @@ -26,6 +32,6 @@ LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { found type `>::Assoc` = note: the return type of a function must have a statically known size -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0271`. From 18e54539ca08ee9cad46200206320ce290086999 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 15:17:16 -0400 Subject: [PATCH 16/32] use `ParamName` to track in-scope lifetimes instead of Ident This allows us to record "fresh" lifetime names for cases like `impl Foo<'_>`. --- src/librustc/hir/lowering.rs | 12 ++++++++---- src/librustc/hir/lowering/item.rs | 2 +- .../async-fn-elided-impl-lifetime-parameter.rs | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index fe69c9e634635..184180d67be7b 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -136,7 +136,7 @@ pub struct LoweringContext<'a> { /// When `is_collectin_in_band_lifetimes` is true, each lifetime is checked /// against this list to see if it is already in-scope, or if a definition /// needs to be created for it. - in_scope_lifetimes: Vec, + in_scope_lifetimes: Vec, current_module: NodeId, @@ -865,7 +865,7 @@ impl<'a> LoweringContext<'a> { return; } - if self.in_scope_lifetimes.contains(&ident.modern()) { + if self.in_scope_lifetimes.contains(&ParamName::Plain(ident.modern())) { return; } @@ -899,7 +899,7 @@ impl<'a> LoweringContext<'a> { { let old_len = self.in_scope_lifetimes.len(); let lt_def_names = params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => Some(param.ident.modern()), + GenericParamKind::Lifetime { .. } => Some(ParamName::Plain(param.ident.modern())), _ => None, }); self.in_scope_lifetimes.extend(lt_def_names); @@ -2267,10 +2267,14 @@ impl<'a> LoweringContext<'a> { let lifetime_params: Vec<(Span, ParamName)> = this.in_scope_lifetimes .iter().cloned() - .map(|ident| (ident.span, ParamName::Plain(ident))) + .map(|name| (name.ident().span, name)) .chain(this.lifetimes_to_define.iter().cloned()) .collect(); + debug!("lower_async_fn_ret_ty: in_scope_lifetimes={:#?}", this.in_scope_lifetimes); + debug!("lower_async_fn_ret_ty: lifetimes_to_define={:#?}", this.lifetimes_to_define); + debug!("lower_async_fn_ret_ty: lifetime_params={:#?}", lifetime_params); + let generic_params = lifetime_params .iter().cloned() diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 6b717e75199c7..4d6039e101a88 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -123,7 +123,7 @@ impl LoweringContext<'_> { _ => &[], }; let lt_def_names = parent_generics.iter().filter_map(|param| match param.kind { - hir::GenericParamKind::Lifetime { .. } => Some(param.name.ident().modern()), + hir::GenericParamKind::Lifetime { .. } => Some(param.name), _ => None, }); self.in_scope_lifetimes.extend(lt_def_names); diff --git a/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs b/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs new file mode 100644 index 0000000000000..4ded6385325a8 --- /dev/null +++ b/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs @@ -0,0 +1,16 @@ +// Check that `async fn` inside of an impl with `'_` +// in the header compiles correctly. +// +// Regression test for #63500. +// +// check-pass + +#![feature(async_await)] + +struct Foo<'a>(&'a u8); + +impl Foo<'_> { + async fn bar() {} +} + +fn main() { } From 03e7b9628199f5c82d083cd02116c4424a31f47f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 17:15:33 -0400 Subject: [PATCH 17/32] revamp how we handle elision in async fn We now always make fresh lifetimne parameters for all elided lifetimes, whether they are in the inputs or outputs. But then we generate `'_` in the case of elided lifetimes from the outputs. Example: ```rust async fn foo<'a>(x: &'a u32) -> &u32 { .. } ``` becomes ```rust type Foo<'a, 'b> = impl Future; fn foo<'a>(x: &'a u32) -> Foo<'a, '_> ``` --- src/librustc/hir/lowering.rs | 181 +++++----------- .../ui/async-await/issues/issue-63388-1.rs | 20 ++ .../async-await/issues/issue-63388-1.stderr | 12 ++ .../ui/async-await/issues/issue-63388-2.rs | 20 ++ .../async-await/issues/issue-63388-2.stderr | 29 +++ .../ui/async-await/issues/issue-63388-3.rs | 19 ++ .../ui/async-await/issues/issue-63388-4.rs | 12 ++ src/test/ui/self/elision/README.md | 16 +- src/test/ui/self/elision/lt-ref-self-async.rs | 24 +-- .../ui/self/elision/lt-ref-self-async.stderr | 175 ++++----------- .../multiple-ref-self-async.nll.stderr | 43 ---- .../self/elision/multiple-ref-self-async.rs | 11 +- .../elision/multiple-ref-self-async.stderr | 133 ------------ .../self/elision/ref-alias-async.nll.stderr | 43 ---- src/test/ui/self/elision/ref-alias-async.rs | 11 +- .../ui/self/elision/ref-alias-async.stderr | 133 ------------ .../self/elision/ref-assoc-async.nll.stderr | 43 ---- src/test/ui/self/elision/ref-assoc-async.rs | 11 +- .../ui/self/elision/ref-assoc-async.stderr | 133 ------------ .../elision/ref-mut-alias-async.nll.stderr | 43 ---- .../ui/self/elision/ref-mut-alias-async.rs | 12 +- .../self/elision/ref-mut-alias-async.stderr | 133 ------------ .../ui/self/elision/ref-mut-self-async.rs | 24 +-- .../ui/self/elision/ref-mut-self-async.stderr | 175 ++++----------- .../ui/self/elision/ref-mut-struct-async.rs | 20 +- .../self/elision/ref-mut-struct-async.stderr | 146 +++---------- src/test/ui/self/elision/ref-self-async.rs | 28 +-- .../ui/self/elision/ref-self-async.stderr | 204 ++++-------------- src/test/ui/self/elision/ref-struct-async.rs | 20 +- .../ui/self/elision/ref-struct-async.stderr | 146 +++---------- 30 files changed, 383 insertions(+), 1637 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-63388-1.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-1.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-2.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-2.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-3.rs create mode 100644 src/test/ui/async-await/issues/issue-63388-4.rs delete mode 100644 src/test/ui/self/elision/multiple-ref-self-async.nll.stderr delete mode 100644 src/test/ui/self/elision/multiple-ref-self-async.stderr delete mode 100644 src/test/ui/self/elision/ref-alias-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-alias-async.stderr delete mode 100644 src/test/ui/self/elision/ref-assoc-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-assoc-async.stderr delete mode 100644 src/test/ui/self/elision/ref-mut-alias-async.nll.stderr delete mode 100644 src/test/ui/self/elision/ref-mut-alias-async.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 493083c680aad..8e7f96ca23665 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -341,49 +341,6 @@ enum AnonymousLifetimeMode { /// Pass responsibility to `resolve_lifetime` code for all cases. PassThrough, - - /// Used in the return types of `async fn` where there exists - /// exactly one argument-position elided lifetime. - /// - /// In `async fn`, we lower the arguments types using the `CreateParameter` - /// mode, meaning that non-`dyn` elided lifetimes are assigned a fresh name. - /// If any corresponding elided lifetimes appear in the output, we need to - /// replace them with references to the fresh name assigned to the corresponding - /// elided lifetime in the arguments. - /// - /// For **Modern cases**, replace the anonymous parameter with a - /// reference to a specific freshly-named lifetime that was - /// introduced in argument - /// - /// For **Dyn Bound** cases, pass responsibility to - /// `resole_lifetime` code. - Replace(LtReplacement), -} - -/// The type of elided lifetime replacement to perform on `async fn` return types. -#[derive(Copy, Clone)] -enum LtReplacement { - /// Fresh name introduced by the single non-dyn elided lifetime - /// in the arguments of the async fn. - Some(ParamName), - - /// There is no single non-dyn elided lifetime because no lifetimes - /// appeared in the arguments. - NoLifetimes, - - /// There is no single non-dyn elided lifetime because multiple - /// lifetimes appeared in the arguments. - MultipleLifetimes, -} - -/// Calculates the `LtReplacement` to use for elided lifetimes in the return -/// type based on the fresh elided lifetimes introduced in argument position. -fn get_elided_lt_replacement(arg_position_lifetimes: &[(Span, ParamName)]) -> LtReplacement { - match arg_position_lifetimes { - [] => LtReplacement::NoLifetimes, - [(_span, param)] => LtReplacement::Some(*param), - _ => LtReplacement::MultipleLifetimes, - } } struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[NodeId; 1]> } @@ -2318,8 +2275,7 @@ impl<'a> LoweringContext<'a> { err.emit(); } AnonymousLifetimeMode::PassThrough | - AnonymousLifetimeMode::ReportError | - AnonymousLifetimeMode::Replace(_) => { + AnonymousLifetimeMode::ReportError => { self.sess.buffer_lint_with_diagnostic( ELIDED_LIFETIMES_IN_PATHS, CRATE_NODE_ID, @@ -2515,7 +2471,6 @@ impl<'a> LoweringContext<'a> { // Remember how many lifetimes were already around so that we can // only look at the lifetime parameters introduced by the arguments. - let lifetime_count_before_args = self.lifetimes_to_define.len(); let inputs = self.with_anonymous_lifetime_mode(lt_mode, |this| { decl.inputs .iter() @@ -2530,16 +2485,10 @@ impl<'a> LoweringContext<'a> { }); let output = if let Some(ret_id) = make_ret_async { - // Calculate the `LtReplacement` to use for any return-position elided - // lifetimes based on the elided lifetime parameters introduced in the args. - let lt_replacement = get_elided_lt_replacement( - &self.lifetimes_to_define[lifetime_count_before_args..] - ); self.lower_async_fn_ret_ty( &decl.output, in_band_ty_params.expect("`make_ret_async` but no `fn_def_id`").0, ret_id, - lt_replacement, ) } else { match decl.output { @@ -2604,7 +2553,6 @@ impl<'a> LoweringContext<'a> { output: &FunctionRetTy, fn_def_id: DefId, opaque_ty_node_id: NodeId, - elided_lt_replacement: LtReplacement, ) -> hir::FunctionRetTy { let span = output.span(); @@ -2622,9 +2570,18 @@ impl<'a> LoweringContext<'a> { self.allocate_hir_id_counter(opaque_ty_node_id); + let input_lifetimes_count = self.in_scope_lifetimes.len() + self.lifetimes_to_define.len(); let (opaque_ty_id, lifetime_params) = self.with_hir_id_owner(opaque_ty_node_id, |this| { + // We have to be careful to get elision right here. The + // idea is that we create a lifetime parameter for each + // lifetime in the return type. So, given a return type + // like `async fn foo(..) -> &[&u32]`, we lower to `impl + // Future`. + // + // Then, we will create `fn foo(..) -> Foo<'_, '_>`, and + // hence the elision takes place at the fn site. let future_bound = this.with_anonymous_lifetime_mode( - AnonymousLifetimeMode::Replace(elided_lt_replacement), + AnonymousLifetimeMode::CreateParameter, |this| this.lower_async_fn_output_type_to_future_bound( output, fn_def_id, @@ -2678,19 +2635,53 @@ impl<'a> LoweringContext<'a> { (opaque_ty_id, lifetime_params) }); - let generic_args = - lifetime_params - .iter().cloned() - .map(|(span, hir_name)| { - GenericArg::Lifetime(hir::Lifetime { - hir_id: self.next_id(), - span, - name: hir::LifetimeName::Param(hir_name), - }) + // Create the generic lifetime arguments that we will supply + // to the opaque return type. Consider: + // + // ```rust + // async fn foo(x: &u32, ) -> &[&u32] { .. } + // ``` + // + // Here, we would create something like: + // + // ```rust + // type Foo<'a, 'b, 'c> = impl Future; + // fn foo<'a>(x: &'a u32) -> Foo<'a, '_, '_> + // ``` + // + // Note that for the lifetimes which came from the input + // (`'a`, here), we supply them as arguments to the return + // type `Foo`. But for those lifetime parameters (`'b`, `'c`) + // that we created from the return type, we want to use `'_` + // in the return type, so as to trigger elision. + let mut generic_args: Vec<_> = + lifetime_params[..input_lifetimes_count] + .iter() + .map(|&(span, hir_name)| { + GenericArg::Lifetime(hir::Lifetime { + hir_id: self.next_id(), + span, + name: hir::LifetimeName::Param(hir_name), }) - .collect(); + }) + .collect(); + generic_args.extend( + lifetime_params[input_lifetimes_count..] + .iter() + .map(|&(span, _)| { + GenericArg::Lifetime(hir::Lifetime { + hir_id: self.next_id(), + span, + name: hir::LifetimeName::Implicit, + }) + }) + ); - let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args); + // Create the `Foo<...>` refernece itself. Note that the `type + // Foo = impl Trait` is, internally, created as a child of the + // async fn, so the *type parameters* are inherited. It's + // only the lifetime parameters that we must supply. + let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args.into()); hir::FunctionRetTy::Return(P(hir::Ty { node: opaque_ty_ref, @@ -2786,11 +2777,6 @@ impl<'a> LoweringContext<'a> { } AnonymousLifetimeMode::ReportError => self.new_error_lifetime(Some(l.id), span), - - AnonymousLifetimeMode::Replace(replacement) => { - let hir_id = self.lower_node_id(l.id); - self.replace_elided_lifetime(hir_id, span, replacement) - } }, ident => { self.maybe_collect_in_band_lifetime(ident); @@ -2813,39 +2799,6 @@ impl<'a> LoweringContext<'a> { } } - /// Replace a return-position elided lifetime with the elided lifetime - /// from the arguments. - fn replace_elided_lifetime( - &mut self, - hir_id: hir::HirId, - span: Span, - replacement: LtReplacement, - ) -> hir::Lifetime { - let multiple_or_none = match replacement { - LtReplacement::Some(name) => { - return hir::Lifetime { - hir_id, - span, - name: hir::LifetimeName::Param(name), - }; - } - LtReplacement::MultipleLifetimes => "multiple", - LtReplacement::NoLifetimes => "none", - }; - - let mut err = crate::middle::resolve_lifetime::report_missing_lifetime_specifiers( - self.sess, - span, - 1, - ); - err.note(&format!( - "return-position elided lifetimes require exactly one \ - input-position elided lifetime, found {}.", multiple_or_none)); - err.emit(); - - hir::Lifetime { hir_id, span, name: hir::LifetimeName::Error } - } - fn lower_generic_params( &mut self, params: &[GenericParam], @@ -5791,10 +5744,6 @@ impl<'a> LoweringContext<'a> { AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), - - AnonymousLifetimeMode::Replace(replacement) => { - self.new_replacement_lifetime(replacement, span) - } } } @@ -5848,10 +5797,6 @@ impl<'a> LoweringContext<'a> { // This is the normal case. AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), - AnonymousLifetimeMode::Replace(replacement) => { - self.new_replacement_lifetime(replacement, span) - } - AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), } } @@ -5883,25 +5828,11 @@ impl<'a> LoweringContext<'a> { // This is the normal case. AnonymousLifetimeMode::PassThrough => {} - - // We don't need to do any replacement here as this lifetime - // doesn't refer to an elided lifetime elsewhere in the function - // signature. - AnonymousLifetimeMode::Replace(_) => {} } self.new_implicit_lifetime(span) } - fn new_replacement_lifetime( - &mut self, - replacement: LtReplacement, - span: Span, - ) -> hir::Lifetime { - let hir_id = self.next_id(); - self.replace_elided_lifetime(hir_id, span, replacement) - } - fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime { hir::Lifetime { hir_id: self.next_id(), diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs new file mode 100644 index 0000000000000..80003b0d701f5 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth<'a>( + &'a self, foo: &dyn Foo + ) -> &dyn Foo //~ ERROR lifetime mismatch + { + foo + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.stderr new file mode 100644 index 0000000000000..5302adce5a01e --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/issue-63388-1.rs:14:10 + | +LL | &'a self, foo: &dyn Foo + | -------- this parameter and the return type are declared with different lifetimes... +LL | ) -> &dyn Foo + | ^^^^^^^^ + | | + | ...but data from `foo` is returned here + +error: aborting due to previous error + diff --git a/src/test/ui/async-await/issues/issue-63388-2.rs b/src/test/ui/async-await/issues/issue-63388-2.rs new file mode 100644 index 0000000000000..ca9bbef0d503d --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth<'a>( + foo: &dyn Foo, bar: &'a dyn Foo //~ ERROR cannot infer + ) -> &dyn Foo //~ ERROR missing lifetime specifier + { + foo + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-2.stderr b/src/test/ui/async-await/issues/issue-63388-2.stderr new file mode 100644 index 0000000000000..1810138dc80e0 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.stderr @@ -0,0 +1,29 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-63388-2.rs:14:10 + | +LL | ) -> &dyn Foo + | ^ help: consider using the named lifetime: `&'a` + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `foo` or `bar` + +error: cannot infer an appropriate lifetime + --> $DIR/issue-63388-2.rs:13:9 + | +LL | foo: &dyn Foo, bar: &'a dyn Foo + | ^^^ ...but this borrow... +LL | ) -> &dyn Foo + | -------- this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime '_ as defined on the method body at 13:14 + --> $DIR/issue-63388-2.rs:13:14 + | +LL | foo: &dyn Foo, bar: &'a dyn Foo + | ^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 13:14 + | +LL | ) -> &dyn Foo + '_ + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/async-await/issues/issue-63388-3.rs b/src/test/ui/async-await/issues/issue-63388-3.rs new file mode 100644 index 0000000000000..05f23f95965b9 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-3.rs @@ -0,0 +1,19 @@ +// edition:2018 +// check-pass + +#![feature(async_await)] + +struct Xyz { + a: u64, +} + +trait Foo {} + +impl Xyz { + async fn do_sth( + &self, foo: &dyn Foo + ) { + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-63388-4.rs b/src/test/ui/async-await/issues/issue-63388-4.rs new file mode 100644 index 0000000000000..0939242d7fc7a --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-4.rs @@ -0,0 +1,12 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +struct A; + +impl A { + async fn foo(&self, f: &u32) -> &A { self } +} + +fn main() { } diff --git a/src/test/ui/self/elision/README.md b/src/test/ui/self/elision/README.md index c4f06433ba709..2db8a23be6ec6 100644 --- a/src/test/ui/self/elision/README.md +++ b/src/test/ui/self/elision/README.md @@ -61,15 +61,15 @@ Legends: | `struct-async.rs`| ✓ | ✓ | N/A | | `alias-async.rs`| ✓ | ✓ | N/A | | `assoc-async.rs`| ✓ | ✓ | N/A | -| `ref-self-async.rs` | X | X | α ⟶ β + γ | -| `ref-mut-self-async.rs` | X | X | α ⟶ β + γ | -| `ref-struct-async.rs` | X | X | α ⟶ β + γ | -| `ref-mut-struct-async.rs` | X | X | α ⟶ β + γ | -| `ref-alias-async.rs` | X | X | ✓ ⟶ β + γ | -| `ref-assoc-async.rs` | X | X | ✓ ⟶ β + γ | -| `ref-mut-alias-async.rs` | X | X | ✓ ⟶ β + γ | +| `ref-self-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-self-async.rs` | ✓ | ✓ | N/A | +| `ref-struct-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-struct-async.rs` | ✓ | ✓ | N/A | +| `ref-alias-async.rs` | ✓ | ✓ | N/A | +| `ref-assoc-async.rs` | ✓ | ✓ | N/A | +| `ref-mut-alias-async.rs` | ✓ | ✓ | N/A | | `lt-self-async.rs` | ✓ | ✓ | N/A | `lt-struct-async.rs` | ✓ | ✓ | N/A | `lt-alias-async.rs` | ✓ | ✓ | N/A | `lt-assoc-async.rs` | ✓ | ✓ | N/A -| `lt-ref-self-async.rs` | X | X | α ⟶ β + γ +| `lt-ref-self-async.rs` | ✓ | ✓ | N/A | diff --git a/src/test/ui/self/elision/lt-ref-self-async.rs b/src/test/ui/self/elision/lt-ref-self-async.rs index 84b91ba08b75d..79a4771978a8e 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.rs +++ b/src/test/ui/self/elision/lt-ref-self-async.rs @@ -13,41 +13,29 @@ impl<'a> Struct<'a> { // Test using `&self` sugar: async fn ref_self(&self, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/lt-ref-self-async.stderr b/src/test/ui/self/elision/lt-ref-self-async.stderr index 56595d008a6bf..0a459257fa708 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.stderr @@ -1,159 +1,56 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/lt-ref-self-async.rs:15:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:23:48 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:29:57 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:35:57 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41:66 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:47:62 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:15:30 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 - --> $DIR/lt-ref-self-async.rs:15:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:23:36 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 - --> $DIR/lt-ref-self-async.rs:23:29 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:21:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:29:45 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 - --> $DIR/lt-ref-self-async.rs:29:37 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:25:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:35:45 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 - --> $DIR/lt-ref-self-async.rs:35:37 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:29:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:41:54 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 - --> $DIR/lt-ref-self-async.rs:41:45 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:33:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/lt-ref-self-async.rs:47:50 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 47:41 - --> $DIR/lt-ref-self-async.rs:47:41 +error[E0623]: lifetime mismatch + --> $DIR/lt-ref-self-async.rs:37:62 | LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:41 - | -LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 12 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr b/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr deleted file mode 100644 index 00e16cd7f99fb..0000000000000 --- a/src/test/ui/self/elision/multiple-ref-self-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:24:74 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:30:84 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:36:84 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:42:93 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:48:93 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/multiple-ref-self-async.rs b/src/test/ui/self/elision/multiple-ref-self-async.rs index 3cc146c5dc7b2..eb8c25277e145 100644 --- a/src/test/ui/self/elision/multiple-ref-self-async.rs +++ b/src/test/ui/self/elision/multiple-ref-self-async.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 #![feature(async_await)] @@ -22,32 +23,22 @@ impl Struct { // Test using multiple `&Self`: async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/multiple-ref-self-async.stderr b/src/test/ui/self/elision/multiple-ref-self-async.stderr deleted file mode 100644 index 2a89ed3feba62..0000000000000 --- a/src/test/ui/self/elision/multiple-ref-self-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:24:74 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:30:84 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:36:84 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:42:93 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/multiple-ref-self-async.rs:48:93 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:24:63 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ --- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 24:48 - --> $DIR/multiple-ref-self-async.rs:24:48 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:48 - | -LL | async fn wrap_ref_Self_ref_Self(self: Wrap<&Self, &Self>, f: &u8) -> &u8 + '_ { - | ^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:30:72 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 30:56 - --> $DIR/multiple-ref-self-async.rs:30:56 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 30:56 - | -LL | async fn box_wrap_ref_Self_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:36:72 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 36:56 - --> $DIR/multiple-ref-self-async.rs:36:56 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 36:56 - | -LL | async fn pin_wrap_ref_Self_ref_Self(self: Pin>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:42:81 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 42:64 - --> $DIR/multiple-ref-self-async.rs:42:64 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 42:64 - | -LL | async fn box_box_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/multiple-ref-self-async.rs:48:81 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 48:64 - --> $DIR/multiple-ref-self-async.rs:48:64 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 48:64 - | -LL | async fn box_pin_wrap_ref_Self_ref_Self(self: Box>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.nll.stderr b/src/test/ui/self/elision/ref-alias-async.nll.stderr deleted file mode 100644 index 7e47b3794035f..0000000000000 --- a/src/test/ui/self/elision/ref-alias-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:20:50 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:26:59 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:32:59 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:38:68 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:44:68 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-alias-async.rs b/src/test/ui/self/elision/ref-alias-async.rs index 224151b9b0c55..acc4b2153ef66 100644 --- a/src/test/ui/self/elision/ref-alias-async.rs +++ b/src/test/ui/self/elision/ref-alias-async.rs @@ -1,4 +1,5 @@ // edition:2018 +// check-pass #![feature(async_await)] @@ -18,32 +19,22 @@ impl Struct { // feels like a bug. async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-alias-async.stderr b/src/test/ui/self/elision/ref-alias-async.stderr deleted file mode 100644 index a3250562c6fff..0000000000000 --- a/src/test/ui/self/elision/ref-alias-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:20:50 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:26:59 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:32:59 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:38:68 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-alias-async.rs:44:68 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:20:38 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 20:30 - --> $DIR/ref-alias-async.rs:20:30 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 20:30 - | -LL | async fn ref_Alias(self: &Alias, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:26:47 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 26:38 - --> $DIR/ref-alias-async.rs:26:38 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 26:38 - | -LL | async fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:32:47 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 32:38 - --> $DIR/ref-alias-async.rs:32:38 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:38 - | -LL | async fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:38:56 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 38:46 - --> $DIR/ref-alias-async.rs:38:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-alias-async.rs:44:56 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 44:46 - --> $DIR/ref-alias-async.rs:44:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.nll.stderr b/src/test/ui/self/elision/ref-assoc-async.nll.stderr deleted file mode 100644 index 25c8bf652d84b..0000000000000 --- a/src/test/ui/self/elision/ref-assoc-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:21:77 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:27:86 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:33:86 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:39:95 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:45:95 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-assoc-async.rs b/src/test/ui/self/elision/ref-assoc-async.rs index 380937e61ca3f..a6b6cbd6da391 100644 --- a/src/test/ui/self/elision/ref-assoc-async.rs +++ b/src/test/ui/self/elision/ref-assoc-async.rs @@ -1,4 +1,5 @@ // edition:2018 +// check-pass #![feature(async_await)] @@ -19,32 +20,22 @@ impl Trait for Struct { impl Struct { async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-assoc-async.stderr b/src/test/ui/self/elision/ref-assoc-async.stderr deleted file mode 100644 index c2e893a3f58bf..0000000000000 --- a/src/test/ui/self/elision/ref-assoc-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:21:77 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:27:86 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:33:86 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:39:95 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-assoc-async.rs:45:95 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:21:65 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:34 - --> $DIR/ref-assoc-async.rs:21:34 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:34 - | -LL | async fn ref_AssocType(self: &::AssocType, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:27:74 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:42 - --> $DIR/ref-assoc-async.rs:27:42 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:42 - | -LL | async fn box_ref_AssocType(self: Box<&::AssocType>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:33:74 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:42 - --> $DIR/ref-assoc-async.rs:33:42 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:42 - | -LL | async fn pin_ref_AssocType(self: Pin<&::AssocType>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:39:83 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:50 - --> $DIR/ref-assoc-async.rs:39:50 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:50 - | -LL | async fn box_box_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-assoc-async.rs:45:83 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 45:50 - --> $DIR/ref-assoc-async.rs:45:50 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 45:50 - | -LL | async fn box_pin_ref_AssocType(self: Box::AssocType>>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr b/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr deleted file mode 100644 index 1026a0b492f34..0000000000000 --- a/src/test/ui/self/elision/ref-mut-alias-async.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:17:54 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:23:63 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:29:63 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:35:72 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:41:72 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-alias-async.rs b/src/test/ui/self/elision/ref-mut-alias-async.rs index ce66313bddd12..873e92bc6d33e 100644 --- a/src/test/ui/self/elision/ref-mut-alias-async.rs +++ b/src/test/ui/self/elision/ref-mut-alias-async.rs @@ -1,7 +1,7 @@ // edition:2018 +// check-pass #![feature(async_await)] - #![feature(arbitrary_self_types)] #![allow(non_snake_case)] @@ -15,32 +15,22 @@ impl Struct { // Test using an alias for `Struct`: async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime f } } diff --git a/src/test/ui/self/elision/ref-mut-alias-async.stderr b/src/test/ui/self/elision/ref-mut-alias-async.stderr deleted file mode 100644 index 678bf74518606..0000000000000 --- a/src/test/ui/self/elision/ref-mut-alias-async.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:17:54 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:23:63 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:29:63 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:35:72 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-alias-async.rs:41:72 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:17:42 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 17:30 - --> $DIR/ref-mut-alias-async.rs:17:30 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 17:30 - | -LL | async fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:23:51 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:38 - --> $DIR/ref-mut-alias-async.rs:23:38 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:38 - | -LL | async fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:29:51 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:38 - --> $DIR/ref-mut-alias-async.rs:29:38 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:38 - | -LL | async fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:35:60 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:46 - --> $DIR/ref-mut-alias-async.rs:35:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:46 - | -LL | async fn box_box_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-alias-async.rs:41:60 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:46 - --> $DIR/ref-mut-alias-async.rs:41:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:46 - | -LL | async fn box_pin_ref_Alias(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.rs b/src/test/ui/self/elision/ref-mut-self-async.rs index 7d143e1b35e45..a6bd9d693163e 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.rs +++ b/src/test/ui/self/elision/ref-mut-self-async.rs @@ -12,42 +12,30 @@ struct Struct { } impl Struct { // Test using `&mut self` sugar: - async fn ref_self(&mut self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime + async fn ref_self(&mut self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch f } // Test using `&mut Self` explicitly: async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr index 15f5f8dd0dd48..d605bab463697 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -1,159 +1,56 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-mut-self-async.rs:15:46 | LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:23:52 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:29:61 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35:61 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41:70 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:47:70 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:15:34 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:23 - --> $DIR/ref-mut-self-async.rs:15:23 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:23 - | -LL | async fn ref_self(&mut self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:23:40 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 23:29 - --> $DIR/ref-mut-self-async.rs:23:29 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:24:52 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 23:29 - | -LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:29:49 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 29:37 - --> $DIR/ref-mut-self-async.rs:29:37 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:28:61 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 29:37 - | -LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:35:49 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:32:61 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 35:37 - --> $DIR/ref-mut-self-async.rs:35:37 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 35:37 - | -LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:41:58 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 41:45 - --> $DIR/ref-mut-self-async.rs:41:45 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:36:70 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 41:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-self-async.rs:47:58 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 47:45 - --> $DIR/ref-mut-self-async.rs:47:45 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-self-async.rs:40:70 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 47:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | --------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 12 previous errors +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.rs b/src/test/ui/self/elision/ref-mut-struct-async.rs index 3ba9c95d35ff4..7a89ef9596a37 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.rs +++ b/src/test/ui/self/elision/ref-mut-struct-async.rs @@ -13,33 +13,23 @@ impl Struct { // Test using `&mut Struct` explicitly: async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-struct-async.stderr b/src/test/ui/self/elision/ref-mut-struct-async.stderr index fd2581eba9434..4c983872942c1 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.stderr @@ -1,133 +1,47 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-mut-struct-async.rs:15:56 | LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:21:65 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:27:65 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33:74 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39:74 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:15:44 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 - --> $DIR/ref-mut-struct-async.rs:15:31 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 - | -LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:21:53 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 - --> $DIR/ref-mut-struct-async.rs:21:39 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:19:65 | LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 - | -LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:27:53 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 - --> $DIR/ref-mut-struct-async.rs:27:39 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:23:65 | LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:33:62 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 - --> $DIR/ref-mut-struct-async.rs:33:47 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:27:74 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-mut-struct-async.rs:39:62 +error[E0623]: lifetime mismatch + --> $DIR/ref-mut-struct-async.rs:31:74 | LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:47 - --> $DIR/ref-mut-struct-async.rs:39:47 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:47 - | -LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-self-async.rs b/src/test/ui/self/elision/ref-self-async.rs index 6cca5494ff784..5a5705d7e099b 100644 --- a/src/test/ui/self/elision/ref-self-async.rs +++ b/src/test/ui/self/elision/ref-self-async.rs @@ -21,48 +21,34 @@ impl Deref for Wrap { impl Struct { // Test using `&self` sugar: - async fn ref_self(&self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime + async fn ref_self(&self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch f } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index eab77cfacd956..e169f3cf6f1f7 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -1,185 +1,65 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-self-async.rs:24:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:32:48 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:38:57 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:44:57 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:50:66 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56:66 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:62:69 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:24:30 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 24:23 - --> $DIR/ref-self-async.rs:24:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 24:23 - | -LL | async fn ref_self(&self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:32:36 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 32:29 - --> $DIR/ref-self-async.rs:32:29 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:33:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 32:29 - | -LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:38:45 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 38:37 - --> $DIR/ref-self-async.rs:38:37 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:37:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 38:37 - | -LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:44:45 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 44:37 - --> $DIR/ref-self-async.rs:44:37 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:41:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 44:37 - | -LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:50:54 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:45:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 50:45 - --> $DIR/ref-self-async.rs:50:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 50:45 - | -LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:56:54 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 56:45 - --> $DIR/ref-self-async.rs:56:45 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:49:66 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 56:45 - | -LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ----- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-self-async.rs:62:58 +error[E0623]: lifetime mismatch + --> $DIR/ref-self-async.rs:53:69 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ --- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 62:44 - --> $DIR/ref-self-async.rs:62:44 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 62:44 - | -LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 + '_ { - | ^^^^^^^^ + | ----- ^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 14 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-struct-async.rs b/src/test/ui/self/elision/ref-struct-async.rs index cd0f5a2a6058d..f0410bbee906d 100644 --- a/src/test/ui/self/elision/ref-struct-async.rs +++ b/src/test/ui/self/elision/ref-struct-async.rs @@ -13,33 +13,23 @@ impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - f + f //~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-struct-async.stderr b/src/test/ui/self/elision/ref-struct-async.stderr index 966e102fa5f27..574b0fddc1eb2 100644 --- a/src/test/ui/self/elision/ref-struct-async.stderr +++ b/src/test/ui/self/elision/ref-struct-async.stderr @@ -1,133 +1,47 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/ref-struct-async.rs:15:52 | LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:21:61 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:27:61 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33:70 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39:66 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:15:40 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:31 - --> $DIR/ref-struct-async.rs:15:31 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:31 - | -LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:21:49 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 21:39 - --> $DIR/ref-struct-async.rs:21:39 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:19:61 | LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 21:39 - | -LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:27:49 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 27:39 - --> $DIR/ref-struct-async.rs:27:39 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:23:61 | LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 27:39 - | -LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:33:58 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 33:47 - --> $DIR/ref-struct-async.rs:33:47 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:27:70 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 33:47 - | -LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: cannot infer an appropriate lifetime - --> $DIR/ref-struct-async.rs:39:54 +error[E0623]: lifetime mismatch + --> $DIR/ref-struct-async.rs:31:66 | LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 39:43 - --> $DIR/ref-struct-async.rs:39:43 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 39:43 - | -LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 + '_ { - | ^^^^^^^^^ + | ------- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0106`. From cbe8518407fd6986093946353252b0384867aa53 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 18:14:48 -0400 Subject: [PATCH 18/32] use `modern` everywhere --- src/librustc/hir/lowering.rs | 3 +++ src/librustc/hir/lowering/item.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 184180d67be7b..0816c7a20f850 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -136,6 +136,9 @@ pub struct LoweringContext<'a> { /// When `is_collectin_in_band_lifetimes` is true, each lifetime is checked /// against this list to see if it is already in-scope, or if a definition /// needs to be created for it. + /// + /// We always store a `modern()` version of the param-name in this + /// vector. in_scope_lifetimes: Vec, current_module: NodeId, diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 4d6039e101a88..7b774812a24f2 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -123,7 +123,7 @@ impl LoweringContext<'_> { _ => &[], }; let lt_def_names = parent_generics.iter().filter_map(|param| match param.kind { - hir::GenericParamKind::Lifetime { .. } => Some(param.name), + hir::GenericParamKind::Lifetime { .. } => Some(param.name.modern()), _ => None, }); self.in_scope_lifetimes.extend(lt_def_names); From a02a171e6a8e1cf601867230bba577c0351461b2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 18:33:53 -0400 Subject: [PATCH 19/32] add edition to regression test --- .../ui/async-await/async-fn-elided-impl-lifetime-parameter.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs b/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs index 4ded6385325a8..1cbc5133a07e6 100644 --- a/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs +++ b/src/test/ui/async-await/async-fn-elided-impl-lifetime-parameter.rs @@ -4,6 +4,7 @@ // Regression test for #63500. // // check-pass +// edition:2018 #![feature(async_await)] From 948739f2eef514357a0f1ab2eb12d6bdb05a7d41 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 19:21:13 -0400 Subject: [PATCH 20/32] revamp comment --- src/librustc/hir/lowering.rs | 76 +++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 8e7f96ca23665..8901738637453 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2570,7 +2570,54 @@ impl<'a> LoweringContext<'a> { self.allocate_hir_id_counter(opaque_ty_node_id); + // When we create the opaque type for this async fn, it is going to have + // to capture all the lifetimes involved in the signature (including in the + // return type). This is done by introducing lifetime parameters for: + // + // - all the explicitly declared lifetimes from the impl and function itself; + // - all the elided lifetimes in the fn arguments; + // - all the elided lifetimes in the return type. + // + // So for example in this snippet: + // + // ```rust + // impl<'a> Foo<'a> { + // async fn bar<'b>(&self, x: &'b Vec, y: &str) -> &u32 { + // // ^ '0 ^ '1 ^ '2 + // // elided lifetimes used below + // } + // } + // ``` + // + // we would create an opaque type like: + // + // ``` + // type Bar<'a, 'b, '0, '1, '2> = impl Future; + // ``` + // + // and we would then desugar `bar` to the equivalent of: + // + // ```rust + // impl<'a> Foo<'a> { + // fn bar<'b, '0, '1>(&'0 self, x: &'b Vec, y: &'1 str) -> Bar<'a, 'b, '0, '1, '_> + // } + // ``` + // + // Note that the final parameter to `Bar` is `'_`, not `'2` -- + // this is because the elided lifetimes from the return type + // should be figured out using the ordinary elision rules, and + // this desugaring achieves that. + // + // The variable `input_lifetimes_count` tracks the number of + // lifetime parameters to the opaque type *not counting* those + // lifetimes elided in the return type. This includes those + // that are explicitly declared (`in_scope_lifetimes`) and + // those elided lifetimes we found in the arguments (current + // content of `lifetimes_to_define`). Next, we will process + // the return type, which will cause `lifetimes_to_define` to + // grow. let input_lifetimes_count = self.in_scope_lifetimes.len() + self.lifetimes_to_define.len(); + let (opaque_ty_id, lifetime_params) = self.with_hir_id_owner(opaque_ty_node_id, |this| { // We have to be careful to get elision right here. The // idea is that we create a lifetime parameter for each @@ -2635,29 +2682,27 @@ impl<'a> LoweringContext<'a> { (opaque_ty_id, lifetime_params) }); - // Create the generic lifetime arguments that we will supply - // to the opaque return type. Consider: + // As documented above on the variable + // `input_lifetimes_count`, we need to create the lifetime + // arguments to our opaque type. Continuing with our example, + // we're creating the type arguments for the return type: // - // ```rust - // async fn foo(x: &u32, ) -> &[&u32] { .. } // ``` - // - // Here, we would create something like: - // - // ```rust - // type Foo<'a, 'b, 'c> = impl Future; - // fn foo<'a>(x: &'a u32) -> Foo<'a, '_, '_> + // Bar<'a, 'b, '0, '1, '_> // ``` // - // Note that for the lifetimes which came from the input - // (`'a`, here), we supply them as arguments to the return - // type `Foo`. But for those lifetime parameters (`'b`, `'c`) - // that we created from the return type, we want to use `'_` - // in the return type, so as to trigger elision. + // For the "input" lifetime parameters, we wish to create + // references to the parameters themselves, including the + // "implicit" ones created from parameter types (`'a`, `'b`, + // '`0`, `'1`). + // + // For the "output" lifetime parameters, we just want to + // generate `'_`. let mut generic_args: Vec<_> = lifetime_params[..input_lifetimes_count] .iter() .map(|&(span, hir_name)| { + // Input lifetime like `'a` or `'1`: GenericArg::Lifetime(hir::Lifetime { hir_id: self.next_id(), span, @@ -2669,6 +2714,7 @@ impl<'a> LoweringContext<'a> { lifetime_params[input_lifetimes_count..] .iter() .map(|&(span, _)| { + // Output lifetime like `'_`. GenericArg::Lifetime(hir::Lifetime { hir_id: self.next_id(), span, From ad214fe47092c5b3d36a58480f6fa3f62d20770b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 19:23:21 -0400 Subject: [PATCH 21/32] fix README.md --- src/test/ui/self/elision/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/ui/self/elision/README.md b/src/test/ui/self/elision/README.md index 2db8a23be6ec6..3bd7a6c00b2ad 100644 --- a/src/test/ui/self/elision/README.md +++ b/src/test/ui/self/elision/README.md @@ -61,10 +61,10 @@ Legends: | `struct-async.rs`| ✓ | ✓ | N/A | | `alias-async.rs`| ✓ | ✓ | N/A | | `assoc-async.rs`| ✓ | ✓ | N/A | -| `ref-self-async.rs` | ✓ | ✓ | N/A | -| `ref-mut-self-async.rs` | ✓ | ✓ | N/A | -| `ref-struct-async.rs` | ✓ | ✓ | N/A | -| `ref-mut-struct-async.rs` | ✓ | ✓ | N/A | +| `ref-self-async.rs` | X | ✓ | N/A | +| `ref-mut-self-async.rs` | X | ✓ | N/A | +| `ref-struct-async.rs` | X | ✓ | N/A | +| `ref-mut-struct-async.rs` | X | ✓ | N/A | | `ref-alias-async.rs` | ✓ | ✓ | N/A | | `ref-assoc-async.rs` | ✓ | ✓ | N/A | | `ref-mut-alias-async.rs` | ✓ | ✓ | N/A | @@ -72,4 +72,4 @@ Legends: | `lt-struct-async.rs` | ✓ | ✓ | N/A | `lt-alias-async.rs` | ✓ | ✓ | N/A | `lt-assoc-async.rs` | ✓ | ✓ | N/A -| `lt-ref-self-async.rs` | ✓ | ✓ | N/A | +| `lt-ref-self-async.rs` | X | ✓ | N/A | From e4756e6b07989d1cf195667bcf5d9f780618031a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 21:08:32 -0400 Subject: [PATCH 22/32] clear in-scope lifetimes for nested items in HIR lowering This was causing us to incorrectly think the lifetimes were already declared on the scope for the nested item, when in fact they are not inherited. --- src/librustc/hir/lowering/item.rs | 32 ++++++++++++++++--- src/test/ui/async-await/nested-in-impl.rs | 17 ++++++++++ src/test/ui/in-band-lifetimes/nested-items.rs | 20 ++++++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/async-await/nested-in-impl.rs create mode 100644 src/test/ui/in-band-lifetimes/nested-items.rs diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 7b774812a24f2..dd95d99d4e1d6 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -60,10 +60,12 @@ impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> { fn visit_item(&mut self, item: &'tcx Item) { let mut item_hir_id = None; self.lctx.with_hir_id_owner(item.id, |lctx| { - if let Some(hir_item) = lctx.lower_item(item) { - item_hir_id = Some(hir_item.hir_id); - lctx.insert_item(hir_item); - } + lctx.without_in_scope_lifetime_defs(|lctx| { + if let Some(hir_item) = lctx.lower_item(item) { + item_hir_id = Some(hir_item.hir_id); + lctx.insert_item(hir_item); + } + }) }); if let Some(hir_id) = item_hir_id { @@ -134,6 +136,28 @@ impl LoweringContext<'_> { res } + // Clears (and restores) the `in_scope_lifetimes` field. Used when + // visiting nested items, which never inherit in-scope lifetimes + // from their surrounding environment. + fn without_in_scope_lifetime_defs( + &mut self, + f: impl FnOnce(&mut LoweringContext<'_>) -> T, + ) -> T { + let old_in_scope_lifetimes = std::mem::replace(&mut self.in_scope_lifetimes, vec![]); + + // this vector is only used when walking over impl headers, + // input types, and the like, and should not be non-empty in + // between items + assert!(self.lifetimes_to_define.is_empty()); + + let res = f(self); + + assert!(self.in_scope_lifetimes.is_empty()); + self.in_scope_lifetimes = old_in_scope_lifetimes; + + res + } + pub(super) fn lower_mod(&mut self, m: &Mod) -> hir::Mod { hir::Mod { inner: m.inner, diff --git a/src/test/ui/async-await/nested-in-impl.rs b/src/test/ui/async-await/nested-in-impl.rs new file mode 100644 index 0000000000000..3c82160595f1d --- /dev/null +++ b/src/test/ui/async-await/nested-in-impl.rs @@ -0,0 +1,17 @@ +// Test that async fn works when nested inside of +// impls with lifetime parameters. +// +// check-pass +// edition:2018 + +#![feature(async_await)] + +struct Foo<'a>(&'a ()); + +impl<'a> Foo<'a> { + fn test() { + async fn test() {} + } +} + +fn main() { } diff --git a/src/test/ui/in-band-lifetimes/nested-items.rs b/src/test/ui/in-band-lifetimes/nested-items.rs new file mode 100644 index 0000000000000..7de20712fba94 --- /dev/null +++ b/src/test/ui/in-band-lifetimes/nested-items.rs @@ -0,0 +1,20 @@ +// Test that the `'a` from the impl doesn't +// prevent us from creating a `'a` parameter +// on the `blah` function. +// +// check-pass + +#![feature(in_band_lifetimes)] + +struct Foo<'a> { + x: &'a u32 + +} + +impl Foo<'a> { + fn method(&self) { + fn blah(f: Foo<'a>) { } + } +} + +fn main() { } From d7c7c52dbc462048cb60d4dca43b42d753025a6b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 12 Aug 2019 21:13:59 -0400 Subject: [PATCH 23/32] bless tests --- ..._self_types_pin_lifetime_mismatch-async.rs | 10 +-- ...f_types_pin_lifetime_mismatch-async.stderr | 85 +++---------------- .../ui/self/elision/ref-mut-self-async.stderr | 10 +-- .../ui/self/elision/ref-self-async.stderr | 12 +-- .../ui/self/self_lifetime-async.nll.stderr | 11 --- src/test/ui/self/self_lifetime-async.rs | 6 +- src/test/ui/self/self_lifetime-async.stderr | 39 --------- 7 files changed, 27 insertions(+), 146 deletions(-) delete mode 100644 src/test/ui/self/self_lifetime-async.nll.stderr delete mode 100644 src/test/ui/self/self_lifetime-async.stderr diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs index 93870b7cdcf28..53ab75ee16bd0 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.rs @@ -8,16 +8,10 @@ struct Foo; impl Foo { async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - // FIXME: should be E0623? + //~^ ERROR lifetime mismatch async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - //~| ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime - // FIXME: should be E0623? + //~^ ERROR lifetime mismatch } type Alias = Pin; diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index c7d10e7fc780d..74fc474134949 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -1,81 +1,23 @@ -error[E0106]: missing lifetime specifier +error[E0623]: lifetime mismatch --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + | ---- ^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:33 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ ---- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 10:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:26 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 10:26 - | -LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo + '_ { f } - | ^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:16 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^^^^ ...but this borrow... ----------------- this return type evaluates to the `'static` lifetime... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: cannot infer an appropriate lifetime - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:34 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ ----------------- this return type evaluates to the `'static` lifetime... - | | - | ...but this borrow... - | -note: ...can't outlive the lifetime '_ as defined on the method body at 15:26 - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:26 +error[E0623]: lifetime mismatch + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:13:55 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 15:26 - | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) + '_ { (self, f) } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ----- ^^^^^^^^^^^^^^^^^ + | | | + | | ...but data from `f` is returned here + | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:25:58 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:58 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | ----- ^^^ @@ -83,6 +25,5 @@ LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | | ...but data from `arg` is returned here | this parameter and the return type are declared with different lifetimes... -error: aborting due to 7 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr index d605bab463697..805833f94720d 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -8,7 +8,7 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:24:52 + --> $DIR/ref-mut-self-async.rs:21:52 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | --------- ^^^^ @@ -17,7 +17,7 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:28:61 + --> $DIR/ref-mut-self-async.rs:25:61 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | --------- ^^^^ @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:32:61 + --> $DIR/ref-mut-self-async.rs:29:61 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | --------- ^^^^ @@ -35,7 +35,7 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:36:70 + --> $DIR/ref-mut-self-async.rs:33:70 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | --------- ^^^^ @@ -44,7 +44,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:40:70 + --> $DIR/ref-mut-self-async.rs:37:70 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | --------- ^^^^ diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index e169f3cf6f1f7..eb796a07a86d5 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -8,7 +8,7 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:33:48 + --> $DIR/ref-self-async.rs:30:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | ----- ^^^^ @@ -17,7 +17,7 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:37:57 + --> $DIR/ref-self-async.rs:34:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | ----- ^^^^ @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:41:57 + --> $DIR/ref-self-async.rs:38:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | ----- ^^^^ @@ -35,7 +35,7 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:45:66 + --> $DIR/ref-self-async.rs:42:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | ----- ^^^^ @@ -44,7 +44,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:49:66 + --> $DIR/ref-self-async.rs:46:66 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | ----- ^^^^ @@ -53,7 +53,7 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:53:69 + --> $DIR/ref-self-async.rs:50:69 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | ----- ^^^ diff --git a/src/test/ui/self/self_lifetime-async.nll.stderr b/src/test/ui/self/self_lifetime-async.nll.stderr deleted file mode 100644 index 805d2433f87ac..0000000000000 --- a/src/test/ui/self/self_lifetime-async.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/self_lifetime-async.rs:9:44 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/self_lifetime-async.rs b/src/test/ui/self/self_lifetime-async.rs index 71eba01fe1a02..ec4c3d1522423 100644 --- a/src/test/ui/self/self_lifetime-async.rs +++ b/src/test/ui/self/self_lifetime-async.rs @@ -1,5 +1,4 @@ -// FIXME: Investigate why `self_lifetime.rs` is check-pass but this isn't. - +// check-pass // edition:2018 #![feature(async_await)] @@ -7,14 +6,11 @@ struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - //~^ ERROR missing lifetime specifier - //~| ERROR cannot infer an appropriate lifetime } type Alias = Foo<'static>; impl Alias { async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - //~^ ERROR lifetime mismatch } fn main() {} diff --git a/src/test/ui/self/self_lifetime-async.stderr b/src/test/ui/self/self_lifetime-async.stderr deleted file mode 100644 index e3ec1abd44763..0000000000000 --- a/src/test/ui/self/self_lifetime-async.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/self_lifetime-async.rs:9:44 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found none. - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/self_lifetime-async.rs:9:22 - | -LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | ^^^^ - | -note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 8:6... - --> $DIR/self_lifetime-async.rs:8:6 - | -LL | impl<'a> Foo<'a> { - | ^^ - = note: ...so that the expression is assignable: - expected &Foo<'_> - found &'b Foo<'a> - = note: but, the lifetime must be valid for the static lifetime... - = note: ...so that the types are compatible: - expected &() - found &'static () - -error[E0623]: lifetime mismatch - --> $DIR/self_lifetime-async.rs:16:52 - | -LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - | ------ ^^^ - | | | - | | ...but data from `arg` is returned here - | this parameter and the return type are declared with different lifetimes... - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0106`. From 84cab928db8526af7c42e1637e7253a009da215d Mon Sep 17 00:00:00 2001 From: Gurwinder Singh Date: Tue, 13 Aug 2019 13:18:48 +0530 Subject: [PATCH 24/32] Provide map_ok and map_err method for Poll>> --- src/libcore/task/poll.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libcore/task/poll.rs b/src/libcore/task/poll.rs index 3db70d5e7645f..fec17c4d1a4df 100644 --- a/src/libcore/task/poll.rs +++ b/src/libcore/task/poll.rs @@ -81,6 +81,34 @@ impl Poll> { } } +impl Poll>> { + /// Changes the success value of this `Poll` with the closure provided. + #[unstable(feature = "poll_map", issue = "63514")] + pub fn map_ok(self, f: F) -> Poll>> + where F: FnOnce(T) -> U + { + match self { + Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(f(t)))), + Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))), + Poll::Ready(None) => Poll::Ready(None), + Poll::Pending => Poll::Pending, + } + } + + /// Changes the error value of this `Poll` with the closure provided. + #[unstable(feature = "poll_map", issue = "63514")] + pub fn map_err(self, f: F) -> Poll>> + where F: FnOnce(E) -> U + { + match self { + Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(t))), + Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(f(e)))), + Poll::Ready(None) => Poll::Ready(None), + Poll::Pending => Poll::Pending, + } + } +} + #[stable(feature = "futures_api", since = "1.36.0")] impl From for Poll { fn from(t: T) -> Poll { From e9b3a0176440fa1696c730b55d82e68e8e6c41f6 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 11 Aug 2019 12:55:31 -0400 Subject: [PATCH 25/32] Bump to 1.39 --- src/bootstrap/channel.rs | 2 +- src/stage0.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 8e8d8f5e787a7..caa4843da4d36 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -13,7 +13,7 @@ use build_helper::output; use crate::Build; // The version number -pub const CFG_RELEASE_NUM: &str = "1.38.0"; +pub const CFG_RELEASE_NUM: &str = "1.39.0"; pub struct GitInfo { inner: Option, diff --git a/src/stage0.txt b/src/stage0.txt index 14d65bef8f6dd..1a9e64a1862c9 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2019-07-04 +date: 2019-08-13 rustc: beta cargo: beta @@ -25,7 +25,7 @@ cargo: beta # # This means that there's a small window of time (a few days) where artifacts # are downloaded from dev-static.rust-lang.org instead of static.rust-lang.org. -# In order to ease this transition we have an extra key which is in the +# In order to ease this transition we have an extra key which is in the # configuration file below. When uncommented this will instruct the bootstrap.py # script to download from dev-static.rust-lang.org. # From 18d69c8ebe7b313d574014e6585680f78bd2e157 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 13 Aug 2019 09:13:50 -0400 Subject: [PATCH 26/32] bless tests with compare-mode=nll --- .../issues/issue-63388-1.nll.stderr | 24 +++ .../issues/issue-63388-2.nll.stderr | 11 ++ ...pes_pin_lifetime_mismatch-async.nll.stderr | 49 ++++-- .../self/elision/lt-ref-self-async.nll.stderr | 122 ++++++++++++--- .../elision/ref-mut-self-async.nll.stderr | 122 ++++++++++++--- .../elision/ref-mut-struct-async.nll.stderr | 102 ++++++++++--- .../ui/self/elision/ref-self-async.nll.stderr | 142 ++++++++++++++---- .../self/elision/ref-struct-async.nll.stderr | 102 ++++++++++--- 8 files changed, 538 insertions(+), 136 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-63388-1.nll.stderr create mode 100644 src/test/ui/async-await/issues/issue-63388-2.nll.stderr diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr new file mode 100644 index 0000000000000..fab5892dae183 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -0,0 +1,24 @@ +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/issue-63388-1.rs:14:10 + | +LL | ) -> &dyn Foo + | ^^^^^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#27r + +error: lifetime may not live long enough + --> $DIR/issue-63388-1.rs:15:5 + | +LL | async fn do_sth<'a>( + | -- lifetime `'a` defined here +LL | &'a self, foo: &dyn Foo + | - lifetime `'_` defined here +LL | ) -> &dyn Foo +LL | / { +LL | | foo +LL | | } + | |_____^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'_` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/async-await/issues/issue-63388-2.nll.stderr b/src/test/ui/async-await/issues/issue-63388-2.nll.stderr new file mode 100644 index 0000000000000..b91cdc1b770fb --- /dev/null +++ b/src/test/ui/async-await/issues/issue-63388-2.nll.stderr @@ -0,0 +1,11 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-63388-2.rs:14:10 + | +LL | ) -> &dyn Foo + | ^ help: consider using the named lifetime: `&'a` + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `foo` or `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 6585609555675..94646c2cfe0c3 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -1,27 +1,46 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:45 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:60 +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:50 | -LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ - | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } + | - ^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + | | + | lifetime `'_` defined here + | lifetime `'_` defined here -error[E0106]: missing lifetime specifier - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:67 +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:13:73 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ^ + | - ^^^^^^^^^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + | | + | lifetime `'_` defined here + | lifetime `'_` defined here + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:58 + | +LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | ^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } + | -- - ^^^^^^^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'a` + | | | + | | lifetime `'_` defined here + | lifetime `'a` defined here -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr index d3aeb73b9b7c2..779b21e21a097 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -1,51 +1,123 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/lt-ref-self-async.rs:15:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:23:48 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:15:47 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | _______________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:21:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:29:57 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:21:53 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | _____________________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:25:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:25:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:35:57 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:29:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:29:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:41:66 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:33:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#28r -error[E0106]: missing lifetime specifier - --> $DIR/lt-ref-self-async.rs:47:62 +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:33:71 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/lt-ref-self-async.rs:37:62 | LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#28r + +error: lifetime may not live long enough + --> $DIR/lt-ref-self-async.rs:37:67 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { + | _________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error: aborting due to 6 previous errors +error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index 35969659b19d1..cfe91dde37354 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -1,51 +1,123 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/ref-mut-self-async.rs:15:46 | LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:23:52 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:15:51 + | +LL | async fn ref_self(&mut self, f: &u32) -> &u32 { + | _______________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:21:52 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:29:61 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:21:57 + | +LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { + | _____________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:25:61 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:25:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { + | _____________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:35:61 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:29:61 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:29:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { + | _____________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:41:70 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:33:70 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-self-async.rs:47:70 +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:33:75 + | +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-self-async.rs:37:70 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-self-async.rs:37:75 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error: aborting due to 6 previous errors +error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr index a70dcf5b0ad19..98fa5e2545186 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -1,43 +1,103 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/ref-mut-struct-async.rs:15:56 | LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:21:65 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:15:61 + | +LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { + | _______________________________-_____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-struct-async.rs:19:65 | LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:27:65 +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:19:70 + | +LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { + | _______________________________________-______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-struct-async.rs:23:65 | LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:23:70 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { + | _______________________________________-______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:33:74 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-struct-async.rs:27:74 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:27:79 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-_______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-mut-struct-async.rs:39:74 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-mut-struct-async.rs:31:74 | LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-mut-struct-async.rs:31:79 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-_______________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr index ae17ba9839d22..f991f6d9f7fa1 100644 --- a/src/test/ui/self/elision/ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-self-async.nll.stderr @@ -1,59 +1,143 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/ref-self-async.rs:24:42 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:32:48 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:24:47 + | +LL | async fn ref_self(&self, f: &u32) -> &u32 { + | _______________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:30:48 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:38:57 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:30:53 + | +LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { + | _____________________________-_______________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:34:57 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:34:62 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:44:57 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:38:57 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:50:66 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:38:62 + | +LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { + | _____________________________________-________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:42:66 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:42:71 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:56:66 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:46:66 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-self-async.rs:62:69 +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:46:71 + | +LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { + | _____________________________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-self-async.rs:50:69 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ^ + | ^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-self-async.rs:50:73 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { + | ____________________________________________-____________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error: aborting due to 7 previous errors +error: aborting due to 14 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr index b4f12d7057db4..437d403e044ed 100644 --- a/src/test/ui/self/elision/ref-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -1,43 +1,103 @@ -error[E0106]: missing lifetime specifier +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/ref-struct-async.rs:15:52 | LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:21:61 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:15:57 + | +LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | _______________________________-_________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-struct-async.rs:19:61 | LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ^ + | ^^^^ | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. + = note: hidden type `impl std::future::Future` captures lifetime '_#18r -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:27:61 +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:19:66 + | +LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { + | _______________________________________-__________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` + +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-struct-async.rs:23:61 | LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:23:66 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { + | _______________________________________-__________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:33:70 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-struct-async.rs:27:70 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:27:75 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { + | _______________________________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error[E0106]: missing lifetime specifier - --> $DIR/ref-struct-async.rs:39:66 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/ref-struct-async.rs:31:66 | LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ^ + | ^^^^ + | + = note: hidden type `impl std::future::Future` captures lifetime '_#18r + +error: lifetime may not live long enough + --> $DIR/ref-struct-async.rs:31:71 | - = note: return-position elided lifetimes require exactly one input-position elided lifetime, found multiple. +LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { + | ___________________________________________-___________________________^ + | | | + | | lifetime `'_` defined here + | | lifetime `'_` defined here +LL | | f +LL | | } + | |_____^ function was supposed to return data with lifetime `'_` but it is returning data with lifetime `'_` -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0700`. From c259d1c7c80ff83159d5abf5207baa3abcb43a7f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 13 Aug 2019 11:00:32 -0700 Subject: [PATCH 27/32] RELEASES.md: ? is one of three Kleene operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The slash and quotes in ?/“Kleene” appeared to define “Kleene” as the name for the ? operator, which is not the case. Rust has three Kleene operators *, +, ?. (Pointed out by /u/Sharlinator on Reddit.) Signed-off-by: Anders Kaseorg --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 51cd6578ec531..12131e74c486c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -22,7 +22,7 @@ Language - [You can now use `_` as an identifier for consts.][61347] e.g. You can write `const _: u32 = 5;`. - [You can now use `#[repr(align(X)]` on enums.][61229] -- [The `?`/_"Kleene"_ macro operator is now available in the +- [The `?` Kleene macro operator is now available in the 2015 edition.][60932] Compiler From ea1a9a0e2ba1da31e2de524bf9b0a7af6b02daff Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 13 Aug 2019 11:21:09 -0700 Subject: [PATCH 28/32] Fix typo in error message. --- src/libsyntax/parse/parser/expr.rs | 2 +- src/test/ui/issues/issue-13483.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 4432c1329cbfe..5f04012d7103d 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1199,7 +1199,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(kw::Else) || !cond.returns() { let sp = self.sess.source_map().next_point(lo); let mut err = self.diagnostic() - .struct_span_err(sp, "missing condition for `if` statemement"); + .struct_span_err(sp, "missing condition for `if` statement"); err.span_label(sp, "expected if condition here"); return Err(err) } diff --git a/src/test/ui/issues/issue-13483.stderr b/src/test/ui/issues/issue-13483.stderr index 739f061236697..faaf8690291b7 100644 --- a/src/test/ui/issues/issue-13483.stderr +++ b/src/test/ui/issues/issue-13483.stderr @@ -1,10 +1,10 @@ -error: missing condition for `if` statemement +error: missing condition for `if` statement --> $DIR/issue-13483.rs:3:14 | LL | } else if { | ^ expected if condition here -error: missing condition for `if` statemement +error: missing condition for `if` statement --> $DIR/issue-13483.rs:10:14 | LL | } else if { From 8abaf9dd799915dc9168d2e4f4a73353667616fa Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 11 Aug 2019 12:55:14 -0400 Subject: [PATCH 29/32] Handle cfg(bootstrap) throughout --- src/bootstrap/bin/rustc.rs | 5 +-- src/bootstrap/builder.rs | 2 +- src/liballoc/collections/btree/node.rs | 6 ++-- src/liballoc/lib.rs | 6 ++-- src/libcore/any.rs | 5 --- src/libcore/char/methods.rs | 14 ++------ src/libcore/clone.rs | 1 - src/libcore/cmp.rs | 4 --- src/libcore/default.rs | 1 - src/libcore/fmt/mod.rs | 2 -- src/libcore/hash/mod.rs | 2 -- src/libcore/lib.rs | 4 +-- src/libcore/macros.rs | 35 ------------------- src/libcore/marker.rs | 1 - src/libcore/mem/maybe_uninit.rs | 2 +- src/libcore/mem/mod.rs | 4 +-- src/libcore/prelude/v1.rs | 4 --- src/librustc/lint/context.rs | 4 +-- src/librustc/lint/internal.rs | 2 +- src/librustc/ty/codec.rs | 4 +-- src/librustc/ty/context.rs | 6 ++-- src/librustc/ty/flags.rs | 4 +-- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/sty.rs | 2 +- src/librustc_data_structures/lib.rs | 2 +- src/librustc_macros/src/lib.rs | 2 +- src/librustc_target/abi/mod.rs | 19 ++++------ src/librustc_typeck/check/mod.rs | 4 +-- src/libstd/lib.rs | 5 ++- src/libstd/os/raw/mod.rs | 48 +++++++++----------------- src/libstd/prelude/v1.rs | 18 ---------- src/libstd/sync/mod.rs | 1 - src/libunwind/build.rs | 8 ++--- src/libunwind/libunwind.rs | 10 +++--- src/test/ui/lint/lint-qualification.rs | 2 +- 35 files changed, 63 insertions(+), 178 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 54b689fb062a5..04a3dea5c8791 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -132,10 +132,7 @@ fn main() { cmd.arg("-Dwarnings"); cmd.arg("-Drust_2018_idioms"); cmd.arg("-Dunused_lifetimes"); - // cfg(not(bootstrap)): Remove this during the next stage 0 compiler update. - // `-Drustc::internal` is a new feature and `rustc_version` mis-reports the `stage`. - let cfg_not_bootstrap = stage != "0" && crate_name != Some("rustc_version"); - if cfg_not_bootstrap && use_internal_lints(crate_name) { + if use_internal_lints(crate_name) { cmd.arg("-Zunstable-options"); cmd.arg("-Drustc::internal"); } diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e54c9360baece..9e4cd5ebca749 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -145,7 +145,7 @@ impl StepDescription { only_hosts: S::ONLY_HOSTS, should_run: S::should_run, make_run: S::make_run, - name: unsafe { ::std::intrinsics::type_name::() }, + name: std::any::type_name::(), } } diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index e067096f0c780..0b5a271dbea95 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -106,8 +106,8 @@ impl LeafNode { LeafNode { // As a general policy, we leave fields uninitialized if they can be, as this should // be both slightly faster and easier to track in Valgrind. - keys: uninit_array![_; CAPACITY], - vals: uninit_array![_; CAPACITY], + keys: [MaybeUninit::UNINIT; CAPACITY], + vals: [MaybeUninit::UNINIT; CAPACITY], parent: ptr::null(), parent_idx: MaybeUninit::uninit(), len: 0 @@ -159,7 +159,7 @@ impl InternalNode { unsafe fn new() -> Self { InternalNode { data: LeafNode::new(), - edges: uninit_array![_; 2*B], + edges: [MaybeUninit::UNINIT; 2*B] } } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index a1936b36ac6bf..7421beddd9574 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -69,7 +69,7 @@ #![warn(missing_debug_implementations)] #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] -#![cfg_attr(not(bootstrap), allow(incomplete_features))] +#![allow(incomplete_features)] #![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(test, feature(test))] @@ -84,7 +84,7 @@ #![feature(coerce_unsized)] #![feature(const_generic_impls_guard)] #![feature(const_generics)] -#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] +#![feature(const_in_array_repeat_expressions)] #![feature(dispatch_from_dyn)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -118,7 +118,7 @@ #![feature(rustc_const_unstable)] #![feature(const_vec_new)] #![feature(slice_partition_dedup)] -#![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_array)] +#![feature(maybe_uninit_extra, maybe_uninit_slice)] #![feature(alloc_layout_extra)] #![feature(try_trait)] #![feature(mem_take)] diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 078091a9b5475..e8a0a88f12a7e 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -470,10 +470,5 @@ impl TypeId { #[stable(feature = "type_name", since = "1.38.0")] #[rustc_const_unstable(feature = "const_type_name")] pub const fn type_name() -> &'static str { - #[cfg(bootstrap)] - unsafe { - intrinsics::type_name::() - } - #[cfg(not(bootstrap))] intrinsics::type_name::() } diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index aa834db2b9b3e..e91bf53c5b418 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -553,12 +553,7 @@ impl char { /// `XID_Start` is a Unicode Derived Property specified in /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), /// mostly similar to `ID_Start` but modified for closure under `NFKx`. - #[cfg_attr(bootstrap, - unstable(feature = "rustc_private", - reason = "mainly needed for compiler internals", - issue = "27812"))] - #[cfg_attr(not(bootstrap), - unstable(feature = "unicode_internals", issue = "0"))] + #[unstable(feature = "unicode_internals", issue = "0")] pub fn is_xid_start(self) -> bool { derived_property::XID_Start(self) } @@ -569,12 +564,7 @@ impl char { /// `XID_Continue` is a Unicode Derived Property specified in /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications), /// mostly similar to `ID_Continue` but modified for closure under NFKx. - #[cfg_attr(bootstrap, - unstable(feature = "rustc_private", - reason = "mainly needed for compiler internals", - issue = "27812"))] - #[cfg_attr(not(bootstrap), - unstable(feature = "unicode_internals", issue = "0"))] + #[unstable(feature = "unicode_internals", issue = "0")] #[inline] pub fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 0c99356390bda..ec22a7ccfe4c3 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -134,7 +134,6 @@ pub trait Clone : Sized { } /// Derive macro generating an impl of the trait `Clone`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 38a52d97da212..b802216036b93 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -201,7 +201,6 @@ pub trait PartialEq { } /// Derive macro generating an impl of the trait `PartialEq`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] @@ -265,7 +264,6 @@ pub trait Eq: PartialEq { } /// Derive macro generating an impl of the trait `Eq`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] @@ -617,7 +615,6 @@ pub trait Ord: Eq + PartialOrd { } /// Derive macro generating an impl of the trait `Ord`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] @@ -867,7 +864,6 @@ pub trait PartialOrd: PartialEq { } /// Derive macro generating an impl of the trait `PartialOrd`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 8d95e9de15849..9b1616ccce448 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -116,7 +116,6 @@ pub trait Default: Sized { } /// Derive macro generating an impl of the trait `Default`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 0ea01d4b84a2c..d5fae9e740136 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -546,7 +546,6 @@ pub trait Debug { } // Separate module to reexport the macro `Debug` from prelude without the trait `Debug`. -#[cfg(not(bootstrap))] pub(crate) mod macros { /// Derive macro generating an impl of the trait `Debug`. #[rustc_builtin_macro] @@ -555,7 +554,6 @@ pub(crate) mod macros { #[allow_internal_unstable(core_intrinsics)] pub macro Debug($item:item) { /* compiler built-in */ } } -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(inline)] pub use macros::Debug; diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index c4cbf40a93a15..40b827b878782 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -199,7 +199,6 @@ pub trait Hash { } // Separate module to reexport the macro `Hash` from prelude without the trait `Hash`. -#[cfg(not(bootstrap))] pub(crate) mod macros { /// Derive macro generating an impl of the trait `Hash`. #[rustc_builtin_macro] @@ -208,7 +207,6 @@ pub(crate) mod macros { #[allow_internal_unstable(core_intrinsics)] pub macro Hash($item:item) { /* compiler built-in */ } } -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(inline)] pub use macros::Hash; diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 678ff7687921b..c168d5c8a2eac 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -63,7 +63,7 @@ #![warn(missing_debug_implementations)] #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings #![allow(explicit_outlives_requirements)] -#![cfg_attr(not(bootstrap), allow(incomplete_features))] +#![allow(incomplete_features)] #![feature(allow_internal_unstable)] #![feature(arbitrary_self_types)] @@ -129,7 +129,7 @@ #![feature(structural_match)] #![feature(abi_unadjusted)] #![feature(adx_target_feature)] -#![feature(maybe_uninit_slice, maybe_uninit_array)] +#![feature(maybe_uninit_slice)] #![feature(external_doc)] #![feature(mem_take)] #![feature(associated_type_bounds)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index f9dc53874acb1..bbed95167161d 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -635,46 +635,11 @@ macro_rules! todo { ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+))); } -/// Creates an array of [`MaybeUninit`]. -/// -/// This macro constructs an uninitialized array of the type `[MaybeUninit; N]`. -/// It exists solely because bootstrap does not yet support const array-init expressions. -/// -/// [`MaybeUninit`]: mem/union.MaybeUninit.html -// FIXME: Remove both versions of this macro once bootstrap is 1.38. -#[macro_export] -#[unstable(feature = "maybe_uninit_array", issue = "53491")] -#[cfg(bootstrap)] -macro_rules! uninit_array { - // This `assume_init` is safe because an array of `MaybeUninit` does not - // require initialization. - ($t:ty; $size:expr) => (unsafe { - MaybeUninit::<[MaybeUninit<$t>; $size]>::uninit().assume_init() - }); -} - -/// Creates an array of [`MaybeUninit`]. -/// -/// This macro constructs an uninitialized array of the type `[MaybeUninit; N]`. -/// It exists solely because bootstrap does not yet support const array-init expressions. -/// -/// [`MaybeUninit`]: mem/union.MaybeUninit.html -// FIXME: Just inline this version of the macro once bootstrap is 1.38. -#[macro_export] -#[unstable(feature = "maybe_uninit_array", issue = "53491")] -#[cfg(not(bootstrap))] -macro_rules! uninit_array { - ($t:ty; $size:expr) => ( - [MaybeUninit::<$t>::UNINIT; $size] - ); -} - /// Definitions of built-in macros. /// /// Most of the macro properties (stability, visibility, etc.) are taken from the source code here, /// with exception of expansion functions transforming macro inputs into outputs, /// those functions are provided by the compiler. -#[cfg(not(bootstrap))] pub(crate) mod builtin { /// Causes compilation to fail with the given error message when encountered. diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 78a273611650c..3befd421b0125 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -289,7 +289,6 @@ pub trait Copy : Clone { } /// Derive macro generating an impl of the trait `Copy`. -#[cfg(not(bootstrap))] #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 1bbea02e0c7c9..49711607262df 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -213,7 +213,7 @@ use crate::mem::ManuallyDrop; #[allow(missing_debug_implementations)] #[stable(feature = "maybe_uninit", since = "1.36.0")] // Lang item so we can wrap other types in it. This is useful for generators. -#[cfg_attr(not(bootstrap), lang = "maybe_uninit")] +#[lang = "maybe_uninit"] #[derive(Copy)] #[repr(transparent)] pub union MaybeUninit { diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 2534400b8334f..87ec05a243d36 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -453,7 +453,7 @@ pub const fn needs_drop() -> bool { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, allow(deprecated_in_future))] +#[allow(deprecated_in_future)] #[allow(deprecated)] pub unsafe fn zeroed() -> T { intrinsics::panic_if_uninhabited::(); @@ -481,7 +481,7 @@ pub unsafe fn zeroed() -> T { #[inline] #[rustc_deprecated(since = "1.39.0", reason = "use `mem::MaybeUninit` instead")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, allow(deprecated_in_future))] +#[allow(deprecated_in_future)] #[allow(deprecated)] pub unsafe fn uninitialized() -> T { intrinsics::panic_if_uninhabited::(); diff --git a/src/libcore/prelude/v1.rs b/src/libcore/prelude/v1.rs index 84cf85f339c99..762403790403d 100644 --- a/src/libcore/prelude/v1.rs +++ b/src/libcore/prelude/v1.rs @@ -46,16 +46,13 @@ pub use crate::option::Option::{self, Some, None}; pub use crate::result::Result::{self, Ok, Err}; // Re-exported built-in macros -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::fmt::macros::Debug; -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::hash::macros::Hash; -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ @@ -83,7 +80,6 @@ pub use crate::{ trace_macros, }; -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] #[doc(no_inline)] diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index de812410e8bd8..3584a12829018 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -1355,7 +1355,7 @@ struct LateLintPassObjects<'a> { lints: &'a mut [LateLintPassObject], } -#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))] +#[allow(rustc::lint_pass_impl_without_macro)] impl LintPass for LateLintPassObjects<'_> { fn name(&self) -> &'static str { panic!() @@ -1525,7 +1525,7 @@ struct EarlyLintPassObjects<'a> { lints: &'a mut [EarlyLintPassObject], } -#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))] +#[allow(rustc::lint_pass_impl_without_macro)] impl LintPass for EarlyLintPassObjects<'_> { fn name(&self) -> &'static str { panic!() diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs index 0b514f5927d30..dea1cc6601b04 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc/lint/internal.rs @@ -23,7 +23,7 @@ pub struct DefaultHashTypes { impl DefaultHashTypes { // we are allowed to use `HashMap` and `HashSet` as identifiers for implementing the lint itself - #[cfg_attr(not(bootstrap), allow(rustc::default_hash_types))] + #[allow(rustc::default_hash_types)] pub fn new() -> Self { let mut map = FxHashMap::default(); map.insert(sym::HashMap, sym::FxHashMap); diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index e3c6eca02d554..1ddc6780aca89 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -27,7 +27,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash { fn variant(&self) -> &Self::Variant; } -#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] +#[allow(rustc::usage_of_ty_tykind)] impl<'tcx> EncodableWithShorthand for Ty<'tcx> { type Variant = ty::TyKind<'tcx>; fn variant(&self) -> &Self::Variant { @@ -160,7 +160,7 @@ where Ok(decoder.map_encoded_cnum_to_current(cnum)) } -#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] +#[allow(rustc::usage_of_ty_tykind)] #[inline] pub fn decode_ty(decoder: &mut D) -> Result, D::Error> where diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ef74d9e5b2899..d504ba4dfe086 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -130,7 +130,7 @@ impl<'tcx> CtxtInterners<'tcx> { } /// Intern a type - #[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] + #[allow(rustc::usage_of_ty_tykind)] #[inline(never)] fn intern_ty(&self, st: TyKind<'tcx> @@ -2076,7 +2076,7 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> { } } -#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] +#[allow(rustc::usage_of_ty_tykind)] impl<'tcx> Borrow> for Interned<'tcx, TyS<'tcx>> { fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> { &self.0.sty @@ -2291,7 +2291,7 @@ impl<'tcx> TyCtxt<'tcx> { self.mk_fn_ptr(converted_sig) } - #[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] + #[allow(rustc::usage_of_ty_tykind)] #[inline] pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> { self.interners.intern_ty(st) diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 411b18e043a20..9119505acd174 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -18,7 +18,7 @@ impl FlagComputation { } } - #[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] + #[allow(rustc::usage_of_ty_tykind)] pub fn for_sty(st: &ty::TyKind<'_>) -> FlagComputation { let mut result = FlagComputation::new(); result.add_sty(st); @@ -62,7 +62,7 @@ impl FlagComputation { } // otherwise, this binder captures nothing } - #[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] + #[allow(rustc::usage_of_ty_tykind)] fn add_sty(&mut self, st: &ty::TyKind<'_>) { match st { &ty::Bool | diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 9d563e290de96..a8ff36a394657 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -483,7 +483,7 @@ bitflags! { } } -#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] +#[allow(rustc::usage_of_ty_tykind)] pub struct TyS<'tcx> { pub sty: TyKind<'tcx>, pub flags: TypeFlags, diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 129ea9b5b674a..42e367b851825 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1,6 +1,6 @@ //! This module contains `TyKind` and its major components. -#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))] +#![allow(rustc::usage_of_ty_tykind)] use crate::hir; use crate::hir::def_id::DefId; diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 9f103437d368e..f7593501959c7 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -27,7 +27,7 @@ #![cfg_attr(unix, feature(libc))] -#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))] +#![allow(rustc::default_hash_types)] #[macro_use] extern crate log; diff --git a/src/librustc_macros/src/lib.rs b/src/librustc_macros/src/lib.rs index 85e2247ebd7e3..3d3a020ef0c8e 100644 --- a/src/librustc_macros/src/lib.rs +++ b/src/librustc_macros/src/lib.rs @@ -1,5 +1,5 @@ #![feature(proc_macro_hygiene)] -#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))] +#![allow(rustc::default_hash_types)] #![recursion_limit="128"] diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index dd7ae742a63c6..dafa866117681 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -114,26 +114,20 @@ impl TargetDataLayout { [p] if p.starts_with("P") => { dl.instruction_address_space = parse_address_space(&p[1..], "P")? } - // FIXME: Ping cfg(bootstrap) -- Use `ref a @ ..` with new bootstrap compiler. - ["a", ..] => { - let a = &spec_parts[1..]; // FIXME inline into pattern. + ["a", ref a @ ..] => { dl.aggregate_align = align(a, "a")? } - ["f32", ..] => { - let a = &spec_parts[1..]; // FIXME inline into pattern. + ["f32", ref a @ ..] => { dl.f32_align = align(a, "f32")? } - ["f64", ..] => { - let a = &spec_parts[1..]; // FIXME inline into pattern. + ["f64", ref a @ ..] => { dl.f64_align = align(a, "f64")? } - [p @ "p", s, ..] | [p @ "p0", s, ..] => { - let a = &spec_parts[2..]; // FIXME inline into pattern. + [p @ "p", s, ref a @ ..] | [p @ "p0", s, ref a @ ..] => { dl.pointer_size = size(s, p)?; dl.pointer_align = align(a, p)?; } - [s, ..] if s.starts_with("i") => { - let a = &spec_parts[1..]; // FIXME inline into pattern. + [s, ref a @ ..] if s.starts_with("i") => { let bits = match s[1..].parse::() { Ok(bits) => bits, Err(_) => { @@ -157,8 +151,7 @@ impl TargetDataLayout { dl.i128_align = a; } } - [s, ..] if s.starts_with("v") => { - let a = &spec_parts[1..]; // FIXME inline into pattern. + [s, ref a @ ..] if s.starts_with("v") => { let v_size = size(&s[1..], "v")?; let a = align(a, s)?; if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4fb28db6e94fa..daad2f28fdade 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1834,9 +1834,7 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: &'tcx ty::AdtDef, sp: Span, d ); let mut err = struct_span_err!(tcx.sess, sp, E0731, "transparent enum {}", msg); err.span_label(sp, &msg); - if let &[.., ref end] = &variant_spans[..] { - // FIXME: Ping cfg(bootstrap) -- Use `ref start @ ..` with new bootstrap compiler. - let start = &variant_spans[..variant_spans.len() - 1]; + if let &[ref start @ .., ref end] = &variant_spans[..] { for variant_span in start { err.span_label(*variant_span, ""); } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index ba80d1b70049a..1f48315d3f8db 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -228,7 +228,7 @@ // std is implemented with unstable features, many of which are internal // compiler details that will never be stable // NB: the following list is sorted to minimize merge conflicts. -#![cfg_attr(not(bootstrap), feature(__rust_unstable_column))] +#![feature(__rust_unstable_column)] #![feature(alloc_error_handler)] #![feature(alloc_layout_extra)] #![feature(allocator_api)] @@ -513,7 +513,7 @@ pub use std_detect::detect; // Re-export macros defined in libcore. #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated_in_future)] +#[allow(deprecated, deprecated_in_future)] pub use core::{ // Stable assert_eq, @@ -531,7 +531,6 @@ pub use core::{ }; // Re-export built-in macros defined through libcore. -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use core::{ // Stable diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index 0761c50f4b229..611a1709c8d91 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -8,8 +8,7 @@ #![stable(feature = "raw_os", since = "1.1.0")] -#[cfg_attr(bootstrap, doc(include = "os/raw/char.md"))] -#[cfg_attr(not(bootstrap), doc(include = "char.md"))] +#[doc(include = "char.md")] #[cfg(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "hexagon", @@ -33,8 +32,7 @@ target_arch = "powerpc")), all(target_os = "fuchsia", target_arch = "aarch64")))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; -#[cfg_attr(bootstrap, doc(include = "os/raw/char.md"))] -#[cfg_attr(not(bootstrap), doc(include = "char.md"))] +#[doc(include = "char.md")] #[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "hexagon", @@ -58,51 +56,37 @@ target_arch = "powerpc")), all(target_os = "fuchsia", target_arch = "aarch64"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; -#[cfg_attr(bootstrap, doc(include = "os/raw/schar.md"))] -#[cfg_attr(not(bootstrap), doc(include = "schar.md"))] +#[doc(include = "schar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8; -#[cfg_attr(bootstrap, doc(include = "os/raw/uchar.md"))] -#[cfg_attr(not(bootstrap), doc(include = "uchar.md"))] +#[doc(include = "uchar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8; -#[cfg_attr(bootstrap, doc(include = "os/raw/short.md"))] -#[cfg_attr(not(bootstrap), doc(include = "short.md"))] +#[doc(include = "short.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16; -#[cfg_attr(bootstrap, doc(include = "os/raw/ushort.md"))] -#[cfg_attr(not(bootstrap), doc(include = "ushort.md"))] +#[doc(include = "ushort.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16; -#[cfg_attr(bootstrap, doc(include = "os/raw/int.md"))] -#[cfg_attr(not(bootstrap), doc(include = "int.md"))] +#[doc(include = "int.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32; -#[cfg_attr(bootstrap, doc(include = "os/raw/uint.md"))] -#[cfg_attr(not(bootstrap), doc(include = "uint.md"))] +#[doc(include = "uint.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32; -#[cfg_attr(bootstrap, doc(include = "os/raw/long.md"))] -#[cfg_attr(not(bootstrap), doc(include = "long.md"))] +#[doc(include = "long.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32; -#[cfg_attr(bootstrap, doc(include = "os/raw/ulong.md"))] -#[cfg_attr(not(bootstrap), doc(include = "ulong.md"))] +#[doc(include = "ulong.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32; -#[cfg_attr(bootstrap, doc(include = "os/raw/long.md"))] -#[cfg_attr(not(bootstrap), doc(include = "long.md"))] +#[doc(include = "long.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64; -#[cfg_attr(bootstrap, doc(include = "os/raw/ulong.md"))] -#[cfg_attr(not(bootstrap), doc(include = "ulong.md"))] +#[doc(include = "ulong.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64; -#[cfg_attr(bootstrap, doc(include = "os/raw/longlong.md"))] -#[cfg_attr(not(bootstrap), doc(include = "longlong.md"))] +#[doc(include = "longlong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64; -#[cfg_attr(bootstrap, doc(include = "os/raw/ulonglong.md"))] -#[cfg_attr(not(bootstrap), doc(include = "ulonglong.md"))] +#[doc(include = "ulonglong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64; -#[cfg_attr(bootstrap, doc(include = "os/raw/float.md"))] -#[cfg_attr(not(bootstrap), doc(include = "float.md"))] +#[doc(include = "float.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32; -#[cfg_attr(bootstrap, doc(include = "os/raw/double.md"))] -#[cfg_attr(not(bootstrap), doc(include = "double.md"))] +#[doc(include = "double.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64; #[stable(feature = "raw_os", since = "1.1.0")] diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 1c61f21f7df4e..752c6202ee489 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -7,10 +7,6 @@ #![stable(feature = "rust1", since = "1.0.0")] // Re-exported core operators -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -#[doc(no_inline)] -pub use crate::marker::Copy; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use crate::marker::{Send, Sized, Sync, Unpin}; @@ -24,21 +20,9 @@ pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; pub use crate::mem::drop; // Re-exported types and traits -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -#[doc(no_inline)] -pub use crate::clone::Clone; -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -#[doc(no_inline)] -pub use crate::cmp::{PartialEq, PartialOrd, Eq, Ord}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use crate::convert::{AsRef, AsMut, Into, From}; -#[cfg(bootstrap)] -#[stable(feature = "rust1", since = "1.0.0")] -#[doc(no_inline)] -pub use crate::default::Default; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use crate::iter::{Iterator, Extend, IntoIterator}; @@ -53,7 +37,6 @@ pub use crate::option::Option::{self, Some, None}; pub use crate::result::Result::{self, Ok, Err}; // Re-exported built-in macros -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use core::prelude::v1::{ @@ -83,7 +66,6 @@ pub use core::prelude::v1::{ // FIXME: Attribute and derive macros are not documented because for them rustdoc generates // dead links which fail link checker testing. -#[cfg(not(bootstrap))] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] #[doc(hidden)] diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index e29faf18d83e5..fd6e46fd61dc5 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -163,7 +163,6 @@ pub use self::condvar::{Condvar, WaitTimeoutResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, allow(deprecated_in_future))] #[allow(deprecated)] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index da31a49ddf21f..c1b0dbc0881d3 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -4,13 +4,11 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").expect("TARGET was not set"); - // FIXME: the not(bootstrap) part is needed because of the issue addressed by #62286, - // and could be removed once that change is in beta. - if cfg!(all(not(bootstrap), feature = "llvm-libunwind")) && + if cfg!(feature = "llvm-libunwind") && (target.contains("linux") || target.contains("fuchsia")) { // Build the unwinding from libunwind C/C++ source code. - #[cfg(all(not(bootstrap), feature = "llvm-libunwind"))] + #[cfg(feature = "llvm-libunwind")] llvm_libunwind::compile(); } else if target.contains("linux") { if target.contains("musl") { @@ -46,7 +44,7 @@ fn main() { } } -#[cfg(all(not(bootstrap), feature = "llvm-libunwind"))] +#[cfg(feature = "llvm-libunwind")] mod llvm_libunwind { use std::env; use std::path::Path; diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index aacbfc547d472..7c9eaa51fd94e 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -70,7 +70,7 @@ pub enum _Unwind_Context {} pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); -#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", +#[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { @@ -97,7 +97,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm } pub use _Unwind_Action::*; - #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", + #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { @@ -153,7 +153,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm pub const UNWIND_POINTER_REG: c_int = 12; pub const UNWIND_IP_REG: c_int = 15; - #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", + #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { @@ -218,7 +218,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm cfg_if::cfg_if! { if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { // Not 32-bit iOS - #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", + #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { @@ -230,7 +230,7 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { } } else { // 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace() - #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind", + #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] extern "C" { diff --git a/src/test/ui/lint/lint-qualification.rs b/src/test/ui/lint/lint-qualification.rs index 1b24191a111c2..0cace0ca0355a 100644 --- a/src/test/ui/lint/lint-qualification.rs +++ b/src/test/ui/lint/lint-qualification.rs @@ -1,5 +1,5 @@ #![deny(unused_qualifications)] -#[allow(deprecated)] +#![allow(deprecated)] mod foo { pub fn bar() {} From 5b21f314b46b22daf54d117dda4c1ef03555a77c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 12 Aug 2019 19:42:41 -0400 Subject: [PATCH 30/32] Disable --cfg bootstrap in libcore This is needed to permit us building core_arch which is a submodule dep (so we can't snap it to the new beta compiler). --- src/bootstrap/bin/rustc.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 04a3dea5c8791..1436096dd6e22 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -110,7 +110,11 @@ fn main() { // Non-zero stages must all be treated uniformly to avoid problems when attempting to uplift // compiler libraries and such from stage 1 to 2. - if stage == "0" { + // + // FIXME: the fact that core here is excluded is due to core_arch from our stdarch submodule + // being broken on the beta compiler with bootstrap passed, so this is a temporary workaround + // (we've just snapped, so there are no cfg(bootstrap) related annotations in core). + if stage == "0" && crate_name != Some("core") { cmd.arg("--cfg").arg("bootstrap"); } From 28d2279710c7aed0ff4f1fc5541366d5fc82f8bf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 12 Aug 2019 14:49:12 -0400 Subject: [PATCH 31/32] Update error-format to match new Cargo flags for pipelining --- src/bootstrap/bin/rustc.rs | 12 ------------ src/bootstrap/builder.rs | 3 --- src/bootstrap/compile.rs | 20 ++++++-------------- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 1436096dd6e22..9c01de8aa8251 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -45,18 +45,6 @@ fn main() { } } - // Drop `--error-format json` because despite our desire for json messages - // from Cargo we don't want any from rustc itself. - if let Some(n) = args.iter().position(|n| n == "--error-format") { - args.remove(n); - args.remove(n); - } - - if let Some(s) = env::var_os("RUSTC_ERROR_FORMAT") { - args.push("--error-format".into()); - args.push(s); - } - // Detect whether or not we're a build script depending on whether --target // is passed (a bit janky...) let target = args.windows(2) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 9e4cd5ebca749..8dad5f2ef4632 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -980,9 +980,6 @@ impl<'a> Builder<'a> { if let Some(target_linker) = self.linker(target) { cargo.env("RUSTC_TARGET_LINKER", target_linker); } - if let Some(ref error_format) = self.config.rustc_error_format { - cargo.env("RUSTC_ERROR_FORMAT", error_format); - } if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc { cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler)); } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 4cd793adaf574..4b4b072cc1c96 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1116,10 +1116,6 @@ pub fn run_cargo(builder: &Builder<'_>, }, .. } => (filenames, crate_types), - CargoMessage::CompilerMessage { message } => { - eprintln!("{}", message.rendered); - return; - } _ => return, }; for filename in filenames { @@ -1256,8 +1252,12 @@ pub fn stream_cargo( } // Instruct Cargo to give us json messages on stdout, critically leaving // stderr as piped so we can get those pretty colors. - cargo.arg("--message-format").arg("json") - .stdout(Stdio::piped()); + let mut message_format = String::from("json-render-diagnostics"); + if let Some(s) = &builder.config.rustc_error_format { + message_format.push_str(",json-diagnostic-"); + message_format.push_str(s); + } + cargo.arg("--message-format").arg(message_format).stdout(Stdio::piped()); for arg in tail_args { cargo.arg(arg); @@ -1310,12 +1310,4 @@ pub enum CargoMessage<'a> { BuildScriptExecuted { package_id: Cow<'a, str>, }, - CompilerMessage { - message: ClippyMessage<'a> - } -} - -#[derive(Deserialize)] -pub struct ClippyMessage<'a> { - rendered: Cow<'a, str>, } From 643ddfaaa8e11b2da052681b027b24b2718d4222 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 13 Aug 2019 15:09:11 -0700 Subject: [PATCH 32/32] Apply Centril's suggestion Co-Authored-By: Mazdak Farrokhzad --- src/libsyntax/parse/parser/expr.rs | 2 +- src/test/ui/issues/issue-13483.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 5f04012d7103d..7f6406a89fb5a 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1199,7 +1199,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(kw::Else) || !cond.returns() { let sp = self.sess.source_map().next_point(lo); let mut err = self.diagnostic() - .struct_span_err(sp, "missing condition for `if` statement"); + .struct_span_err(sp, "missing condition for `if` expression"); err.span_label(sp, "expected if condition here"); return Err(err) } diff --git a/src/test/ui/issues/issue-13483.stderr b/src/test/ui/issues/issue-13483.stderr index faaf8690291b7..df9f1dd0115db 100644 --- a/src/test/ui/issues/issue-13483.stderr +++ b/src/test/ui/issues/issue-13483.stderr @@ -1,10 +1,10 @@ -error: missing condition for `if` statement +error: missing condition for `if` expression --> $DIR/issue-13483.rs:3:14 | LL | } else if { | ^ expected if condition here -error: missing condition for `if` statement +error: missing condition for `if` expression --> $DIR/issue-13483.rs:10:14 | LL | } else if {