File tree Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -2919,7 +2919,10 @@ impl<'a> Parser<'a> {
2919
2919
let op_span = mk_sp ( op. span . lo , self . span . hi ) ;
2920
2920
let mut err = self . diagnostic ( ) . struct_span_err ( op_span,
2921
2921
"chained comparison operators require parentheses" ) ;
2922
- if op. node == BinOpKind :: Lt && * outer_op == AssocOp :: Greater {
2922
+ if op. node == BinOpKind :: Lt &&
2923
+ * outer_op == AssocOp :: Less || // Include `<` to provide this recommendation
2924
+ * outer_op == AssocOp :: Greater // even in a case like the following:
2925
+ { // Foo<Bar<Baz<Qux, ()>>>
2923
2926
err. help (
2924
2927
"use `::<...>` instead of `<...>` if you meant to specify type arguments" ) ;
2925
2928
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ fn foo ( ) {
12
+ println ! ( "{:?}" , ( 0 ..13 ) . collect<Vec <i32 >>( ) ) ;
13
+ }
14
+
15
+ fn bar ( ) {
16
+ println ! ( "{:?}" , Vec <i32 >:: new( ) ) ;
17
+ }
18
+
19
+ fn qux ( ) {
20
+ println ! ( "{:?}" , ( 0 ..13 ) . collect<Vec <i32 >( ) ) ;
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: chained comparison operators require parentheses
2
+ --> $DIR/issue-40396.rs:12:37
3
+ |
4
+ 12 | println!("{:?}", (0..13).collect<Vec<i32>>());
5
+ | ^^^^^^^^
6
+ |
7
+ = help: use `::<...>` instead of `<...>` if you meant to specify type arguments
8
+
9
+ error: chained comparison operators require parentheses
10
+ --> $DIR/issue-40396.rs:16:25
11
+ |
12
+ 16 | println!("{:?}", Vec<i32>::new());
13
+ | ^^^^^^^
14
+ |
15
+ = help: use `::<...>` instead of `<...>` if you meant to specify type arguments
16
+
17
+ error: chained comparison operators require parentheses
18
+ --> $DIR/issue-40396.rs:20:37
19
+ |
20
+ 20 | println!("{:?}", (0..13).collect<Vec<i32>());
21
+ | ^^^^^^^^
22
+ |
23
+ = help: use `::<...>` instead of `<...>` if you meant to specify type arguments
24
+
25
+ error: chained comparison operators require parentheses
26
+ --> $DIR/issue-40396.rs:20:41
27
+ |
28
+ 20 | println!("{:?}", (0..13).collect<Vec<i32>());
29
+ | ^^^^^^
30
+ |
31
+ = help: use `::<...>` instead of `<...>` if you meant to specify type arguments
32
+
33
+ error: aborting due to 4 previous errors
34
+
You can’t perform that action at this time.
0 commit comments