diff options
| author | bors <bors@rust-lang.org> | 2023-05-27 07:02:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-27 07:02:48 +0000 |
| commit | a525c7ddba5997b132efa46515e0ce90c173f480 (patch) | |
| tree | 17ca62c1eb7822c77ba93af082ea1b00af290f20 /library/core/src/macros/mod.rs | |
| parent | dbfc95f969802788f6082772c50f7f3d20d5bf88 (diff) | |
| parent | 462a96c9e902e8ec7b2fddfbe9429f27eb0030d0 (diff) | |
| download | rust-a525c7ddba5997b132efa46515e0ce90c173f480.tar.gz rust-a525c7ddba5997b132efa46515e0ce90c173f480.zip | |
Auto merge of #111928 - c410-f3r:dqewdas, r=eholk
[RFC-2011] Expand more expressions
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.
```rust
#![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)
```
Diffstat (limited to 'library/core/src/macros/mod.rs')
| -rw-r--r-- | library/core/src/macros/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index b24882ddb17..c4134dbcd25 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1427,7 +1427,7 @@ pub(crate) mod builtin { #[rustc_builtin_macro] #[macro_export] #[rustc_diagnostic_item = "assert_macro"] - #[allow_internal_unstable(core_panic, edition_panic)] + #[allow_internal_unstable(core_panic, edition_panic, generic_assert_internals)] macro_rules! assert { ($cond:expr $(,)?) => {{ /* compiler built-in */ }}; ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }}; |
