@@ -278,9 +278,9 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
278
278
}
279
279
let pat = match expr. node {
280
280
hir:: ExprTup ( ref exprs) =>
281
- PatKind :: Tuple ( try! ( exprs. iter ( )
282
- . map ( |expr| const_expr_to_pat ( tcx, & expr, pat_id, span) )
283
- . collect ( ) ) , None ) ,
281
+ PatKind :: Tuple ( exprs. iter ( )
282
+ . map ( |expr| const_expr_to_pat ( tcx, & expr, pat_id, span) )
283
+ . collect :: < Result < _ , _ > > ( ) ? , None ) ,
284
284
285
285
hir:: ExprCall ( ref callee, ref args) => {
286
286
let def = tcx. expect_def ( callee. id ) ;
@@ -297,34 +297,31 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
297
297
} ) ) ,
298
298
_ => bug ! ( )
299
299
} ;
300
- let pats = try!( args. iter ( )
301
- . map ( |expr| const_expr_to_pat ( tcx, & * * expr,
302
- pat_id, span) )
303
- . collect ( ) ) ;
300
+ let pats = args. iter ( )
301
+ . map ( |expr| const_expr_to_pat ( tcx, & * * expr, pat_id, span) )
302
+ . collect :: < Result < _ , _ > > ( ) ?;
304
303
PatKind :: TupleStruct ( path, pats, None )
305
304
}
306
305
307
306
hir:: ExprStruct ( ref path, ref fields, None ) => {
308
307
let field_pats =
309
- try!( fields. iter ( )
310
- . map ( |field| Ok ( codemap:: Spanned {
311
- span : syntax_pos:: DUMMY_SP ,
312
- node : hir:: FieldPat {
313
- name : field. name . node ,
314
- pat : try!( const_expr_to_pat ( tcx, & field. expr ,
315
- pat_id, span) ) ,
316
- is_shorthand : false ,
317
- } ,
318
- } ) )
319
- . collect ( ) ) ;
308
+ fields. iter ( )
309
+ . map ( |field| Ok ( codemap:: Spanned {
310
+ span : syntax_pos:: DUMMY_SP ,
311
+ node : hir:: FieldPat {
312
+ name : field. name . node ,
313
+ pat : const_expr_to_pat ( tcx, & field. expr , pat_id, span) ?,
314
+ is_shorthand : false ,
315
+ } ,
316
+ } ) )
317
+ . collect :: < Result < _ , _ > > ( ) ?;
320
318
PatKind :: Struct ( path. clone ( ) , field_pats, false )
321
319
}
322
320
323
321
hir:: ExprVec ( ref exprs) => {
324
- let pats = try!( exprs. iter ( )
325
- . map ( |expr| const_expr_to_pat ( tcx, & expr,
326
- pat_id, span) )
327
- . collect ( ) ) ;
322
+ let pats = exprs. iter ( )
323
+ . map ( |expr| const_expr_to_pat ( tcx, & expr, pat_id, span) )
324
+ . collect :: < Result < _ , _ > > ( ) ?;
328
325
PatKind :: Vec ( pats, None , hir:: HirVec :: new ( ) )
329
326
}
330
327
0 commit comments