Skip to content

Commit

Permalink
proc_macro/bridge: Remove dead code Slice type
Browse files Browse the repository at this point in the history
  • Loading branch information
lf- committed Jul 1, 2021
1 parent 64de497 commit 0b3fedc
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions library/proc_macro/src/bridge/buffer.rs
Expand Up @@ -5,35 +5,6 @@ use std::mem;
use std::ops::{Deref, DerefMut};
use std::slice;

#[repr(C)]
struct Slice<'a, T> {
data: &'a [T; 0],
len: usize,
}

unsafe impl<'a, T: Sync> Sync for Slice<'a, T> {}
unsafe impl<'a, T: Sync> Send for Slice<'a, T> {}

impl<T> Copy for Slice<'a, T> {}
impl<T> Clone for Slice<'a, T> {
fn clone(&self) -> Self {
*self
}
}

impl<T> From<&'a [T]> for Slice<'a, T> {
fn from(xs: &'a [T]) -> Self {
Slice { data: unsafe { &*(xs.as_ptr() as *const [T; 0]) }, len: xs.len() }
}
}

impl<T> Deref for Slice<'a, T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe { slice::from_raw_parts(self.data.as_ptr(), self.len) }
}
}

#[repr(C)]
pub struct Buffer<T: Copy> {
data: *mut T,
Expand Down

0 comments on commit 0b3fedc

Please sign in to comment.