forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add suggestion for inverted function parameters
Fixes rust-lang#54065.
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 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. | ||
|
||
struct S; | ||
|
||
impl S { | ||
fn foo(&self, &str bar) {} | ||
//~^ ERROR expected one of `:` or `@` | ||
//~| HELP declare the type after the parameter binding | ||
//~| SUGGESTION <identifier>: <type> | ||
} | ||
|
||
fn baz(S quux, xyzzy: i32) {} | ||
//~^ ERROR expected one of `:` or `@` | ||
//~| HELP declare the type after the parameter binding | ||
//~| SUGGESTION <identifier>: <type> | ||
|
||
fn one(i32 a b) {} | ||
//~^ ERROR expected one of `:` or `@` | ||
|
||
fn pattern((i32, i32) (a, b)) {} | ||
//~^ ERROR expected `:` | ||
|
||
fn fizz(i32) {} | ||
//~^ ERROR expected one of `:` or `@` | ||
|
||
fn missing_colon(quux S) {} | ||
//~^ ERROR expected one of `:` or `@` | ||
//~| HELP declare the type after the parameter binding | ||
//~| SUGGESTION <identifier>: <type> | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error: expected one of `:` or `@`, found `bar` | ||
--> $DIR/inverted-parameters.rs:14:24 | ||
| | ||
LL | fn foo(&self, &str bar) {} | ||
| -----^^^ | ||
| | | | ||
| | expected one of `:` or `@` here | ||
| help: declare the type after the parameter binding: `<identifier>: <type>` | ||
|
||
error: expected one of `:` or `@`, found `quux` | ||
--> $DIR/inverted-parameters.rs:20:10 | ||
| | ||
LL | fn baz(S quux, xyzzy: i32) {} | ||
| --^^^^ | ||
| | | | ||
| | expected one of `:` or `@` here | ||
| help: declare the type after the parameter binding: `<identifier>: <type>` | ||
|
||
error: expected one of `:` or `@`, found `a` | ||
--> $DIR/inverted-parameters.rs:25:12 | ||
| | ||
LL | fn one(i32 a b) {} | ||
| ^ expected one of `:` or `@` here | ||
|
||
error: expected `:`, found `(` | ||
--> $DIR/inverted-parameters.rs:28:23 | ||
| | ||
LL | fn pattern((i32, i32) (a, b)) {} | ||
| ^ expected `:` | ||
|
||
error: expected one of `:` or `@`, found `)` | ||
--> $DIR/inverted-parameters.rs:31:12 | ||
| | ||
LL | fn fizz(i32) {} | ||
| ^ expected one of `:` or `@` here | ||
|
||
error: expected one of `:` or `@`, found `S` | ||
--> $DIR/inverted-parameters.rs:34:23 | ||
| | ||
LL | fn missing_colon(quux S) {} | ||
| -----^ | ||
| | | | ||
| | expected one of `:` or `@` here | ||
| help: declare the type after the parameter binding: `<identifier>: <type>` | ||
|
||
error: aborting due to 6 previous errors | ||
|