Skip to content

Commit

Permalink
Rollup merge of #83653 - jyn514:unused-sync-code, r=wesleywiser
Browse files Browse the repository at this point in the history
Remove unused code from `rustc_data_structures::sync`

Found using https://github.com/est31/warnalyzer. Follow-up to #83185.

r? `@Zoxc` cc `@oli-obk`
  • Loading branch information
JohnTitor authored Jun 4, 2021
2 parents efc4e37 + 3412957 commit 7564312
Showing 1 changed file with 2 additions and 60 deletions.
62 changes: 2 additions & 60 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,9 @@ 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.
/// It has explicit ordering arguments and is only intended for use with
/// the native atomic types.
/// You should use this type through the `AtomicU64`, `AtomicUsize`, etc, type aliases
/// as it's not intended to be used separately.
#[derive(Debug)]
Expand Down Expand Up @@ -159,22 +119,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),*) => {
Expand Down Expand Up @@ -318,8 +262,6 @@ cfg_if! {

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};

pub use crossbeam_utils::atomic::AtomicCell;

pub use std::sync::Arc as Lrc;
pub use std::sync::Weak as Weak;

Expand Down

0 comments on commit 7564312

Please sign in to comment.