Skip to content

Commit 52a0283

Browse files
committed
convert the creepy case to just return None -- in practice, it would
have always been returning None anyway, since it was comparing node-ids across crates incorrectly -- and remove the now unused map `extern_const_variants`
1 parent 01f32ac commit 52a0283

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
8282
Some(_) => None
8383
}
8484
} else {
85-
match tcx.extern_const_variants.borrow().get(&variant_def) {
86-
Some(&ast::DUMMY_NODE_ID) => return None,
87-
Some(&expr_id) => {
88-
return Some(tcx.map.expect_expr(expr_id));
89-
}
90-
None => {}
91-
}
92-
let expr_id = match
93-
csearch::maybe_get_item_ast(
94-
tcx, enum_def,
95-
Box::new(|a, b, c, d, e| astencode::decode_inlined_item(a, b, c, d, e)))
96-
{
97-
csearch::FoundAst::Found(&InlinedItem::Item(ref item)) => match item.node {
98-
hir::ItemEnum(hir::EnumDef { .. }, _) => {
99-
tcx.sess.span_bug(
100-
item.span,
101-
&format!("cross-crate enum discr constant with enum {:?} variant {:?}",
102-
enum_def, variant_def));
103-
}
104-
_ => None
105-
},
106-
_ => None
107-
};
108-
tcx.extern_const_variants.borrow_mut().insert(variant_def,
109-
expr_id.unwrap_or(ast::DUMMY_NODE_ID));
110-
expr_id.map(|id| tcx.map.expect_expr(id))
85+
None
11186
}
11287
}
11388

src/librustc/middle/ty/context.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ pub struct ctxt<'tcx> {
307307

308308
/// These caches are used by const_eval when decoding external constants.
309309
pub extern_const_statics: RefCell<DefIdMap<NodeId>>,
310-
pub extern_const_variants: RefCell<DefIdMap<NodeId>>,
311310
pub extern_const_fns: RefCell<DefIdMap<NodeId>>,
312311

313312
pub node_lint_levels: RefCell<FnvHashMap<(NodeId, lint::LintId),
@@ -500,7 +499,6 @@ impl<'tcx> ctxt<'tcx> {
500499
populated_external_types: RefCell::new(DefIdSet()),
501500
populated_external_primitive_impls: RefCell::new(DefIdSet()),
502501
extern_const_statics: RefCell::new(DefIdMap()),
503-
extern_const_variants: RefCell::new(DefIdMap()),
504502
extern_const_fns: RefCell::new(DefIdMap()),
505503
node_lint_levels: RefCell::new(FnvHashMap()),
506504
transmute_restrictions: RefCell::new(Vec::new()),

0 commit comments

Comments
 (0)