Rollup merge of #60388 - cramertj:elided-lifetime-async, r=nikomatsakis
Disallow non-explicit elided lifetimes in async fn Fix https://github.com/rust-lang/rust/issues/60203 r? @nikomatsakis
This commit is contained in:
commit
3ca0d36538
11 changed files with 150 additions and 65 deletions
16
src/test/ui/async-fn-path-elision.rs
Normal file
16
src/test/ui/async-fn-path-elision.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// edition:2018
|
||||
|
||||
#![feature(async_await, await_macro)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct HasLifetime<'a>(&'a bool);
|
||||
|
||||
async fn error(lt: HasLifetime) { //~ ERROR implicit elided lifetime not allowed here
|
||||
if *lt.0 {}
|
||||
}
|
||||
|
||||
fn no_error(lt: HasLifetime) {
|
||||
if *lt.0 {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
8
src/test/ui/async-fn-path-elision.stderr
Normal file
8
src/test/ui/async-fn-path-elision.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/async-fn-path-elision.rs:8:20
|
||||
|
|
||||
LL | async fn error(lt: HasLifetime) {
|
||||
| ^^^^^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ trait MyTrait { }
|
|||
struct Foo<'a> { x: &'a u32 }
|
||||
|
||||
impl MyTrait for Foo {
|
||||
//~^ ERROR missing lifetime specifier
|
||||
//~^ ERROR implicit elided lifetime not allowed here
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/path-elided.rs:7:18
|
||||
|
|
||||
LL | impl MyTrait for Foo {
|
||||
| ^^^ expected lifetime parameter
|
||||
| ^^^- help: indicate the anonymous lifetime: `<'_>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
trait MyTrait<'a> { }
|
||||
|
||||
impl MyTrait for u32 {
|
||||
//~^ ERROR missing lifetime specifier
|
||||
//~^ ERROR implicit elided lifetime not allowed here
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/trait-elided.rs:5:6
|
||||
|
|
||||
LL | impl MyTrait for u32 {
|
||||
| ^^^^^^^ expected lifetime parameter
|
||||
| ^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
|
|||
|
||||
impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
|
||||
//~^ ERROR lifetimes cannot use keyword names
|
||||
//~| ERROR missing lifetime specifier
|
||||
//~| ERROR implicit elided lifetime not allowed here
|
||||
//~| ERROR the size for values of type `str` cannot be known at compilation time
|
||||
fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR lifetimes cannot use keyword names
|
||||
vec![1]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,23 +29,32 @@ LL | impl<'self> Serializable<str> for &'self str {
|
|||
| ^^^^^
|
||||
|
||||
error: lifetimes cannot use keyword names
|
||||
--> $DIR/issue-10412.rs:9:25
|
||||
--> $DIR/issue-10412.rs:10:25
|
||||
|
|
||||
LL | fn serialize(val : &'self str) -> Vec<u8> {
|
||||
| ^^^^^
|
||||
|
||||
error: lifetimes cannot use keyword names
|
||||
--> $DIR/issue-10412.rs:12:37
|
||||
--> $DIR/issue-10412.rs:13:37
|
||||
|
|
||||
LL | fn deserialize(repr: &[u8]) -> &'self str {
|
||||
| ^^^^^
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/issue-10412.rs:6:13
|
||||
|
|
||||
LL | impl<'self> Serializable<str> for &'self str {
|
||||
| ^^^^^^^^^^^^^^^^^ expected lifetime parameter
|
||||
| ^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Serializable<'_, str>`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/issue-10412.rs:6:13
|
||||
|
|
||||
LL | impl<'self> Serializable<str> for &'self str {
|
||||
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `str`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue