Bless tests, fix ICE with ImplTraitPlaceholder

This commit is contained in:
Michael Goulet 2022-09-02 17:54:58 +00:00
parent 70775304cd
commit 1f03edeabe
13 changed files with 255 additions and 202 deletions

View File

@ -1960,8 +1960,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
//
// Then, we will create `fn foo(..) -> Foo<'_, '_>`, and
// hence the elision takes place at the fn site.
let future_bound =
this.lower_async_fn_output_type_to_future_bound(output, fn_def_id, span);
let future_bound = this.lower_async_fn_output_type_to_future_bound(
output,
span,
ImplTraitContext::ReturnPositionOpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
},
);
let generic_params = this.arena.alloc_from_iter(collected_lifetimes.iter().map(
|&(new_node_id, lifetime, _)| {
@ -2064,17 +2069,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn_node_id: NodeId,
opaque_ty_node_id: NodeId,
) -> hir::FnRetTy<'hir> {
let span = output.span();
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::Async, span, None);
let fn_def_id = self.local_def_id(fn_node_id);
let kind = self.lower_impl_trait_in_trait(output.span(), opaque_ty_node_id, |lctx| {
let bound =
lctx.lower_async_fn_output_type_to_future_bound(output, fn_def_id, output.span());
let bound = lctx.lower_async_fn_output_type_to_future_bound(
output,
output.span(),
ImplTraitContext::Disallowed(ImplTraitPosition::TraitReturn),
);
arena_vec![lctx; bound]
});
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::Async, output.span(), None);
let opaque_ty = self.ty(opaque_ty_span, kind);
hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
}
@ -2083,8 +2087,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_async_fn_output_type_to_future_bound(
&mut self,
output: &FnRetTy,
fn_def_id: LocalDefId,
span: Span,
mut nested_impl_trait_context: ImplTraitContext,
) -> hir::GenericBound<'hir> {
// Compute the `T` in `Future<Output = T>` from the return type.
let output_ty = match output {
@ -2092,10 +2096,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
// `impl Future` opaque type that `async fn` implicitly
// generates.
let mut context = ImplTraitContext::ReturnPositionOpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
};
self.lower_ty(ty, &mut context)
self.lower_ty(ty, &mut nested_impl_trait_context)
}
FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
};

View File

@ -4,6 +4,7 @@ use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
use crate::astconv::AstConv;
use crate::rustc_middle::ty::subst::Subst;
use hir::def::DefKind;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
@ -680,9 +681,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.map(|e| e.map_bound(|e| *e).transpose_tuple2())
.find_map(|(p, s)| get_future_output(p.subst(self.tcx, substs), s.0))?,
ty::Error(_) => return None,
ty::Projection(proj)
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
{
self.tcx
.bound_explicit_item_bounds(proj.item_def_id)
.transpose_iter()
.map(|e| e.map_bound(|e| *e).transpose_tuple2())
.find_map(|(p, s)| get_future_output(p.subst(self.tcx, proj.substs), s.0))?
}
_ => span_bug!(
self.tcx.def_span(expr_def_id),
"async fn generator return type not an inference variable"
"async fn generator return type not an inference variable: {ret_ty}"
),
};

View File

