Skip to content

Commit

Permalink
Explicitly ban async in trait impls
Browse files Browse the repository at this point in the history
This wouldn't compile before because the return type wouldn't match,
but now it's properly an error.
  • Loading branch information
cramertj committed Jun 22, 2018
1 parent d64e577 commit b97ef26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/librustc_passes/ast_validation.rs
Expand Up @@ -265,6 +265,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self.invalid_visibility(&impl_item.vis, None);
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
self.check_trait_fn_not_const(sig.header.constness);
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/did_you_mean/issue-40006.stderr
Expand Up @@ -38,11 +38,11 @@ LL | L = M; //~ ERROR missing
LL | | Z = { 2 + 3 }; //~ ERROR expected one of
| |____^ missing `fn`, `type`, or `const`

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

error: expected one of `!` or `::`, found `(`
--> $DIR/issue-40006.rs:24:9
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/token/issue-41155.stderr
@@ -1,8 +1,8 @@
error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
--> $DIR/issue-41155.rs:13:1
|
LL | pub
| - expected one of 7 possible tokens here
| - expected one of 8 possible tokens here
LL | } //~ ERROR expected one of
| ^ unexpected token

Expand Down

0 comments on commit b97ef26

Please sign in to comment.