rollup merge of #20726: dgrunwald/require-parens-for-chained-comparison

[Rendered RFC](https://github.com/rust-lang/rfcs/blob/master/text/0558-require-parentheses-for-chained-comparisons.md)
This commit is contained in:
Alex Crichton 2015-01-07 17:19:55 -08:00
commit f6a7dc5528
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.
}