Skip to content

Commit 509aa23

Browse files
committed
Use question_mark feature in librustc_const_eval.
1 parent 0dbf77e commit 509aa23

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

src/librustc_const_eval/eval.rs

+19-22
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
278278
}
279279
let pat = match expr.node {
280280
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),
284284

285285
hir::ExprCall(ref callee, ref args) => {
286286
let def = tcx.expect_def(callee.id);
@@ -297,34 +297,31 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
297297
})),
298298
_ => bug!()
299299
};
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<_, _>>()?;
304303
PatKind::TupleStruct(path, pats, None)
305304
}
306305

307306
hir::ExprStruct(ref path, ref fields, None) => {
308307
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<_, _>>()?;
320318
PatKind::Struct(path.clone(), field_pats, false)
321319
}
322320

323321
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<_, _>>()?;
328325
PatKind::Vec(pats, None, hir::HirVec::new())
329326
}
330327

0 commit comments

Comments
 (0)