@@ -5,7 +5,7 @@ use rustc_ast::{
55    token, 
66    tokenstream:: { DelimSpan ,  TokenStream ,  TokenTree } , 
77    BorrowKind ,  Expr ,  ExprKind ,  ItemKind ,  MacArgs ,  MacCall ,  MacDelimiter ,  Mutability ,  Path , 
8-     PathSegment ,  Stmt ,  UseTree ,  UseTreeKind ,  DUMMY_NODE_ID , 
8+     PathSegment ,  Stmt ,  StructRest ,   UseTree ,  UseTreeKind ,  DUMMY_NODE_ID , 
99} ; 
1010use  rustc_ast_pretty:: pprust; 
1111use  rustc_data_structures:: fx:: FxHashSet ; 
@@ -167,15 +167,103 @@ impl<'cx, 'a> Context<'cx, 'a> {
167167/// See [Self::manage_initial_capture] and [Self::manage_try_capture] 
168168fn  manage_cond_expr ( & mut  self ,  expr :  & mut  P < Expr > )  { 
169169        match  ( * expr) . kind  { 
170+             ExprKind :: AddrOf ( _,  _,  ref  mut  local_expr)  => { 
171+                 self . manage_cond_expr ( local_expr) ; 
172+             } 
173+             ExprKind :: Array ( ref  mut  local_exprs)  => { 
174+                 for  local_expr in  local_exprs { 
175+                     self . manage_cond_expr ( local_expr) ; 
176+                 } 
177+             } 
170178            ExprKind :: Binary ( _,  ref  mut  lhs,  ref  mut  rhs)  => { 
171179                self . manage_cond_expr ( lhs) ; 
172180                self . manage_cond_expr ( rhs) ; 
173181            } 
182+             ExprKind :: Call ( _,  ref  mut  local_exprs)  => { 
183+                 for  local_expr in  local_exprs { 
184+                     self . manage_cond_expr ( local_expr) ; 
185+                 } 
186+             } 
187+             ExprKind :: Cast ( ref  mut  local_expr,  _)  => { 
188+                 self . manage_cond_expr ( local_expr) ; 
189+             } 
190+             ExprKind :: Index ( ref  mut  prefix,  ref  mut  suffix)  => { 
191+                 self . manage_cond_expr ( prefix) ; 
192+                 self . manage_cond_expr ( suffix) ; 
193+             } 
194+             ExprKind :: MethodCall ( _,  ref  mut  local_exprs,  _)  => { 
195+                 for  local_expr in  local_exprs. iter_mut ( ) . skip ( 1 )  { 
196+                     self . manage_cond_expr ( local_expr) ; 
197+                 } 
198+             } 
174199            ExprKind :: Path ( _,  Path  {  ref  segments,  .. } )  if  let  & [ ref  path_segment]  = & segments[ ..]  => { 
175200                let  path_ident = path_segment. ident ; 
176201                self . manage_initial_capture ( expr,  path_ident) ; 
177202            } 
178-             _ => { } 
203+             ExprKind :: Paren ( ref  mut  local_expr)  => { 
204+                 self . manage_cond_expr ( local_expr) ; 
205+             } 
206+             ExprKind :: Range ( ref  mut  prefix,  ref  mut  suffix,  _)  => { 
207+                 if  let  Some ( ref  mut  elem)  = prefix { 
208+                     self . manage_cond_expr ( elem) ; 
209+                 } 
210+                 if  let  Some ( ref  mut  elem)  = suffix { 
211+                     self . manage_cond_expr ( elem) ; 
212+                 } 
213+             } 
214+             ExprKind :: Repeat ( ref  mut  local_expr,  ref  mut  elem)  => { 
215+                 self . manage_cond_expr ( local_expr) ; 
216+                 self . manage_cond_expr ( & mut  elem. value ) ; 
217+             } 
218+             ExprKind :: Struct ( ref  mut  elem)  => { 
219+                 for  field in  & mut  elem. fields  { 
220+                     self . manage_cond_expr ( & mut  field. expr ) ; 
221+                 } 
222+                 if  let  StructRest :: Base ( ref  mut  local_expr)  = elem. rest  { 
223+                     self . manage_cond_expr ( local_expr) ; 
224+                 } 
225+             } 
226+             ExprKind :: Tup ( ref  mut  local_exprs)  => { 
227+                 for  local_expr in  local_exprs { 
228+                     self . manage_cond_expr ( local_expr) ; 
229+                 } 
230+             } 
231+             ExprKind :: Unary ( _,  ref  mut  local_expr)  => { 
232+                 self . manage_cond_expr ( local_expr) ; 
233+             } 
234+             // Expressions that are not worth or can not be captured. 
235+             // 
236+             // Full list instead of `_` to catch possible future inclusions and to 
237+             // sync with the `rfc-2011-nicer-assert-messages/all-expr-kinds.rs` test. 
238+             ExprKind :: Assign ( _,  _,  _) 
239+             | ExprKind :: AssignOp ( _,  _,  _) 
240+             | ExprKind :: Async ( _,  _,  _) 
241+             | ExprKind :: Await ( _) 
242+             | ExprKind :: Block ( _,  _) 
243+             | ExprKind :: Box ( _) 
244+             | ExprKind :: Break ( _,  _) 
245+             | ExprKind :: Closure ( _,  _,  _,  _,  _,  _) 
246+             | ExprKind :: ConstBlock ( _) 
247+             | ExprKind :: Continue ( _) 
248+             | ExprKind :: Err 
249+             | ExprKind :: Field ( _,  _) 
250+             | ExprKind :: ForLoop ( _,  _,  _,  _) 
251+             | ExprKind :: If ( _,  _,  _) 
252+             | ExprKind :: InlineAsm ( _) 
253+             | ExprKind :: Let ( _,  _,  _) 
254+             | ExprKind :: Lit ( _) 
255+             | ExprKind :: Loop ( _,  _) 
256+             | ExprKind :: MacCall ( _) 
257+             | ExprKind :: Match ( _,  _) 
258+             | ExprKind :: Path ( _,  _) 
259+             | ExprKind :: Ret ( _) 
260+             | ExprKind :: Try ( _) 
261+             | ExprKind :: TryBlock ( _) 
262+             | ExprKind :: Type ( _,  _) 
263+             | ExprKind :: Underscore 
264+             | ExprKind :: While ( _,  _,  _) 
265+             | ExprKind :: Yeet ( _) 
266+             | ExprKind :: Yield ( _)  => { } 
179267        } 
180268    } 
181269
0 commit comments