Skip to content

Commit 1fcb7ed

Browse files
committed
Fix error message when trait method ends with wrong token
When parsing a trait function, the function must end with either `;` or `{` (signifying a default implementation). The error message incorrectly stated that it must be `;` or `}`. Fixes #6610.
1 parent fc3297f commit 1fcb7ed

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl Parser {
953953
_ => {
954954
p.fatal(
955955
fmt!(
956-
"expected `;` or `}` but found `%s`",
956+
"expected `;` or `{` but found `%s`",
957957
self.this_token_to_str()
958958
)
959959
);

src/test/compile-fail/issue-6610.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo { fn a() } //~ ERROR expected `;` or `{` but found `}`
12+
13+
fn main() {}

0 commit comments

Comments
 (0)