Rollup merge of #66117 - olegnn:fixed_linked_list_marker, r=RalfJung
Fixed PhantomData markers in Arc and Rc Include owned internal structs in `PhantomData` markers in `Arc` (`PhantomData<T>` => `PhantomData<ArcInner<T>>`) and `Rc` (`PhantomData<T>` => `PhantomData<RcBox<T>>`).
This commit is contained in:
commit
a2b4ad439c
4 changed files with 10 additions and 5 deletions
|
@ -90,7 +90,7 @@ impl<T> Clone for Iter<'_, T> {
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct IterMut<'a, T: 'a> {
|
pub struct IterMut<'a, T: 'a> {
|
||||||
// We do *not* exclusively own the entire list here, references to node's `element`
|
// We do *not* exclusively own the entire list here, references to node's `element`
|
||||||
// have been handed out by the iterator! So be careful when using this; the methods
|
// have been handed out by the iterator! So be careful when using this; the methods
|
||||||
// called must be aware that there can be aliasing pointers to `element`.
|
// called must be aware that there can be aliasing pointers to `element`.
|
||||||
list: &'a mut LinkedList<T>,
|
list: &'a mut LinkedList<T>,
|
||||||
head: Option<NonNull<Node<T>>>,
|
head: Option<NonNull<Node<T>>>,
|
||||||
|
|
|
@ -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")]
|
||||||
|
|
|
@ -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")]
|
||||||
|
|
|
@ -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> {
|
||||||
|
@ -151,7 +153,10 @@
|
||||||
//! impl<T: ?Sized> Clone for Rc<T> {
|
//! impl<T: ?Sized> Clone for Rc<T> {
|
||||||
//! fn clone(&self) -> Rc<T> {
|
//! fn clone(&self) -> Rc<T> {
|
||||||
//! self.inc_strong();
|
//! self.inc_strong();
|
||||||
//! Rc { ptr: self.ptr }
|
//! Rc {
|
||||||
|
//! ptr: self.ptr,
|
||||||
|
//! phantom: PhantomData,
|
||||||
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue