Skip to content

Commit 44019ee

Browse files
committed
Avoid looking at HIR for inline const pattern literals
1 parent 5a0a5e6 commit 44019ee

File tree

1 file changed

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

1 file changed

+0
-24
lines changed

Diff for: compiler/rustc_mir_build/src/thir/pattern/mod.rs

-24
Original file line numberDiff line numberDiff line change
@@ -620,32 +620,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
620620
) -> PatKind<'tcx> {
621621
let tcx = self.tcx;
622622
let def_id = block.def_id;
623-
let body_id = block.body;
624-
let expr = &tcx.hir().body(body_id).value;
625623
let ty = tcx.typeck(def_id).node_type(block.hir_id);
626624

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

0 commit comments

Comments
 (0)