Skip to content

Commit b97ef26

Browse files
committed
Explicitly ban async in trait impls
This wouldn't compile before because the return type wouldn't match, but now it's properly an error.
1 parent d64e577 commit b97ef26

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/librustc_passes/ast_validation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
265265
self.invalid_visibility(&impl_item.vis, None);
266266
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
267267
self.check_trait_fn_not_const(sig.header.constness);
268+
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness);
268269
}
269270
}
270271
}

src/test/ui/did_you_mean/issue-40006.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ LL | L = M; //~ ERROR missing
3838
LL | | Z = { 2 + 3 }; //~ ERROR expected one of
3939
| |____^ missing `fn`, `type`, or `const`
4040

41-
error: expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;`
41+
error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;`
4242
--> $DIR/issue-40006.rs:23:18
4343
|
4444
LL | Z = { 2 + 3 }; //~ ERROR expected one of
45-
| ^ expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}` here
45+
| ^ expected one of 7 possible tokens here
4646

4747
error: expected one of `!` or `::`, found `(`
4848
--> $DIR/issue-40006.rs:24:9

src/test/ui/token/issue-41155.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
1+
error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
22
--> $DIR/issue-41155.rs:13:1
33
|
44
LL | pub
5-
| - expected one of 7 possible tokens here
5+
| - expected one of 8 possible tokens here
66
LL | } //~ ERROR expected one of
77
| ^ unexpected token
88

0 commit comments

Comments
 (0)