mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Remove unused types UnusedGenericParams and FiniteBitSet
These types have been unused since polymorphization was removed in <https://github.com/rust-lang/rust/pull/133883>.
This commit is contained in:
@@ -555,15 +555,6 @@ fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, CTX> HashStable<CTX> for bit_set::FiniteBitSet<T>
|
||||
where
|
||||
T: HashStable<CTX> + bit_set::FiniteBitSetTy,
|
||||
{
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
self.0.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl_stable_traits_for_trivial_type!(::std::ffi::OsStr);
|
||||
|
||||
impl_stable_traits_for_trivial_type!(::std::path::Path);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::marker::PhantomData;
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
use std::mem;
|
||||
use std::ops::{BitAnd, BitAndAssign, BitOrAssign, Bound, Not, Range, RangeBounds, Shl};
|
||||
use std::ops::{Bound, Range, RangeBounds};
|
||||
use std::rc::Rc;
|
||||
use std::{fmt, iter, slice};
|
||||
|
||||
@@ -1736,114 +1736,3 @@ fn max_bit(word: Word) -> usize {
|
||||
fn count_ones(words: &[Word]) -> usize {
|
||||
words.iter().map(|word| word.count_ones() as usize).sum()
|
||||
}
|
||||
|
||||
/// Integral type used to represent the bit set.
|
||||
pub trait FiniteBitSetTy:
|
||||
BitAnd<Output = Self>
|
||||
+ BitAndAssign
|
||||
+ BitOrAssign
|
||||
+ Clone
|
||||
+ Copy
|
||||
+ Shl
|
||||
+ Not<Output = Self>
|
||||
+ PartialEq
|
||||
+ Sized
|
||||
{
|
||||
/// Size of the domain representable by this type, e.g. 64 for `u64`.
|
||||
const DOMAIN_SIZE: u32;
|
||||
|
||||
/// Value which represents the `FiniteBitSet` having every bit set.
|
||||
const FILLED: Self;
|
||||
/// Value which represents the `FiniteBitSet` having no bits set.
|
||||
const EMPTY: Self;
|
||||
|
||||
/// Value for one as the integral type.
|
||||
const ONE: Self;
|
||||
/// Value for zero as the integral type.
|
||||
const ZERO: Self;
|
||||
|
||||
/// Perform a checked left shift on the integral type.
|
||||
fn checked_shl(self, rhs: u32) -> Option<Self>;
|
||||
/// Perform a checked right shift on the integral type.
|
||||
fn checked_shr(self, rhs: u32) -> Option<Self>;
|
||||
}
|
||||
|
||||
impl FiniteBitSetTy for u32 {
|
||||
const DOMAIN_SIZE: u32 = 32;
|
||||
|
||||
const FILLED: Self = Self::MAX;
|
||||
const EMPTY: Self = Self::MIN;
|
||||
|
||||
const ONE: Self = 1u32;
|
||||
const ZERO: Self = 0u32;
|
||||
|
||||
fn checked_shl(self, rhs: u32) -> Option<Self> {
|
||||
self.checked_shl(rhs)
|
||||
}
|
||||
|
||||
fn checked_shr(self, rhs: u32) -> Option<Self> {
|
||||
self.checked_shr(rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for FiniteBitSet<u32> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:032b}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// A fixed-sized bitset type represented by an integer type. Indices outwith than the range
|
||||
/// representable by `T` are considered set.
|
||||
#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext))]
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct FiniteBitSet<T: FiniteBitSetTy>(pub T);
|
||||
|
||||
impl<T: FiniteBitSetTy> FiniteBitSet<T> {
|
||||
/// Creates a new, empty bitset.
|
||||
pub fn new_empty() -> Self {
|
||||
Self(T::EMPTY)
|
||||
}
|
||||
|
||||
/// Sets the `index`th bit.
|
||||
pub fn set(&mut self, index: u32) {
|
||||
self.0 |= T::ONE.checked_shl(index).unwrap_or(T::ZERO);
|
||||
}
|
||||
|
||||
/// Unsets the `index`th bit.
|
||||
pub fn clear(&mut self, index: u32) {
|
||||
self.0 &= !T::ONE.checked_shl(index).unwrap_or(T::ZERO);
|
||||
}
|
||||
|
||||
/// Sets the `i`th to `j`th bits.
|
||||
pub fn set_range(&mut self, range: Range<u32>) {
|
||||
let bits = T::FILLED
|
||||
.checked_shl(range.end - range.start)
|
||||
.unwrap_or(T::ZERO)
|
||||
.not()
|
||||
.checked_shl(range.start)
|
||||
.unwrap_or(T::ZERO);
|
||||
self.0 |= bits;
|
||||
}
|
||||
|
||||
/// Is the set empty?
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0 == T::EMPTY
|
||||
}
|
||||
|
||||
/// Returns the domain size of the bitset.
|
||||
pub fn within_domain(&self, index: u32) -> bool {
|
||||
index < T::DOMAIN_SIZE
|
||||
}
|
||||
|
||||
/// Returns if the `index`th bit is set.
|
||||
pub fn contains(&self, index: u32) -> Option<bool> {
|
||||
self.within_domain(index)
|
||||
.then(|| ((self.0.checked_shr(index).unwrap_or(T::ONE)) & T::ONE) == T::ONE)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: FiniteBitSetTy> Default for FiniteBitSet<T> {
|
||||
fn default() -> Self {
|
||||
Self::new_empty()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::ConstValue;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, UnusedGenericParams};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_serialize::opaque::FileEncoder;
|
||||
use rustc_session::config::{SymbolManglingVersion, TargetModifier};
|
||||
|
||||
@@ -44,16 +44,6 @@ fn is_default(&self) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl IsDefault for UnusedGenericParams {
|
||||
fn is_default(&self) -> bool {
|
||||
// UnusedGenericParams encodes the *un*usedness as a bitset.
|
||||
// This means that 0 corresponds to all bits used, which is indeed the default.
|
||||
let is_default = self.bits() == 0;
|
||||
debug_assert_eq!(is_default, self.all_used());
|
||||
is_default
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper trait, for encoding to, and decoding from, a fixed number of bytes.
|
||||
/// Used mainly for Lazy positions and lengths.
|
||||
///
|
||||
|
||||
@@ -356,7 +356,6 @@ impl Erasable for $ty {
|
||||
rustc_hir::OwnerId,
|
||||
rustc_hir::Stability,
|
||||
rustc_hir::Upvar,
|
||||
rustc_index::bit_set::FiniteBitSet<u32>,
|
||||
rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs,
|
||||
rustc_middle::middle::dependency_format::Linkage,
|
||||
rustc_middle::middle::exported_symbols::SymbolExportInfo,
|
||||
@@ -383,7 +382,6 @@ impl Erasable for $ty {
|
||||
rustc_middle::ty::Destructor,
|
||||
rustc_middle::ty::fast_reject::SimplifiedType,
|
||||
rustc_middle::ty::ImplPolarity,
|
||||
rustc_middle::ty::UnusedGenericParams,
|
||||
rustc_middle::ty::util::AlwaysRequiresDrop,
|
||||
rustc_middle::ty::Visibility<rustc_span::def_id::DefId>,
|
||||
rustc_middle::middle::codegen_fn_attrs::SanitizerFnAttrs,
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
use rustc_hir::def::{CtorKind, DefKind, Namespace};
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_index::bit_set::FiniteBitSet;
|
||||
use rustc_macros::{Decodable, Encodable, HashStable, Lift, TyDecodable, TyEncodable};
|
||||
use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable};
|
||||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
@@ -941,50 +940,3 @@ fn needs_fn_once_adapter_shim(
|
||||
(ty::ClosureKind::FnMut | ty::ClosureKind::FnOnce, _) => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
// Set bits represent unused generic parameters.
|
||||
// An empty set indicates that all parameters are used.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Decodable, Encodable, HashStable)]
|
||||
pub struct UnusedGenericParams(FiniteBitSet<u32>);
|
||||
|
||||
impl Default for UnusedGenericParams {
|
||||
fn default() -> Self {
|
||||
UnusedGenericParams::new_all_used()
|
||||
}
|
||||
}
|
||||
|
||||
impl UnusedGenericParams {
|
||||
pub fn new_all_unused(amount: u32) -> Self {
|
||||
let mut bitset = FiniteBitSet::new_empty();
|
||||
bitset.set_range(0..amount);
|
||||
Self(bitset)
|
||||
}
|
||||
|
||||
pub fn new_all_used() -> Self {
|
||||
Self(FiniteBitSet::new_empty())
|
||||
}
|
||||
|
||||
pub fn mark_used(&mut self, idx: u32) {
|
||||
self.0.clear(idx);
|
||||
}
|
||||
|
||||
pub fn is_unused(&self, idx: u32) -> bool {
|
||||
self.0.contains(idx).unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn is_used(&self, idx: u32) -> bool {
|
||||
!self.is_unused(idx)
|
||||
}
|
||||
|
||||
pub fn all_used(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
pub fn bits(&self) -> u32 {
|
||||
self.0.0
|
||||
}
|
||||
|
||||
pub fn from_bits(bits: u32) -> UnusedGenericParams {
|
||||
UnusedGenericParams(FiniteBitSet(bits))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,
|
||||
};
|
||||
pub use self::fold::*;
|
||||
pub use self::instance::{Instance, InstanceKind, ReifyReason, UnusedGenericParams};
|
||||
pub use self::instance::{Instance, InstanceKind, ReifyReason};
|
||||
pub use self::list::{List, ListWithCachedTypeInfo};
|
||||
pub use self::opaque_types::OpaqueTypeKey;
|
||||
pub use self::pattern::{Pattern, PatternKind};
|
||||
|
||||
Reference in New Issue
Block a user