Remove unused code from rustc_middle
This commit is contained in:
@@ -56,15 +56,6 @@ impl<'tcx> ConstValue<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_to_str_slice(&self) -> Option<&'tcx str> {
|
||||
if let ConstValue::Slice { data, start, end } = *self {
|
||||
std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end))
|
||||
.ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_to_bits(&self, size: Size) -> Option<u128> {
|
||||
self.try_to_scalar()?.to_bits(size).ok()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html
|
||||
|
||||
use crate::mir::coverage::{CodeRegion, CoverageKind};
|
||||
use crate::mir::interpret::{Allocation, ConstValue, GlobalAlloc, Scalar};
|
||||
use crate::mir::interpret::{Allocation, GlobalAlloc, Scalar};
|
||||
use crate::mir::visit::MirVisitable;
|
||||
use crate::ty::adjustment::PointerCast;
|
||||
use crate::ty::codec::{TyDecoder, TyEncoder};
|
||||
@@ -460,17 +460,6 @@ impl<'tcx> Body<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if `sub` is a sub scope of `sup`
|
||||
pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
|
||||
while sub != sup {
|
||||
match self.source_scopes[sub].parent_scope {
|
||||
None => return false,
|
||||
Some(p) => sub = p,
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Returns the return type; it always return first element from `local_decls` array.
|
||||
#[inline]
|
||||
pub fn return_ty(&self) -> Ty<'tcx> {
|
||||
@@ -1978,45 +1967,6 @@ impl<'tcx> Operand<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Convenience helper to make a `Scalar` from the given `Operand`, assuming that `Operand`
|
||||
/// wraps a constant literal value. Panics if this is not the case.
|
||||
pub fn scalar_from_const(operand: &Operand<'tcx>) -> Scalar {
|
||||
match operand {
|
||||
Operand::Constant(constant) => match constant.literal.val.try_to_scalar() {
|
||||
Some(scalar) => scalar,
|
||||
_ => panic!("{:?}: Scalar value expected", constant.literal.val),
|
||||
},
|
||||
_ => panic!("{:?}: Constant expected", operand),
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience helper to make a literal-like constant from a given `&str` slice.
|
||||
/// Since this is used to synthesize MIR, assumes `user_ty` is None.
|
||||
pub fn const_from_str(tcx: TyCtxt<'tcx>, val: &str, span: Span) -> Operand<'tcx> {
|
||||
let tcx = tcx;
|
||||
let allocation = Allocation::from_byte_aligned_bytes(val.as_bytes());
|
||||
let allocation = tcx.intern_const_alloc(allocation);
|
||||
let const_val = ConstValue::Slice { data: allocation, start: 0, end: val.len() };
|
||||
let ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, tcx.types.str_);
|
||||
Operand::Constant(box Constant {
|
||||
span,
|
||||
user_ty: None,
|
||||
literal: ty::Const::from_value(tcx, const_val, ty),
|
||||
})
|
||||
}
|
||||
|
||||
/// Convenience helper to make a `ConstValue` from the given `Operand`, assuming that `Operand`
|
||||
/// wraps a constant value (such as a `&str` slice). Panics if this is not the case.
|
||||
pub fn value_from_const(operand: &Operand<'tcx>) -> ConstValue<'tcx> {
|
||||
match operand {
|
||||
Operand::Constant(constant) => match constant.literal.val.try_to_value() {
|
||||
Some(const_value) => const_value,
|
||||
_ => panic!("{:?}: ConstValue expected", constant.literal.val),
|
||||
},
|
||||
_ => panic!("{:?}: Constant expected", operand),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_copy(&self) -> Self {
|
||||
match *self {
|
||||
Operand::Copy(_) | Operand::Constant(_) => self.clone(),
|
||||
@@ -2413,10 +2363,6 @@ impl<'tcx> UserTypeProjections {
|
||||
self.contents.is_empty()
|
||||
}
|
||||
|
||||
pub fn from_projections(projs: impl Iterator<Item = (UserTypeProjection, Span)>) -> Self {
|
||||
UserTypeProjections { contents: projs.collect() }
|
||||
}
|
||||
|
||||
pub fn projections_and_spans(
|
||||
&self,
|
||||
) -> impl Iterator<Item = &(UserTypeProjection, Span)> + ExactSizeIterator {
|
||||
|
||||
@@ -413,18 +413,6 @@ pub struct CoverageInfo {
|
||||
/// For more information on why this is needed, consider looking
|
||||
/// at the docs for `WithOptConstParam` itself.
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
#[inline]
|
||||
pub fn mir_borrowck_opt_const_arg(
|
||||
self,
|
||||
def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> &'tcx BorrowCheckResult<'tcx> {
|
||||
if let Some(param_did) = def.const_param_did {
|
||||
self.mir_borrowck_const_arg((def.did, param_did))
|
||||
} else {
|
||||
self.mir_borrowck(def.did)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mir_const_qualif_opt_const_arg(
|
||||
self,
|
||||
|
||||
@@ -1186,16 +1186,6 @@ impl PlaceContext {
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns `true` if this place context represents a storage live marker.
|
||||
pub fn is_storage_live_marker(&self) -> bool {
|
||||
matches!(self, PlaceContext::NonUse(NonUseContext::StorageLive))
|
||||
}
|
||||
|
||||
/// Returns `true` if this place context represents a storage dead marker.
|
||||
pub fn is_storage_dead_marker(&self) -> bool {
|
||||
matches!(self, PlaceContext::NonUse(NonUseContext::StorageDead))
|
||||
}
|
||||
|
||||
/// Returns `true` if this place context represents a use that potentially changes the value.
|
||||
pub fn is_mutating_use(&self) -> bool {
|
||||
matches!(self, PlaceContext::MutatingUse(..))
|
||||
|
||||
Reference in New Issue
Block a user