Skip to content

Commit 05aeeb3

Browse files
committed
Auto merge of #30934 - oli-obk:simplify_const_eval, r=alexcrichton
the `None` and the `DefVariant` paths were unused anyway.
2 parents c14b615 + 1aacd9d commit 05aeeb3

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

src/librustc/middle/const_eval.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ use std::mem::transmute;
4444
use std::{i8, i16, i32, i64, u8, u16, u32, u64};
4545
use std::rc::Rc;
4646

47-
fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> {
48-
let opt_def = tcx.def_map.borrow().get(&e.id).map(|d| d.full_def());
49-
match opt_def {
50-
Some(def::DefConst(def_id)) |
51-
Some(def::DefAssociatedConst(def_id)) => {
52-
lookup_const_by_id(tcx, def_id, Some(e.id), None)
53-
}
54-
Some(def::DefVariant(enum_def, variant_def, _)) => {
55-
lookup_variant_by_id(tcx, enum_def, variant_def)
56-
}
57-
_ => None
58-
}
59-
}
60-
6147
fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
6248
enum_def: DefId,
6349
variant_def: DefId)
@@ -382,12 +368,12 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
382368
hir::PatStruct(path.clone(), hir::HirVec::new(), false),
383369
Some(def::DefVariant(..)) =>
384370
hir::PatEnum(path.clone(), None),
385-
_ => {
386-
match lookup_const(tcx, expr) {
387-
Some(actual) => return const_expr_to_pat(tcx, actual, span),
388-
_ => unreachable!()
389-
}
390-
}
371+
Some(def::DefConst(def_id)) |
372+
Some(def::DefAssociatedConst(def_id)) => {
373+
let expr = lookup_const_by_id(tcx, def_id, Some(expr.id), None).unwrap();
374+
return const_expr_to_pat(tcx, expr, span);
375+
},
376+
_ => unreachable!(),
391377
}
392378
}
393379

0 commit comments

Comments
 (0)