From 008d90a66a30bc8ff498f8ad47dea315c1853a75 Mon Sep 17 00:00:00 2001 From: csmoe Date: Sat, 16 May 2020 16:01:59 +0800 Subject: [PATCH] create error code E0754 --- src/librustc_error_codes/error_codes.rs | 1 + src/librustc_error_codes/error_codes/E0754.md | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/librustc_error_codes/error_codes/E0754.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index e01412bc21c..52d40fd0f2f 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -435,6 +435,7 @@ E0751: include_str!("./error_codes/E0751.md"), E0752: include_str!("./error_codes/E0752.md"), E0753: include_str!("./error_codes/E0753.md"), +E0754: include_str!("./error_codes/E0754.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0754.md b/src/librustc_error_codes/error_codes/E0754.md new file mode 100644 index 00000000000..e7cea982010 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0754.md @@ -0,0 +1,29 @@ +`async fn`/`impl trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope. + +Erroneous code example: + +```compile_fail,E0754,edition2018 +struct S<'a>(&'a i32); + +impl<'a> S<'a> { + async fn new(i: &'a i32) -> Self { + S(&22) + } +} +``` + +To fix this error we need to spell out `Self` to `S<'a>`: + +```edition2018 +struct S<'a>(&'a i32); + +impl<'a> S<'a> { + async fn new(i: &'a i32) -> S<'a> { + S(&22) + } +} +``` + +This will be allowed at some point in the future, but the implementation is not yet complete. See the [issue-61949] for this limitation. + +[issue-61949]: https://github.com/rust-lang/rust/issues/61949 -- 2.44.0