Remove some dead code
This commit is contained in:
parent
4ca87073f6
commit
1722aa79ea
@ -369,13 +369,6 @@ fn recur(
|
||||
suffix: Box::new([]),
|
||||
},
|
||||
ty::Ref(_, pointee_ty, ..) => match *pointee_ty.kind() {
|
||||
// These are not allowed and will error elsewhere anyway.
|
||||
ty::Dynamic(..) => {
|
||||
self.saw_const_match_error.set(true);
|
||||
let err = InvalidPattern { span, non_sm_ty: ty };
|
||||
tcx.sess.emit_err(err);
|
||||
PatKind::Wild
|
||||
}
|
||||
// `&str` is represented as a valtree, let's keep using this
|
||||
// optimization for now.
|
||||
ty::Str => PatKind::Constant { value: mir::ConstantKind::Ty(tcx.mk_const(cv, ty)) },
|
||||
@ -467,6 +460,7 @@ fn recur(
|
||||
let err = UnsizedPattern { span, non_sm_ty: *pointee_ty };
|
||||
tcx.sess.emit_err(err);
|
||||
|
||||
// FIXME: introduce PatKind::Error to silence follow up diagnostics due to unreachable patterns.
|
||||
PatKind::Wild
|
||||
} else {
|
||||
let old = self.behind_reference.replace(true);
|
||||
|
@ -53,11 +53,11 @@
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_hir::{HirId, RangeEnd};
|
||||
use rustc_index::Idx;
|
||||
use rustc_middle::middle::stability::EvalResult;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::thir::{FieldPat, Pat, PatKind, PatRange};
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
|
||||
use rustc_middle::{middle::stability::EvalResult, mir::interpret::ConstValue};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{FieldIdx, Integer, Size, VariantIdx, FIRST_VARIANT};
|
||||
@ -142,13 +142,6 @@ fn from_constant<'tcx>(
|
||||
let ty = value.ty();
|
||||
if let Some((target_size, bias)) = Self::integral_size_and_signed_bias(tcx, ty) {
|
||||
let val = match value {
|
||||
mir::ConstantKind::Val(ConstValue::Scalar(scalar), _) => {
|
||||
// For this specific pattern we can skip a lot of effort and go
|
||||
// straight to the result, after doing a bit of checking. (We
|
||||
// could remove this branch and just fall through, which
|
||||
// is more general but much slower.)
|
||||
scalar.to_bits_or_ptr_internal(target_size).unwrap().left()
|
||||
}
|
||||
mir::ConstantKind::Ty(c) if let ty::ConstKind::Value(valtree) = c.kind() => {
|
||||
valtree.unwrap_leaf().to_bits(target_size).ok()
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user