-
Notifications
You must be signed in to change notification settings - Fork 13.5k
if- and while-let-chains, take 2 - edition changes #53854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
50 changes: 50 additions & 0 deletions
50
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs
This file contains hidden or 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,50 @@ | ||
// 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 | ||
// compile-pass | ||
|
||
// 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 { } | ||
//~^ WARN error in 2018 | ||
|
||
if let Range { start: _, end: _ } = true..true || false { } | ||
//~^ WARN error in 2018 | ||
|
||
while let Range { start: _, end: _ } = true..true && false { } | ||
//~^ WARN error in 2018 | ||
|
||
while let Range { start: _, end: _ } = true..true || false { } | ||
//~^ WARN error in 2018 | ||
|
||
if let true = false && false { } | ||
//~^ WARN error in 2018 | ||
|
||
while let true = (1 == 2) && false { } | ||
//~^ WARN error in 2018 | ||
|
||
// 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) { } | ||
} |
48 changes: 48 additions & 0 deletions
48
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr
This file contains hidden or 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,48 @@ | ||
warning: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:22:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true && false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
||
warning: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2015.rs:25:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true || false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
||
warning: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:28:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true && false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
||
warning: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2015.rs:31:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true || false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
||
warning: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:34:19 | ||
| | ||
LL | if let true = false && false { } | ||
| ^^^^^^^^^^^^^^ help: consider adding parenthesis: `(false && false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
||
warning: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2015.rs:37:22 | ||
| | ||
LL | while let true = (1 == 2) && false { } | ||
| ^^^^^^^^^^^^^^^^^ help: consider adding parenthesis: `((1 == 2) && false)` | ||
| | ||
= note: This will be a error in Rust 2018 until the `let_chains` feature is stabilized. | ||
|
49 changes: 49 additions & 0 deletions
49
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs
This file contains hidden or 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) { } | ||
} |
50 changes: 50 additions & 0 deletions
50
src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr
This file contains hidden or 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,50 @@ | ||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:21:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true && false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2018.rs:24:47 | ||
| | ||
LL | if let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true || false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:27:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true && false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true && false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: ambigious use of `||` | ||
--> $DIR/syntax-ambiguity-2018.rs:30:50 | ||
| | ||
LL | while let Range { start: _, end: _ } = true..true || false { } | ||
| ^^^^^^^^^^^^^ help: consider adding parenthesis: `(true || false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:33:19 | ||
| | ||
LL | if let true = false && false { } | ||
| ^^^^^^^^^^^^^^ help: consider adding parenthesis: `(false && false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: ambigious use of `&&` | ||
--> $DIR/syntax-ambiguity-2018.rs:36:22 | ||
| | ||
LL | while let true = (1 == 2) && false { } | ||
| ^^^^^^^^^^^^^^^^^ help: consider adding parenthesis: `((1 == 2) && false)` | ||
| | ||
= note: This will be a error until the `let_chains` feature is stabilized. | ||
|
||
error: aborting due to 6 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.