@ -1,8 +1,11 @@
// edition:2018
trait T {
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`
//~^ ERROR mismatched types
async fn bar(&self) {} //~ ERROR functions in traits cannot be declared `async`
//~^ ERROR mismatched types
async fn baz() { //~ ERROR functions in traits cannot be declared `async`
//~^ ERROR mismatched types
// Nested item must not ICE.
fn a() {}
}

View File

@ -2,40 +2,89 @@ error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:3:5
|
LL | async fn foo() {}
| -----^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:4:5
|
LL | async fn bar(&self) {}
| -----^^^^^^^^^^^^^^^^^
| -----^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:5:5
|
LL | async fn baz() {
| ^----
| |
| _____`async` because of this
| |
LL | | // Nested item must not ICE.
LL | | fn a() {}
LL | | }
| |_____^
LL | async fn bar(&self) {}
| -----^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error: aborting due to 3 previous errors
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:7:5
|
LL | async fn baz() {
| -----^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0706`.
error[E0308]: mismatched types
--> $DIR/async-trait-fn.rs:3:20
|
LL | async fn foo() {}
| ^^ expected associated type, found opaque type
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as T>::foo::{opaque#0}`
found opaque type `impl Future<Output = ()>`
error[E0308]: mismatched types
--> $DIR/async-trait-fn.rs:5:25
|
LL | async fn bar(&self) {}
| ^^ expected associated type, found opaque type
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as T>::bar::{opaque#0}`
found opaque type `impl Future<Output = ()>`
error[E0308]: mismatched types
--> $DIR/async-trait-fn.rs:7:20
|
LL | async fn baz() {
| ____________________^
LL | |
LL | | // Nested item must not ICE.
LL | | fn a() {}
LL | | }
| |_____^ expected associated type, found opaque type
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as T>::baz::{opaque#0}`
found opaque type `impl Future<Output = ()>`
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0308, E0706.
For more information about an error, try `rustc --explain E0308`.

View File

@ -16,7 +16,8 @@ impl Foo {
trait Bar {
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
//~^ ERROR functions in traits cannot be declared `async`
//~^ ERROR functions in traits cannot be declared `async`
//~| ERROR mismatched types
}
fn main() {

View File

@ -53,7 +53,7 @@ LL | async fn foo() {}
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
--> $DIR/edition-deny-async-fns-2015.rs:36:9
--> $DIR/edition-deny-async-fns-2015.rs:37:9
|
LL | async fn bar() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@ -62,7 +62,7 @@ LL | async fn bar() {}
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
--> $DIR/edition-deny-async-fns-2015.rs:26:9
--> $DIR/edition-deny-async-fns-2015.rs:27:9
|
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@ -71,7 +71,7 @@ LL | async fn foo() {}
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
--> $DIR/edition-deny-async-fns-2015.rs:31:13
--> $DIR/edition-deny-async-fns-2015.rs:32:13
|
LL | async fn bar() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@ -83,14 +83,30 @@ error[E0706]: functions in traits cannot be declared `async`
--> $DIR/edition-deny-async-fns-2015.rs:18:5
|
LL | async fn foo() {}
| -----^^^^^^^^^^^^
| -----^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error: aborting due to 10 previous errors
error[E0308]: mismatched types
--> $DIR/edition-deny-async-fns-2015.rs:18:20
|
LL | async fn foo() {}
| ^^ expected associated type, found opaque type
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as Bar>::foo::{opaque#0}`
found opaque type `impl Future<Output = ()>`
Some errors have detailed explanations: E0670, E0706.
For more information about an error, try `rustc --explain E0670`.
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0308, E0670, E0706.
For more information about an error, try `rustc --explain E0308`.

View File

@ -8,6 +8,8 @@ LL | async fn new() -> [u8; _];
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error: in expressions, `_` can only be used on the left-hand side of an assignment
--> $DIR/issue-95307.rs:7:28

View File

@ -27,7 +27,6 @@ fn main() {
struct Y;
impl X for Y {
async fn ft1() {} //~ ERROR functions in traits cannot be declared `async`
//~^ ERROR has an incompatible type for trait
unsafe fn ft2() {} // OK.
const fn ft3() {} //~ ERROR functions in traits cannot be declared const
extern "C" fn ft4() {}
@ -36,7 +35,6 @@ fn main() {
//~| ERROR functions in traits cannot be declared const
//~| ERROR functions cannot be both `const` and `async`
//~| ERROR cycle detected
//~| ERROR has an incompatible type for trait
}
impl Y {

View File

@ -7,17 +7,6 @@ LL | const async unsafe extern "C" fn ff5() {}
| | `async` because of this
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:17:9
|
LL | async fn ft1();
| -----^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:19:9
|
@ -30,17 +19,6 @@ error[E0379]: functions in traits cannot be declared const
LL | const async unsafe extern "C" fn ft5();
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:21:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:21:9
|
@ -50,42 +28,20 @@ LL | const async unsafe extern "C" fn ft5();
| | `async` because of this
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:29:9
|
LL | async fn ft1() {}
| -----^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:32:9
--> $DIR/fn-header-semantic-fail.rs:31:9
|
LL | const fn ft3() {}
| ^^^^^ functions in traits cannot be const
error[E0379]: functions in traits cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^ functions in traits cannot be const
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:34:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^-^^^^^------------------------------
@ -94,7 +50,7 @@ LL | const async unsafe extern "C" fn ft5() {}
| `const` because of this
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:47:9
--> $DIR/fn-header-semantic-fail.rs:45:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^-^^^^^------------------------------
@ -103,7 +59,7 @@ LL | const async unsafe extern "C" fn fi5() {}
| `const` because of this
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:53:18
--> $DIR/fn-header-semantic-fail.rs:51:18
|
LL | extern "C" {
| ---------- in this `extern` block
@ -116,7 +72,7 @@ LL | fn fe1();
| ~~
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:54:19
--> $DIR/fn-header-semantic-fail.rs:52:19
|
LL | extern "C" {
| ---------- in this `extern` block
@ -130,7 +86,7 @@ LL | fn fe2();
| ~~
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:55:18
--> $DIR/fn-header-semantic-fail.rs:53:18
|
LL | extern "C" {
| ---------- in this `extern` block
@ -144,7 +100,7 @@ LL | fn fe3();
| ~~
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:56:23
--> $DIR/fn-header-semantic-fail.rs:54:23
|
LL | extern "C" {
| ---------- in this `extern` block
@ -158,7 +114,7 @@ LL | fn fe4();
| ~~
error: functions in `extern` blocks cannot have qualifiers
--> $DIR/fn-header-semantic-fail.rs:57:42
--> $DIR/fn-header-semantic-fail.rs:55:42
|
LL | extern "C" {
| ---------- in this `extern` block
@ -172,7 +128,7 @@ LL | fn fe5();
| ~~
error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:57:9
--> $DIR/fn-header-semantic-fail.rs:55:9
|
LL | const async unsafe extern "C" fn fe5();
| ^^^^^-^^^^^----------------------------
@ -180,6 +136,58 @@ LL | const async unsafe extern "C" fn fe5();
| | `async` because of this
| `const` because of this
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:17:9
|
LL | async fn ft1();
| -----^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:21:9
|
LL | const async unsafe extern "C" fn ft5();
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:29:9
|
LL | async fn ft1() {}
| -----^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}`
--> $DIR/fn-header-semantic-fail.rs:12:44
|
@ -216,60 +224,24 @@ LL | | }
LL | | }
| |_^
error[E0053]: method `ft1` has an incompatible type for trait
--> $DIR/fn-header-semantic-fail.rs:29:24
|
LL | async fn ft1() {}
| ^
| |
| checked the `Output` of this `async fn`, found opaque type
| expected `()`, found opaque type
|
= note: while checking the return type of the `async fn`
note: type in trait
--> $DIR/fn-header-semantic-fail.rs:17:23
|
LL | async fn ft1();
| ^
= note: expected fn pointer `fn()`
found fn pointer `fn() -> impl Future<Output = ()>`
error[E0053]: method `ft5` has an incompatible type for trait
--> $DIR/fn-header-semantic-fail.rs:34:48
|
LL | const async unsafe extern "C" fn ft5() {}
| ^
| |
| checked the `Output` of this `async fn`, found opaque type
| expected `()`, found opaque type
|
= note: while checking the return type of the `async fn`
note: type in trait
--> $DIR/fn-header-semantic-fail.rs:21:47
|
LL | const async unsafe extern "C" fn ft5();
| ^
= note: expected fn pointer `unsafe extern "C" fn()`
found fn pointer `unsafe extern "C" fn() -> impl Future<Output = ()>`
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}`
--> $DIR/fn-header-semantic-fail.rs:34:48
--> $DIR/fn-header-semantic-fail.rs:33:48
|
LL | const async unsafe extern "C" fn ft5() {}
| ^
|
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`...
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`...
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`...
--> $DIR/fn-header-semantic-fail.rs:34:9
--> $DIR/fn-header-semantic-fail.rs:33:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -288,30 +260,30 @@ LL | | }
LL | | }
| |_^
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 42:11>::fi5::{opaque#0}`
--> $DIR/fn-header-semantic-fail.rs:47:48
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}`
--> $DIR/fn-header-semantic-fail.rs:45:48
|
LL | const async unsafe extern "C" fn fi5() {}
| ^
|
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 42:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:47:9
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:45:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 42:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:47:9
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:45:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 42:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:47:9
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`...
--> $DIR/fn-header-semantic-fail.rs:45:9
|
LL | const async unsafe extern "C" fn fi5() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze...
= note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`...
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 42:11>::fi5::{opaque#0}`, completing the cycle
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/fn-header-semantic-fail.rs:5:1
|
@ -324,7 +296,7 @@ LL | | }
LL | | }
| |_^
error: aborting due to 23 previous errors
error: aborting due to 21 previous errors
Some errors have detailed explanations: E0053, E0379, E0391, E0706.
For more information about an error, try `rustc --explain E0053`.
Some errors have detailed explanations: E0379, E0391, E0706.
For more information about an error, try `rustc --explain E0379`.

View File

@ -14,7 +14,6 @@ trait B {
impl B for A {
async fn associated(); //~ ERROR without body
//~^ ERROR cannot be declared `async`
//~| ERROR has an incompatible type for trait
}
fn main() {}

View File

@ -14,6 +14,14 @@ LL | async fn inherent();
| |
| help: provide a definition for the function: `{ <body> }`
error: associated function in `impl` without body
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
|
LL | async fn associated();
| ^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:5
|
@ -24,14 +32,8 @@ LL | async fn associated();
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: associated function in `impl` without body
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
|
LL | async fn associated();
| ^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
@ -43,26 +45,9 @@ LL | async fn associated();
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0053]: method `associated` has an incompatible type for trait
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:26
|
LL | async fn associated();
| ^
| |
| checked the `Output` of this `async fn`, found opaque type
| expected `()`, found opaque type
|
= note: while checking the return type of the `async fn`
note: type in trait
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:26
|
LL | async fn associated();
| ^
= note: expected fn pointer `fn()`
found fn pointer `fn() -> impl Future<Output = ()>`
error: aborting due to 5 previous errors
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0053, E0706.
For more information about an error, try `rustc --explain E0053`.
For more information about this error, try `rustc --explain E0706`.

View File

@ -12,7 +12,8 @@ impl A {
trait C{async fn new(val: T) {} //~ ERROR `async fn` is not permitted in Rust 2015
//~^ ERROR functions in traits cannot be declared `async`
//~^^ ERROR cannot find type `T` in this scope
//~^^^ WARN changes to closure capture in Rust 2021 will affect drop order [rust_2021_incompatible_closure_captures]
//~| ERROR mismatched types
//~| ERROR cannot find type `T` in this scope
//~| WARN changes to closure capture in Rust 2021 will affect drop order [rust_2021_incompatible_closure_captures]
//~ ERROR this file contains an unclosed delimiter

View File

@ -1,5 +1,5 @@
error: this file contains an unclosed delimiter
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:18:53
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:19:53
|
LL | trait C{async fn new(val: T) {}
| - unclosed delimiter
@ -25,17 +25,6 @@ LL | trait C{async fn new(val: T) {}
= help: pass `--edition 2021` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:9
|
LL | trait C{async fn new(val: T) {}
| -----^^^^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0423]: expected function, found module `crate`
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:9:5
|
@ -51,6 +40,19 @@ LL | pub struct A {}
LL | trait C{async fn new(val: T) {}
| ^ help: a struct with a similar name exists: `A`
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:9
|
LL | trait C{async fn new(val: T) {}
| -----^^^^^^^^^^^^^^^
| |
| `async` because of this
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
warning: changes to closure capture in Rust 2021 will affect drop order
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:57
|
@ -72,6 +74,20 @@ help: add a dummy let to cause `path` to be fully captured
LL | async fn create(path: impl AsRef<std::path::Path>) { let _ = &path;
| ++++++++++++++
error[E0308]: mismatched types
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:30
|
LL | trait C{async fn new(val: T) {}
| ^^ expected associated type, found opaque type
|
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as C>::new::{opaque#0}`
found opaque type `impl Future<Output = ()>`
warning: changes to closure capture in Rust 2021 will affect drop order
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:13:30
|
@ -87,7 +103,7 @@ help: add a dummy let to cause `val` to be fully captured
LL | trait C{async fn new(val: T) { let _ = &val;}
| +++++++++++++
error: aborting due to 6 previous errors; 2 warnings emitted
error: aborting due to 7 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0412, E0423, E0670, E0706.
For more information about an error, try `rustc --explain E0412`.
Some errors have detailed explanations: E0308, E0412, E0423, E0670, E0706.
For more information about an error, try `rustc --explain E0308`.