RFC 558: Require parentheses for chained comparisons

Fixes #20724.
This commit is contained in:
Daniel Grunwald 2015-01-08 01:44:01 +01:00
parent 9e4e524e0e
commit 1cc69c484e
4 changed files with 58 additions and 4 deletions

View file

@ -0,0 +1,23 @@
// Copyright 2015 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.
fn f<T>() {}
fn main() {
false == false == false;
//~^ ERROR: Chained comparison operators require parentheses
false == 0 < 2;
//~^ ERROR: Chained comparison operators require parentheses
f<X>();
//~^ ERROR: Chained comparison operators require parentheses
//~^^ HELP: Use ::< instead of < if you meant to specify type arguments.
}

View file

@ -13,5 +13,8 @@
fn f<X>() {}
pub fn main() {
f<type>(); //~ ERROR expected identifier, found keyword `type`
f<type>();
//~^ ERROR expected identifier, found keyword `type`
//~^^ ERROR: Chained comparison operators require parentheses
//~^^^ HELP: Use ::< instead of < if you meant to specify type arguments.
}