From 008d90a66a30bc8ff498f8ad47dea315c1853a75 Mon Sep 17 00:00:00 2001 From: csmoe Date: Sat, 16 May 2020 16:01:59 +0800 Subject: create error code E0754 --- src/librustc_error_codes/error_codes.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/librustc_error_codes/error_codes.rs') 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 @@ E0750: include_str!("./error_codes/E0750.md"), 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 -- cgit 1.4.1-3-g733a5 From 8841ede3648b5f12284dae850ec065374fd3af46 Mon Sep 17 00:00:00 2001 From: csmoe Date: Sat, 16 May 2020 17:10:08 +0800 Subject: bless suggestion on spell out --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0754.md | 29 -------------------- src/librustc_error_codes/error_codes/E0755.md | 32 ++++++++++++++++++++++ src/librustc_typeck/check/mod.rs | 2 +- .../issue-61949-self-return-type.stderr | 5 ++-- src/test/ui/async-await/issue-69276.stderr | 8 ------ .../ui/impl-trait/bound-normalization-fail.stderr | 5 ++-- 7 files changed, 40 insertions(+), 43 deletions(-) delete mode 100644 src/librustc_error_codes/error_codes/E0754.md create mode 100644 src/librustc_error_codes/error_codes/E0755.md delete mode 100644 src/test/ui/async-await/issue-69276.stderr (limited to 'src/librustc_error_codes/error_codes.rs') diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 52d40fd0f2f..6467561e509 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -435,7 +435,7 @@ E0750: include_str!("./error_codes/E0750.md"), 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"), +E0755: include_str!("./error_codes/E0755.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 deleted file mode 100644 index e7cea982010..00000000000 --- a/src/librustc_error_codes/error_codes/E0754.md +++ /dev/null @@ -1,29 +0,0 @@ -`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 diff --git a/src/librustc_error_codes/error_codes/E0755.md b/src/librustc_error_codes/error_codes/E0755.md new file mode 100644 index 00000000000..b6eb2e34ccf --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0755.md @@ -0,0 +1,32 @@ +`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 diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0906c25baef..bd8f628957d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1701,7 +1701,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId, let mut err = struct_span_err!( tcx.sess, span, - E0754, + E0755, "`{}` return type cannot contain a projection or `Self` that references lifetimes from \ a parent scope", if is_async { "async fn" } else { "impl Trait" }, 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 index 12fb77d8dd6..fe05754c83f 100644 --- a/src/test/ui/async-await/issue-61949-self-return-type.stderr +++ b/src/test/ui/async-await/issue-61949-self-return-type.stderr @@ -1,8 +1,9 @@ -error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0755]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/issue-61949-self-return-type.rs:11:40 | LL | pub async fn new(_bar: &'a i32) -> Self { - | ^^^^ + | ^^^^ help: consider spelling out the type instead: `Foo<'a>` error: aborting due to previous error +For more information about this error, try `rustc --explain E0754`. diff --git a/src/test/ui/async-await/issue-69276.stderr b/src/test/ui/async-await/issue-69276.stderr deleted file mode 100644 index 1ebfdfa8b54..00000000000 --- a/src/test/ui/async-await/issue-69276.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/issue-69276.rs:6:33 - | -LL | async fn new(i: &'a i32) -> Self { - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index f5092044627..04b398f5b52 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -20,7 +20,7 @@ help: consider constraining the associated type `::Assoc LL | fn foo_fail>() -> impl FooLike { | ^^^^^^^^^^^^ -error: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0755]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/bound-normalization-fail.rs:43:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { @@ -42,4 +42,5 @@ LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike Date: Fri, 22 May 2020 12:14:53 +0800 Subject: resolve error code e0760 --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0755.md | 32 ---------------------- src/librustc_error_codes/error_codes/E0760.md | 32 ++++++++++++++++++++++ src/librustc_typeck/check/mod.rs | 2 +- .../issue-61949-self-return-type.stderr | 4 +-- .../ui/impl-trait/bound-normalization-fail.stderr | 4 +-- 6 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 src/librustc_error_codes/error_codes/E0755.md create mode 100644 src/librustc_error_codes/error_codes/E0760.md (limited to 'src/librustc_error_codes/error_codes.rs') diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index c0b16c22e4d..97f0c16b4cf 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -437,7 +437,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"), -E0755: include_str!("./error_codes/E0755.md"), +E0760: include_str!("./error_codes/E0760.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0755.md b/src/librustc_error_codes/error_codes/E0755.md deleted file mode 100644 index 0c289146176..00000000000 --- a/src/librustc_error_codes/error_codes/E0755.md +++ /dev/null @@ -1,32 +0,0 @@ -`async fn`/`impl trait` return type cannot contain a projection -or `Self` that references lifetimes from a parent scope. - -Erroneous code example: - -```compile_fail,E0755,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 diff --git a/src/librustc_error_codes/error_codes/E0760.md b/src/librustc_error_codes/error_codes/E0760.md new file mode 100644 index 00000000000..e1dcfefebcd --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0760.md @@ -0,0 +1,32 @@ +`async fn`/`impl trait` return type cannot contain a projection +or `Self` that references lifetimes from a parent scope. + +Erroneous code example: + +```compile_fail,E0760,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 diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 200263728d9..4646e703496 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1690,7 +1690,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId, let mut err = struct_span_err!( tcx.sess, span, - E0755, + E0760, "`{}` return type cannot contain a projection or `Self` that references lifetimes from \ a parent scope", if is_async { "async fn" } else { "impl Trait" }, 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 index f57e097c125..4eeef871c5b 100644 --- a/src/test/ui/async-await/issue-61949-self-return-type.stderr +++ b/src/test/ui/async-await/issue-61949-self-return-type.stderr @@ -1,4 +1,4 @@ -error[E0755]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/issue-61949-self-return-type.rs:11:40 | LL | pub async fn new(_bar: &'a i32) -> Self { @@ -6,4 +6,4 @@ LL | pub async fn new(_bar: &'a i32) -> Self { error: aborting due to previous error -For more information about this error, try `rustc --explain E0755`. +For more information about this error, try `rustc --explain E0760`. diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index c78d4c4a8fd..03aba10cc79 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -21,7 +21,7 @@ help: consider constraining the associated type `::Assoc LL | fn foo_fail>() -> impl FooLike { | ^^^^^^^^^^^^ -error[E0755]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope +error[E0760]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope --> $DIR/bound-normalization-fail.rs:43:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { @@ -43,5 +43,5 @@ LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike