mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Tweak chained comparison errors.
Lower case and give a more precise span: from operator to operator, not just the last one.
This commit is contained in:
parent
2e888d0341
commit
ec790d6fcc
@ -2882,12 +2882,13 @@ impl<'a> Parser<'a> {
|
|||||||
debug_assert!(ast_util::is_comparison_binop(outer_op));
|
debug_assert!(ast_util::is_comparison_binop(outer_op));
|
||||||
match lhs.node {
|
match lhs.node {
|
||||||
ExprBinary(op, _, _) if ast_util::is_comparison_binop(op.node) => {
|
ExprBinary(op, _, _) if ast_util::is_comparison_binop(op.node) => {
|
||||||
let op_span = self.span;
|
// respan to include both operators
|
||||||
|
let op_span = mk_sp(op.span.lo, self.span.hi);
|
||||||
self.span_err(op_span,
|
self.span_err(op_span,
|
||||||
"Chained comparison operators require parentheses");
|
"chained comparison operators require parentheses");
|
||||||
if op.node == BiLt && outer_op == BiGt {
|
if op.node == BiLt && outer_op == BiGt {
|
||||||
self.span_help(op_span,
|
self.span_help(op_span,
|
||||||
"use ::< instead of < if you meant to specify type arguments");
|
"use `::<...>` instead of `<...>` if you meant to specify type arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -12,12 +12,12 @@ fn f<T>() {}
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
false == false == false;
|
false == false == false;
|
||||||
//~^ ERROR: Chained comparison operators require parentheses
|
//~^ ERROR: chained comparison operators require parentheses
|
||||||
|
|
||||||
false == 0 < 2;
|
false == 0 < 2;
|
||||||
//~^ ERROR: Chained comparison operators require parentheses
|
//~^ ERROR: chained comparison operators require parentheses
|
||||||
|
|
||||||
f<X>();
|
f<X>();
|
||||||
//~^ ERROR: Chained comparison operators require parentheses
|
//~^ ERROR: chained comparison operators require parentheses
|
||||||
//~^^ HELP: use ::< instead of < if you meant to specify type arguments
|
//~^^ HELP: use `::<...>` instead of `<...>`
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ fn f<X>() {}
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
f<type>();
|
f<type>();
|
||||||
//~^ ERROR expected identifier, found keyword `type`
|
//~^ ERROR expected identifier, found keyword `type`
|
||||||
//~^^ ERROR: Chained comparison operators require parentheses
|
//~^^ ERROR: chained comparison
|
||||||
//~^^^ HELP: use ::< instead of < if you meant to specify type arguments
|
//~^^^ HELP: use `::<
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user