Skip to content

Commit

Permalink
Rollup merge of rust-lang#45122 - jean-lourenco:master, r=nikomatsakis
Browse files Browse the repository at this point in the history
Better compile error output when using arguments instead of types

Following @estebank sugestion on issue rust-lang#18945 (comment)
  • Loading branch information
kennytm committed Oct 12, 2017
2 parents 79ed52a + db91b00 commit 9655312
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,7 @@ impl<'a> Parser<'a> {
{ // Foo<Bar<Baz<Qux, ()>>>
err.help(
"use `::<...>` instead of `<...>` if you meant to specify type arguments");
err.help("or use `(...)` if you meant to specify fn arguments");
}
err.emit();
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/parse-fail/require-parens-for-chained-comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ fn main() {

f<X>();
//~^ ERROR: chained comparison operators require parentheses
//~^^ HELP: use `::<...>` instead of `<...>`
//~| HELP: use `::<...>` instead of `<...>`
//~| HELP: or use `(...)`
}
4 changes: 4 additions & 0 deletions src/test/ui/did_you_mean/issue-40396.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ error: chained comparison operators require parentheses
| ^^^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments

error: chained comparison operators require parentheses
--> $DIR/issue-40396.rs:16:25
Expand All @@ -13,6 +14,7 @@ error: chained comparison operators require parentheses
| ^^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments

error: chained comparison operators require parentheses
--> $DIR/issue-40396.rs:20:37
Expand All @@ -21,6 +23,7 @@ error: chained comparison operators require parentheses
| ^^^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments

error: chained comparison operators require parentheses
--> $DIR/issue-40396.rs:20:41
Expand All @@ -29,6 +32,7 @@ error: chained comparison operators require parentheses
| ^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments

error: aborting due to 4 previous errors

0 comments on commit 9655312

Please sign in to comment.