Skip to content

Commit cdb89d6

Browse files
committed
Auto merge of rust-lang#133897 - oli-obk:push-lsxrqtqqwmpt, r=jieyouxu
Remove a lit_to_const call We have so many special cases of `match expr.kind { Lit() => {}, Unary(Neg, Lit()) => {} }`... I'm trying to figure out how to get these all unified, but outright removing some is good, too. So let's try it. Tho we don't have many `const {}` blocks in the perf test suite... But I also don't know how common `const { 42 }` blocks are, I'd expect these to occur mostly from macros (like `thread_local!`)
2 parents ca13e91 + 44019ee commit cdb89d6

File tree

1 file changed

+0
-24
lines changed
  • compiler/rustc_mir_build/src/thir/pattern

1 file changed

+0
-24
lines changed

compiler/rustc_mir_build/src/thir/pattern/mod.rs

-24
Original file line numberDiff line numberDiff line change
@@ -626,32 +626,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
626626
) -> PatKind<'tcx> {
627627
let tcx = self.tcx;
628628
let def_id = block.def_id;
629-
let body_id = block.body;
630-
let expr = &tcx.hir().body(body_id).value;
631629
let ty = tcx.typeck(def_id).node_type(block.hir_id);
632630

633-
// Special case inline consts that are just literals. This is solely
634-
// a performance optimization, as we could also just go through the regular
635-
// const eval path below.
636-
// FIXME: investigate the performance impact of removing this.
637-
let lit_input = match expr.kind {
638-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
639-
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
640-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: true }),
641-
_ => None,
642-
},
643-
_ => None,
644-
};
645-
if let Some(lit_input) = lit_input {
646-
match tcx.at(expr.span).lit_to_const(lit_input) {
647-
Ok(c) => return self.const_to_pat(c, ty, id, span).kind,
648-
// If an error occurred, ignore that it's a literal
649-
// and leave reporting the error up to const eval of
650-
// the unevaluated constant below.
651-
Err(_) => {}
652-
}
653-
}
654-
655631
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id());
656632
let parent_args =
657633
tcx.erase_regions(ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id));

0 commit comments

Comments
 (0)