1
Fork 0

Remove (lots of) dead code

Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
This commit is contained in:
Joshua Nelson 2021-03-16 01:50:34 -04:00
parent 785aeac521
commit 441dc3640a
74 changed files with 60 additions and 1298 deletions

View file

@ -43,46 +43,6 @@ cfg_if! {
use std::ops::Add;
use std::panic::{resume_unwind, catch_unwind, AssertUnwindSafe};
/// This is a single threaded variant of AtomicCell provided by crossbeam.
/// Unlike `Atomic` this is intended for all `Copy` types,
/// but it lacks the explicit ordering arguments.
#[derive(Debug)]
pub struct AtomicCell<T: Copy>(Cell<T>);
impl<T: Copy> AtomicCell<T> {
#[inline]
pub fn new(v: T) -> Self {
AtomicCell(Cell::new(v))
}
#[inline]
pub fn get_mut(&mut self) -> &mut T {
self.0.get_mut()
}
}
impl<T: Copy> AtomicCell<T> {
#[inline]
pub fn into_inner(self) -> T {
self.0.into_inner()
}
#[inline]
pub fn load(&self) -> T {
self.0.get()
}
#[inline]
pub fn store(&self, val: T) {
self.0.set(val)
}
#[inline]
pub fn swap(&self, val: T) -> T {
self.0.replace(val)
}
}
/// This is a single threaded variant of `AtomicU64`, `AtomicUsize`, etc.
/// It differs from `AtomicCell` in that it has explicit ordering arguments
/// and is only intended for use with the native atomic types.
@ -99,11 +59,6 @@ cfg_if! {
}
impl<T: Copy> Atomic<T> {
#[inline]
pub fn into_inner(self) -> T {
self.0.into_inner()
}
#[inline]
pub fn load(&self, _: Ordering) -> T {
self.0.get()
@ -113,11 +68,6 @@ cfg_if! {
pub fn store(&self, val: T, _: Ordering) {
self.0.set(val)
}
#[inline]
pub fn swap(&self, val: T, _: Ordering) -> T {
self.0.replace(val)
}
}
impl<T: Copy + PartialEq> Atomic<T> {
@ -159,22 +109,6 @@ cfg_if! {
(oper_a(), oper_b())
}
pub struct SerialScope;
impl SerialScope {
pub fn spawn<F>(&self, f: F)
where F: FnOnce(&SerialScope)
{
f(self)
}
}
pub fn scope<F, R>(f: F) -> R
where F: FnOnce(&SerialScope) -> R
{
f(&SerialScope)
}
#[macro_export]
macro_rules! parallel {
($($blocks:tt),*) => {
@ -246,12 +180,6 @@ cfg_if! {
pub fn new<F: FnMut(usize) -> T>(mut f: F) -> WorkerLocal<T> {
WorkerLocal(OneThread::new(f(0)))
}
/// Returns the worker-local value for each thread
#[inline]
pub fn into_inner(self) -> Vec<T> {
vec![OneThread::into_inner(self.0)]
}
}
impl<T> Deref for WorkerLocal<T> {
@ -279,16 +207,6 @@ cfg_if! {
self.0
}
#[inline(always)]
pub fn get_mut(&mut self) -> &mut T {
&mut self.0
}
#[inline(always)]
pub fn lock(&self) -> &T {
&self.0
}
#[inline(always)]
pub fn lock_mut(&mut self) -> &mut T {
&mut self.0
@ -521,16 +439,6 @@ impl<T> RwLock<T> {
RwLock(InnerRwLock::new(inner))
}
#[inline(always)]
pub fn into_inner(self) -> T {
self.0.into_inner()
}
#[inline(always)]
pub fn get_mut(&mut self) -> &mut T {
self.0.get_mut()
}
#[cfg(not(parallel_compiler))]
#[inline(always)]
pub fn read(&self) -> ReadGuard<'_, T> {
@ -547,11 +455,6 @@ impl<T> RwLock<T> {
}
}
#[inline(always)]
pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R {
f(&*self.read())
}
#[cfg(not(parallel_compiler))]
#[inline(always)]
pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
@ -580,11 +483,6 @@ impl<T> RwLock<T> {
}
}
#[inline(always)]
pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
f(&mut *self.write())
}
#[inline(always)]
pub fn borrow(&self) -> ReadGuard<'_, T> {
self.read()
@ -633,12 +531,6 @@ impl<T> OneThread<T> {
inner,
}
}
#[inline(always)]
pub fn into_inner(value: Self) -> T {
value.check();
value.inner
}
}
impl<T> Deref for OneThread<T> {

View file

@ -42,18 +42,9 @@ where
pub fn pointer_ref(&self) -> &P::Target {
self.raw.pointer_ref()
}
pub fn pointer_mut(&mut self) -> &mut P::Target
where
P: std::ops::DerefMut,
{
self.raw.pointer_mut()
}
pub fn tag(&self) -> T {
self.raw.tag()
}
pub fn set_tag(&mut self, tag: T) {
self.raw.set_tag(tag);
}
}
impl<P, T, const COMPARE_PACKED: bool> std::ops::Deref for TaggedPtr<P, T, COMPARE_PACKED>

View file

@ -41,10 +41,4 @@ impl<T: Idx> WorkQueue<T> {
None
}
}
/// Returns `true` if nothing is enqueued.
#[inline]
pub fn is_empty(&self) -> bool {
self.deque.is_empty()
}
}