[RFC-2011] Expand more expressions by c410-f3r · Pull Request #111928 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation7 Commits1 Checks0 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
cc #44838
Expands if
, let
, match
and also makes generic_assert_internals
an allowed feature when using assert!
. #![feature(generic_assert)]
is still needed to activate everything.
#![feature(generic_assert)]
fn fun(a: Option, b: Option, c: Option) { assert!( if a.is_some() { 1 } else { 2 } == 3 && if let Some(elem) = b { elem == 4 } else { false } && match c { Some(_) => true, None => false } ); }
fn main() { fun(Some(1), None, Some(2)); }
// Assertion failed: assert!( // if a.is_some() { 1 } else { 2 } == 3 // && if let Some(elem) = b { elem == 4 } else { false } // && match c { Some(_) => true, None => false } // ); // // With captures: // a = Some(1) // b = None // c = Some(2)
r? @eholk
(rustbot has picked a reviewer for you, use r? to override)
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.
labels
Comment on lines -110 to -112
// ***** Disallowed ***** |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New AST variants were created and nobody bothered to include them here and probably nobody will in the future. It is then better to just test allowed expressions.
Looks good to me. Thanks!
@bors r+
📌 Commit 462a96c has been approved by eholk
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request
[RFC-2011] Expand more expressions
Expands if
, let
, match
and also makes generic_assert_internals
an allowed feature when using assert!
. #![feature(generic_assert)]
is still needed to activate everything.
#![feature(generic_assert)]
fn fun(a: Option<i32>, b: Option<i32>, c: Option<i32>) {
assert!(
if a.is_some() { 1 } else { 2 } == 3
&& if let Some(elem) = b { elem == 4 } else { false }
&& match c { Some(_) => true, None => false }
);
}
fn main() {
fun(Some(1), None, Some(2));
}
// Assertion failed: assert!(
// if a.is_some() { 1 } else { 2 } == 3
// && if let Some(elem) = b { elem == 4 } else { false }
// && match c { Some(_) => true, None => false }
// );
//
// With captures:
// a = Some(1)
// b = None
// c = Some(2)
compiler-errors added a commit to compiler-errors/rust that referenced this pull request
[RFC-2011] Expand more expressions
Expands if
, let
, match
and also makes generic_assert_internals
an allowed feature when using assert!
. #![feature(generic_assert)]
is still needed to activate everything.
#![feature(generic_assert)]
fn fun(a: Option<i32>, b: Option<i32>, c: Option<i32>) {
assert!(
if a.is_some() { 1 } else { 2 } == 3
&& if let Some(elem) = b { elem == 4 } else { false }
&& match c { Some(_) => true, None => false }
);
}
fn main() {
fun(Some(1), None, Some(2));
}
// Assertion failed: assert!(
// if a.is_some() { 1 } else { 2 } == 3
// && if let Some(elem) = b { elem == 4 } else { false }
// && match c { Some(_) => true, None => false }
// );
//
// With captures:
// a = Some(1)
// b = None
// c = Some(2)
bors mentioned this pull request
Finished benchmarking commit (a525c7d): comparison URL.
Overall result: no relevant changes - no action needed
@rustbot label: -perf-regression
Instruction count
This benchmark run did not return any relevant results for this metric.
Max RSS (memory usage)
Results
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) | 3.7% | [3.7%, 3.7%] | 1 |
Regressions ❌ (secondary) | 1.1% | [1.1%, 1.1%] | 1 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | 3.7% | [3.7%, 3.7%] | 1 |
Cycles
Results
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
mean | range | count | |
---|---|---|---|
Regressions ❌ (primary) | - | - | 0 |
Regressions ❌ (secondary) | 7.0% | [2.8%, 9.3%] | 9 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | - | - | 0 |
Binary size
This benchmark run did not return any relevant results for this metric.
Bootstrap: 643.935s -> 643.531s (-0.06%)
Labels
`#![feature(generic_assert)]`
This PR was explicitly merged by bors.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.