Use question_mark feature in librustc_const_eval.
This commit is contained in:
parent
0dbf77e722
commit
509aa235ba
@ -278,9 +278,9 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
let pat = match expr.node {
|
||||
hir::ExprTup(ref exprs) =>
|
||||
PatKind::Tuple(try!(exprs.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
|
||||
.collect()), None),
|
||||
PatKind::Tuple(exprs.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
|
||||
.collect::<Result<_, _>>()?, None),
|
||||
|
||||
hir::ExprCall(ref callee, ref args) => {
|
||||
let def = tcx.expect_def(callee.id);
|
||||
@ -297,34 +297,31 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
})),
|
||||
_ => bug!()
|
||||
};
|
||||
let pats = try!(args.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &**expr,
|
||||
pat_id, span))
|
||||
.collect());
|
||||
let pats = args.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &**expr, pat_id, span))
|
||||
.collect::<Result<_, _>>()?;
|
||||
PatKind::TupleStruct(path, pats, None)
|
||||
}
|
||||
|
||||
hir::ExprStruct(ref path, ref fields, None) => {
|
||||
let field_pats =
|
||||
try!(fields.iter()
|
||||
.map(|field| Ok(codemap::Spanned {
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
node: hir::FieldPat {
|
||||
name: field.name.node,
|
||||
pat: try!(const_expr_to_pat(tcx, &field.expr,
|
||||
pat_id, span)),
|
||||
is_shorthand: false,
|
||||
},
|
||||
}))
|
||||
.collect());
|
||||
fields.iter()
|
||||
.map(|field| Ok(codemap::Spanned {
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
node: hir::FieldPat {
|
||||
name: field.name.node,
|
||||
pat: const_expr_to_pat(tcx, &field.expr, pat_id, span)?,
|
||||
is_shorthand: false,
|
||||
},
|
||||
}))
|
||||
.collect::<Result<_, _>>()?;
|
||||
PatKind::Struct(path.clone(), field_pats, false)
|
||||
}
|
||||
|
||||
hir::ExprVec(ref exprs) => {
|
||||
let pats = try!(exprs.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &expr,
|
||||
pat_id, span))
|
||||
.collect());
|
||||
let pats = exprs.iter()
|
||||
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
|
||||
.collect::<Result<_, _>>()?;
|
||||
PatKind::Vec(pats, None, hir::HirVec::new())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user