Skip to content

Commit 1722aa7

Browse files
committed
Remove some dead code
1 parent 4ca8707 commit 1722aa7

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,6 @@ impl<'tcx> ConstToPat<'tcx> {
369369
suffix: Box::new([]),
370370
},
371371
ty::Ref(_, pointee_ty, ..) => match *pointee_ty.kind() {
372-
// These are not allowed and will error elsewhere anyway.
373-
ty::Dynamic(..) => {
374-
self.saw_const_match_error.set(true);
375-
let err = InvalidPattern { span, non_sm_ty: ty };
376-
tcx.sess.emit_err(err);
377-
PatKind::Wild
378-
}
379372
// `&str` is represented as a valtree, let's keep using this
380373
// optimization for now.
381374
ty::Str => PatKind::Constant { value: mir::ConstantKind::Ty(tcx.mk_const(cv, ty)) },
@@ -467,6 +460,7 @@ impl<'tcx> ConstToPat<'tcx> {
467460
let err = UnsizedPattern { span, non_sm_ty: *pointee_ty };
468461
tcx.sess.emit_err(err);
469462

463+
// FIXME: introduce PatKind::Error to silence follow up diagnostics due to unreachable patterns.
470464
PatKind::Wild
471465
} else {
472466
let old = self.behind_reference.replace(true);

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ use smallvec::{smallvec, SmallVec};
5353
use rustc_data_structures::captures::Captures;
5454
use rustc_hir::{HirId, RangeEnd};
5555
use rustc_index::Idx;
56+
use rustc_middle::middle::stability::EvalResult;
5657
use rustc_middle::mir;
5758
use rustc_middle::thir::{FieldPat, Pat, PatKind, PatRange};
5859
use rustc_middle::ty::layout::IntegerExt;
5960
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
60-
use rustc_middle::{middle::stability::EvalResult, mir::interpret::ConstValue};
6161
use rustc_session::lint;
6262
use rustc_span::{Span, DUMMY_SP};
6363
use rustc_target::abi::{FieldIdx, Integer, Size, VariantIdx, FIRST_VARIANT};
@@ -142,13 +142,6 @@ impl IntRange {
142142
let ty = value.ty();
143143
if let Some((target_size, bias)) = Self::integral_size_and_signed_bias(tcx, ty) {
144144
let val = match value {
145-
mir::ConstantKind::Val(ConstValue::Scalar(scalar), _) => {
146-
// For this specific pattern we can skip a lot of effort and go
147-
// straight to the result, after doing a bit of checking. (We
148-
// could remove this branch and just fall through, which
149-
// is more general but much slower.)
150-
scalar.to_bits_or_ptr_internal(target_size).unwrap().left()
151-
}
152145
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
153146
valtree.unwrap_leaf().to_bits(target_size).ok()
154147
},

0 commit comments

Comments
 (0)