Emit error for pattern arguments in trait methods
The error and check for this already existed, but the parser didn't try to parse trait method arguments as patterns, so the error was never emitted. This surfaces the error, so we get better errors than simple parse errors.
This commit is contained in:
parent
a77dfcc79f
commit
90a6954327
5 changed files with 71 additions and 21 deletions
15
src/test/ui/E0642.rs
Normal file
15
src/test/ui/E0642.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
9
src/test/ui/E0642.stderr
Normal file
9
src/test/ui/E0642.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0642]: patterns aren't allowed in methods without bodies
|
||||
--> $DIR/E0642.rs:12:12
|
||||
|
|
||||
LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0642`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue