Rollup merge of #100734 - ComputerDruid:afit_feature, r=compiler-errors
Split out async_fn_in_trait into a separate feature PR #101224 added support for async fn in trait desuraging behind the `return_position_impl_trait_in_trait` feature. Split this out so that it's behind its own feature gate, since async fn in trait doesn't need to follow the same stabilization schedule.
This commit is contained in:
commit
5d7937de8c
13 changed files with 133 additions and 19 deletions
|
@ -332,6 +332,15 @@ impl FnDeclKind {
|
|||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn async_fn_allowed(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
match self {
|
||||
FnDeclKind::Fn | FnDeclKind::Inherent => true,
|
||||
FnDeclKind::Impl if tcx.features().async_fn_in_trait => true,
|
||||
FnDeclKind::Trait if tcx.features().async_fn_in_trait => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -1692,14 +1701,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}));
|
||||
|
||||
let output = if let Some((ret_id, span)) = make_ret_async {
|
||||
if !kind.impl_trait_allowed(self.tcx) {
|
||||
if !kind.async_fn_allowed(self.tcx) {
|
||||
match kind {
|
||||
FnDeclKind::Trait | FnDeclKind::Impl => {
|
||||
self.tcx
|
||||
.sess
|
||||
.create_feature_err(
|
||||
TraitFnAsync { fn_span, span },
|
||||
sym::return_position_impl_trait_in_trait,
|
||||
sym::async_fn_in_trait,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
@ -1917,9 +1926,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
let future_bound = this.lower_async_fn_output_type_to_future_bound(
|
||||
output,
|
||||
span,
|
||||
ImplTraitContext::ReturnPositionOpaqueTy {
|
||||
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
|
||||
in_trait,
|
||||
if in_trait && !this.tcx.features().return_position_impl_trait_in_trait {
|
||||
ImplTraitContext::Disallowed(ImplTraitPosition::TraitReturn)
|
||||
} else {
|
||||
ImplTraitContext::ReturnPositionOpaqueTy {
|
||||
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
|
||||
in_trait,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -312,6 +312,8 @@ declare_features! (
|
|||
(active, associated_type_defaults, "1.2.0", Some(29661), None),
|
||||
/// Allows `async || body` closures.
|
||||
(active, async_closure, "1.37.0", Some(62290), None),
|
||||
/// Alows async functions to be declared, implemented, and used in traits.
|
||||
(incomplete, async_fn_in_trait, "CURRENT_RUSTC_VERSION", Some(91611), None),
|
||||
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
|
||||
(active, c_unwind, "1.52.0", Some(74990), None),
|
||||
/// Allows using C-variadics.
|
||||
|
|
|
@ -396,6 +396,7 @@ symbols! {
|
|||
assume_init,
|
||||
async_await,
|
||||
async_closure,
|
||||
async_fn_in_trait,
|
||||
atomic,
|
||||
atomic_mod,
|
||||
atomics,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue