Skip to content

Commit b54a00a

Browse files
committed
allow unused warnings related to rustc_layout_scalar_valid_range_start
1 parent dc25c80 commit b54a00a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/libcore/num/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st
4747
#[stable(feature = "nonzero", since = "1.28.0")]
4848
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4949
#[repr(transparent)]
50+
// FIXME: the rustc_layout_scalar_valid_range_start attr is marked as unused
51+
#[cfg_attr(stage0, allow(unused_attributes))]
5052
#[rustc_layout_scalar_valid_range_start(1)]
5153
pub struct $Ty($Int);
5254
}
@@ -68,6 +70,8 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st
6870
#[inline]
6971
pub fn new(n: $Int) -> Option<Self> {
7072
if n != 0 {
73+
// FIXME: this unsafe block is actually needed
74+
#[cfg_attr(stage0, allow(unused_unsafe))]
7175
Some(unsafe { $Ty(n) })
7276
} else {
7377
None

src/libcore/ptr.rs

+16
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,8 @@ impl<T: ?Sized> PartialOrd for *mut T {
27182718
(if you also use #[may_dangle]), Send, and/or Sync")]
27192719
#[doc(hidden)]
27202720
#[repr(transparent)]
2721+
// FIXME: the rustc_layout_scalar_valid_range_start attr is marked as unused
2722+
#[cfg_attr(stage0, allow(unused_attributes))]
27212723
#[rustc_layout_scalar_valid_range_start(1)]
27222724
pub struct Unique<T: ?Sized> {
27232725
pointer: *const T,
@@ -2783,6 +2785,8 @@ impl<T: ?Sized> Unique<T> {
27832785
/// Creates a new `Unique` if `ptr` is non-null.
27842786
pub fn new(ptr: *mut T) -> Option<Self> {
27852787
if !ptr.is_null() {
2788+
// FIXME: this unsafe block is actually needed
2789+
#[cfg_attr(stage0, allow(unused_unsafe))]
27862790
Some(unsafe { Unique { pointer: ptr as _, _marker: PhantomData } })
27872791
} else {
27882792
None
@@ -2839,20 +2843,26 @@ impl<T: ?Sized> fmt::Pointer for Unique<T> {
28392843
#[unstable(feature = "ptr_internals", issue = "0")]
28402844
impl<'a, T: ?Sized> From<&'a mut T> for Unique<T> {
28412845
fn from(reference: &'a mut T) -> Self {
2846+
// FIXME: this unsafe block is actually needed
2847+
#[cfg_attr(stage0, allow(unused_unsafe))]
28422848
unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } }
28432849
}
28442850
}
28452851

28462852
#[unstable(feature = "ptr_internals", issue = "0")]
28472853
impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
28482854
fn from(reference: &'a T) -> Self {
2855+
// FIXME: this unsafe block is actually needed
2856+
#[cfg_attr(stage0, allow(unused_unsafe))]
28492857
unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } }
28502858
}
28512859
}
28522860

28532861
#[unstable(feature = "ptr_internals", issue = "0")]
28542862
impl<'a, T: ?Sized> From<NonNull<T>> for Unique<T> {
28552863
fn from(p: NonNull<T>) -> Self {
2864+
// FIXME: this unsafe block is actually needed
2865+
#[cfg_attr(stage0, allow(unused_unsafe))]
28562866
unsafe { Unique { pointer: p.pointer, _marker: PhantomData } }
28572867
}
28582868
}
@@ -3042,6 +3052,8 @@ impl<T: ?Sized> hash::Hash for NonNull<T> {
30423052
impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
30433053
#[inline]
30443054
fn from(unique: Unique<T>) -> Self {
3055+
// FIXME: this unsafe block is actually needed
3056+
#[cfg_attr(stage0, allow(unused_unsafe))]
30453057
unsafe { NonNull { pointer: unique.pointer } }
30463058
}
30473059
}
@@ -3050,6 +3062,8 @@ impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
30503062
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
30513063
#[inline]
30523064
fn from(reference: &'a mut T) -> Self {
3065+
// FIXME: this unsafe block is actually needed
3066+
#[cfg_attr(stage0, allow(unused_unsafe))]
30533067
unsafe { NonNull { pointer: reference as *mut T } }
30543068
}
30553069
}
@@ -3058,6 +3072,8 @@ impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
30583072
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
30593073
#[inline]
30603074
fn from(reference: &'a T) -> Self {
3075+
// FIXME: this unsafe block is actually needed
3076+
#[cfg_attr(stage0, allow(unused_unsafe))]
30613077
unsafe { NonNull { pointer: reference as *const T } }
30623078
}
30633079
}

0 commit comments

Comments
 (0)