Skip to content

Commit ef04c97

Browse files
Deprecate E0706
1 parent 59315b8 commit ef04c97

File tree

4 files changed

+6
-32
lines changed

4 files changed

+6
-32
lines changed

compiler/rustc_ast_lowering/messages.ftl

-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ ast_lowering_template_modifier = template modifier
136136
137137
ast_lowering_this_not_async = this is not `async`
138138
139-
ast_lowering_trait_fn_async =
140-
functions in traits cannot be declared `async`
141-
.label = `async` because of this
142-
.note = `async` trait functions are not currently supported
143-
.note2 = consider using the `async-trait` crate: https://crates.io/crates/async-trait
144-
145139
ast_lowering_underscore_expr_lhs_assign =
146140
in expressions, `_` can only be used on the left-hand side of an assignment
147141
.label = `_` not allowed here

compiler/rustc_ast_lowering/src/errors.rs

-11
Original file line numberDiff line numberDiff line change
@@ -354,17 +354,6 @@ pub struct InclusiveRangeWithNoEnd {
354354
pub span: Span,
355355
}
356356

357-
#[derive(Diagnostic, Clone, Copy)]
358-
#[diag(ast_lowering_trait_fn_async, code = "E0706")]
359-
#[note]
360-
#[note(ast_lowering_note2)]
361-
pub struct TraitFnAsync {
362-
#[primary_span]
363-
pub fn_span: Span,
364-
#[label]
365-
pub span: Span,
366-
}
367-
368357
#[derive(Diagnostic)]
369358
pub enum BadReturnTypeNotation {
370359
#[diag(ast_lowering_bad_return_type_notation_inputs)]

compiler/rustc_ast_lowering/src/lib.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#[macro_use]
4141
extern crate tracing;
4242

43-
use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait, TraitFnAsync};
43+
use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
4444

4545
use rustc_ast::ptr::P;
4646
use rustc_ast::visit;
@@ -336,13 +336,6 @@ impl FnDeclKind {
336336
_ => false,
337337
}
338338
}
339-
340-
fn async_fn_allowed(&self) -> bool {
341-
match self {
342-
FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => true,
343-
_ => false,
344-
}
345-
}
346339
}
347340

348341
#[derive(Copy, Clone)]
@@ -1797,11 +1790,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17971790
self.lower_ty_direct(&param.ty, &itctx)
17981791
}));
17991792

1800-
let output = if let Some((ret_id, span)) = make_ret_async {
1801-
if !kind.async_fn_allowed() {
1802-
self.tcx.sess.emit_err(TraitFnAsync { fn_span, span });
1803-
}
1804-
1793+
let output = if let Some((ret_id, _span)) = make_ret_async {
18051794
let fn_def_id = self.local_def_id(fn_node_id);
18061795
self.lower_async_fn_ret_ty(&decl.output, fn_def_id, ret_id, kind, fn_span)
18071796
} else {

compiler/rustc_error_codes/src/error_codes/E0706.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
`async fn`s are not yet supported in traits in Rust.
24

35
Erroneous code example:
46

5-
```compile_fail,edition2018
7+
```ignore,edition2018
68
trait T {
79
// Neither case is currently supported.
810
async fn foo() {}
@@ -13,7 +15,7 @@ trait T {
1315
`async fn`s return an `impl Future`, making the following two examples
1416
equivalent:
1517

16-
```edition2018,ignore (example-of-desugaring-equivalence)
18+
```ignore,edition2018 (example-of-desugaring-equivalence)
1719
async fn foo() -> User {
1820
unimplemented!()
1921
}

0 commit comments

Comments
 (0)