Rollup merge of #45122 - jean-lourenco:master, r=nikomatsakis

Better compile error output when using arguments instead of types

Following @estebank sugestion on issue https://github.com/rust-lang/rust/issues/18945#issuecomment-331251436
This commit is contained in:
kennytm 2017-10-13 23:37:54 +08:00 committed by GitHub
commit 9eab4ec823
3 changed files with 7 additions and 1 deletions

View File

@ -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();
}

View File

@ -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 `(...)`
}

View File

@ -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
@ -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
@ -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
@ -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