Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6534,8 +6534,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();
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/traits/trait-alias-syntax.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(trait_alias)]

trait Foo {}
auto trait A = Foo; //~ ERROR trait aliases cannot be `auto`
unsafe trait B = Foo; //~ ERROR trait aliases cannot be `unsafe`

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/traits/trait-alias-syntax.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: trait aliases cannot be `auto`
--> $DIR/trait-alias-syntax.rs:4:19
|
LL | auto trait A = Foo; //~ ERROR trait aliases cannot be `auto`
| ^ trait aliases cannot be `auto`

error: trait aliases cannot be `unsafe`
--> $DIR/trait-alias-syntax.rs:5:21
|
LL | unsafe trait B = Foo; //~ ERROR trait aliases cannot be `unsafe`
| ^ trait aliases cannot be `unsafe`

error: aborting due to 2 previous errors