diff options
| author | bors <bors@rust-lang.org> | 2016-01-16 17:57:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-16 17:57:01 +0000 |
| commit | 05aeeb314d0559c2711168cee7655f38ed18511c (patch) | |
| tree | 770f89a9cd99f432e513bf8050b3460078e4d189 /src | |
| parent | c14b615534ebcd5667f594c86d18eebff6afc7cb (diff) | |
| parent | 1aacd9d44f1a822aa9e9e4847f1004e7035410cf (diff) | |
| download | rust-05aeeb314d0559c2711168cee7655f38ed18511c.tar.gz rust-05aeeb314d0559c2711168cee7655f38ed18511c.zip | |
Auto merge of #30934 - oli-obk:simplify_const_eval, r=alexcrichton
the `None` and the `DefVariant` paths were unused anyway.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/const_eval.rs | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index ab421b27c08..f9ab79de2ff 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -44,20 +44,6 @@ use std::mem::transmute; use std::{i8, i16, i32, i64, u8, u16, u32, u64}; use std::rc::Rc; -fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> { - let opt_def = tcx.def_map.borrow().get(&e.id).map(|d| d.full_def()); - match opt_def { - Some(def::DefConst(def_id)) | - Some(def::DefAssociatedConst(def_id)) => { - lookup_const_by_id(tcx, def_id, Some(e.id), None) - } - Some(def::DefVariant(enum_def, variant_def, _)) => { - lookup_variant_by_id(tcx, enum_def, variant_def) - } - _ => None - } -} - fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, enum_def: DefId, variant_def: DefId) @@ -382,12 +368,12 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat> hir::PatStruct(path.clone(), hir::HirVec::new(), false), Some(def::DefVariant(..)) => hir::PatEnum(path.clone(), None), - _ => { - match lookup_const(tcx, expr) { - Some(actual) => return const_expr_to_pat(tcx, actual, span), - _ => unreachable!() - } - } + Some(def::DefConst(def_id)) | + Some(def::DefAssociatedConst(def_id)) => { + let expr = lookup_const_by_id(tcx, def_id, Some(expr.id), None).unwrap(); + return const_expr_to_pat(tcx, expr, span); + }, + _ => unreachable!(), } } |
