From b97ef26de1248848e5c70e994d45c8285f62b343 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Tue, 19 Jun 2018 10:35:05 -0700 Subject: [PATCH] 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. --- src/librustc_passes/ast_validation.rs | 1 + src/test/ui/did_you_mean/issue-40006.stderr | 4 ++-- src/test/ui/token/issue-41155.stderr | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 7cdcdf4f0d10..25187032fb47 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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); } } } diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr index a3433939573a..d3ce2cf12f29 100644 --- a/src/test/ui/did_you_mean/issue-40006.stderr +++ b/src/test/ui/did_you_mean/issue-40006.stderr @@ -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 diff --git a/src/test/ui/token/issue-41155.stderr b/src/test/ui/token/issue-41155.stderr index b56b95a8aafd..84dbc7ffc2f8 100644 --- a/src/test/ui/token/issue-41155.stderr +++ b/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