-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #53854 - davidtwco:issue-53668, r=nikomatsakis
if- and while-let-chains, take 2 - edition changes Part of #53668. r? @nikomatsakis
- Loading branch information
Showing
5 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2016 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. | ||
|
||
// edition:2015 | ||
|
||
// Enabling `ireffutable_let_patterns` isn't necessary for what this tests, but it makes coming up | ||
// with examples easier. | ||
#![feature(irrefutable_let_patterns)] | ||
|
||
#[allow(irrefutable_let_patterns)] | ||
fn main() { | ||
use std::ops::Range; | ||
|
||
if let Range { start: _, end: _ } = true..true && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
if let Range { start: _, end: _ } = true..true || false { } | ||
//~^ ERROR ambigious use of `||` | ||
|
||
while let Range { start: _, end: _ } = true..true && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
while let Range { start: _, end: _ } = true..true || false { } | ||
//~^ ERROR ambigious use of `||` | ||
|
||
if let true = false && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
while let true = (1 == 2) && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
// The following cases are not an error as parenthesis are used to | ||
// clarify intent: | ||
|
||
if let Range { start: _, end: _ } = true..(true || false) { } | ||
|
||
if let Range { start: _, end: _ } = true..(true && false) { } | ||
|
||
while let Range { start: _, end: _ } = true..(true || false) { } | ||
|
||
while let Range { start: _, end: _ } = true..(true && false) { } | ||
} |
56 changes: 56 additions & 0 deletions
56
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:21:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2015.rs:24:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:27:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2015.rs:30:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:33:19 | ||
| | ||
LL | if let true = false && false { } | ||
| ^^^^^^^^^^^^^^ help: consider adding parentheses: `(false && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:36:22 | ||
| | ||
LL | while let true = (1 == 2) && false { } | ||
| ^^^^^^^^^^^^^^^^^ help: consider adding parentheses: `((1 == 2) && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: aborting due to 6 previous errors | ||
|
49 changes: 49 additions & 0 deletions
49
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2016 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. | ||
|
||
// edition:2018 | ||
|
||
// Enabling `ireffutable_let_patterns` isn't necessary for what this tests, but it makes coming up | ||
// with examples easier. | ||
#![feature(irrefutable_let_patterns)] | ||
|
||
#[allow(irrefutable_let_patterns)] | ||
fn main() { | ||
use std::ops::Range; | ||
|
||
if let Range { start: _, end: _ } = true..true && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
if let Range { start: _, end: _ } = true..true || false { } | ||
//~^ ERROR ambigious use of `||` | ||
|
||
while let Range { start: _, end: _ } = true..true && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
while let Range { start: _, end: _ } = true..true || false { } | ||
//~^ ERROR ambigious use of `||` | ||
|
||
if let true = false && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
while let true = (1 == 2) && false { } | ||
//~^ ERROR ambigious use of `&&` | ||
|
||
// The following cases are not an error as parenthesis are used to | ||
// clarify intent: | ||
|
||
if let Range { start: _, end: _ } = true..(true || false) { } | ||
|
||
if let Range { start: _, end: _ } = true..(true && false) { } | ||
|
||
while let Range { start: _, end: _ } = true..(true || false) { } | ||
|
||
while let Range { start: _, end: _ } = true..(true && false) { } | ||
} |
56 changes: 56 additions & 0 deletions
56
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:21:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2018.rs:24:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:27:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2018.rs:30:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:33:19 | ||
| | ||
LL | if let true = false && false { } | ||
| ^^^^^^^^^^^^^^ help: consider adding parentheses: `(false && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:36:22 | ||
| | ||
LL | while let true = (1 == 2) && false { } | ||
| ^^^^^^^^^^^^^^^^^ help: consider adding parentheses: `((1 == 2) && false)` | ||
| | ||
= note: this will be a error until the `let_chains` feature is stabilized | ||
= note: see rust-lang/rust#53668 for more information | ||
|
||
error: aborting due to 6 previous errors | ||
|