1
Fork 0

Rollup merge of #58387 - alexreg:fix-trait-alias-2, r=centril

Disallow `auto` trait alias syntax

See https://github.com/rust-lang/rust/issues/41517#issuecomment-462567679.

r? @Centril

CC @topecongiro @nikomatsakis
This commit is contained in:
Mazdak Farrokhzad 2019-02-13 04:37:07 +01:00 committed by GitHub
commit a5e869eb62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View file

@ -6538,8 +6538,14 @@ impl<'a> Parser<'a> {
let bounds = self.parse_generic_bounds()?;
tps.where_clause = self.parse_where_clause()?;
self.expect(&token::Semi)?;
if is_auto == IsAuto::Yes {
let msg = "trait aliases cannot be `auto`";
self.struct_span_err(self.prev_span, msg)
.span_label(self.prev_span, msg)
.emit();
}
if unsafety != Unsafety::Normal {
let msg = "trait aliases cannot be unsafe";
let msg = "trait aliases cannot be `unsafe`";
self.struct_span_err(self.prev_span, msg)
.span_label(self.prev_span, msg)
.emit();