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) ```
This commit is contained in:
commit
a525c7ddba
9 changed files with 29 additions and 86 deletions
|
@ -233,10 +233,19 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
|||
ExprKind::Cast(local_expr, _) => {
|
||||
self.manage_cond_expr(local_expr);
|
||||
}
|
||||
ExprKind::If(local_expr, _, _) => {
|
||||
self.manage_cond_expr(local_expr);
|
||||
}
|
||||
ExprKind::Index(prefix, suffix) => {
|
||||
self.manage_cond_expr(prefix);
|
||||
self.manage_cond_expr(suffix);
|
||||
}
|
||||
ExprKind::Let(_, local_expr, _) => {
|
||||
self.manage_cond_expr(local_expr);
|
||||
}
|
||||
ExprKind::Match(local_expr, _) => {
|
||||
self.manage_cond_expr(local_expr);
|
||||
}
|
||||
ExprKind::MethodCall(call) => {
|
||||
for arg in &mut call.args {
|
||||
self.manage_cond_expr(arg);
|
||||
|
@ -295,17 +304,14 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
|||
| ExprKind::Continue(_)
|
||||
| ExprKind::Err
|
||||
| ExprKind::Field(_, _)
|
||||
| ExprKind::FormatArgs(_)
|
||||
| ExprKind::ForLoop(_, _, _, _)
|
||||
| ExprKind::If(_, _, _)
|
||||
| ExprKind::FormatArgs(_)
|
||||
| ExprKind::IncludedBytes(..)
|
||||
| ExprKind::InlineAsm(_)
|
||||
| ExprKind::OffsetOf(_, _)
|
||||
| ExprKind::Let(_, _, _)
|
||||
| ExprKind::Lit(_)
|
||||
| ExprKind::Loop(_, _, _)
|
||||
| ExprKind::MacCall(_)
|
||||
| ExprKind::Match(_, _)
|
||||
| ExprKind::OffsetOf(_, _)
|
||||
| ExprKind::Path(_, _)
|
||||
| ExprKind::Ret(_)
|
||||
| ExprKind::Try(_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue