1
Fork 0

Reverted PhantomData in LinkedList, fixed PhantomData markers in Rc and Arc

This commit is contained in:
Oleg Nosov 2019-11-05 23:34:54 +03:00
parent 3a54ab78ef
commit 45f281d461
No known key found for this signature in database
GPG key ID: DE90B83800644E24
4 changed files with 7 additions and 5 deletions

View file

@ -39,7 +39,7 @@ pub struct LinkedList<T> {
head: Option<NonNull<Node<T>>>, head: Option<NonNull<Node<T>>>,
tail: Option<NonNull<Node<T>>>, tail: Option<NonNull<Node<T>>>,
len: usize, len: usize,
marker: PhantomData<T>, marker: PhantomData<Box<Node<T>>>,
} }
struct Node<T> { struct Node<T> {
@ -60,7 +60,7 @@ pub struct Iter<'a, T: 'a> {
head: Option<NonNull<Node<T>>>, head: Option<NonNull<Node<T>>>,
tail: Option<NonNull<Node<T>>>, tail: Option<NonNull<Node<T>>>,
len: usize, len: usize,
marker: PhantomData<&'a T>, marker: PhantomData<&'a Node<T>>,
} }
#[stable(feature = "collection_debug", since = "1.17.0")] #[stable(feature = "collection_debug", since = "1.17.0")]

View file

@ -280,7 +280,7 @@ struct RcBox<T: ?Sized> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct Rc<T: ?Sized> { pub struct Rc<T: ?Sized> {
ptr: NonNull<RcBox<T>>, ptr: NonNull<RcBox<T>>,
phantom: PhantomData<T>, phantom: PhantomData<RcBox<T>>,
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]

View file

@ -195,7 +195,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct Arc<T: ?Sized> { pub struct Arc<T: ?Sized> {
ptr: NonNull<ArcInner<T>>, ptr: NonNull<ArcInner<T>>,
phantom: PhantomData<T>, phantom: PhantomData<ArcInner<T>>,
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]

View file

@ -137,9 +137,11 @@
//! use std::cell::Cell; //! use std::cell::Cell;
//! use std::ptr::NonNull; //! use std::ptr::NonNull;
//! use std::intrinsics::abort; //! use std::intrinsics::abort;
//! use std::marker::PhantomData;
//! //!
//! struct Rc<T: ?Sized> { //! struct Rc<T: ?Sized> {
//! ptr: NonNull<RcBox<T>> //! ptr: NonNull<RcBox<T>>,
//! phantom: PhantomData<RcBox<T>>,
//! } //! }
//! //!
//! struct RcBox<T: ?Sized> { //! struct RcBox<T: ?Sized> {