Skip to content

Commit bc563e4

Browse files
committed
Fix clippy warnings
1 parent dacd12e commit bc563e4

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/error/hosting_result.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::convert::TryFrom;
2-
#[cfg(any(nightly, feature = "nightly"))]
2+
#[cfg(feature = "nightly")]
33
use std::ops::{ControlFlow, FromResidual, Try};
44

55
use crate::bindings;
@@ -116,7 +116,7 @@ impl From<HostingError> for HostingResult {
116116
}
117117
}
118118

119-
#[cfg(any(nightly, feature = "nightly"))]
119+
#[cfg(feature = "nightly")]
120120
impl Try for HostingResult {
121121
type Output = HostingSuccess;
122122
type Residual = HostingError;
@@ -131,7 +131,7 @@ impl Try for HostingResult {
131131
}
132132
}
133133

134-
#[cfg(any(nightly, feature = "nightly"))]
134+
#[cfg(feature = "nightly")]
135135
impl FromResidual for HostingResult {
136136
fn from_residual(r: HostingError) -> Self {
137137
HostingResult(Err(r))

src/nethost.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,20 @@ pub enum LoadHostfxrError {
112112
}
113113

114114
const unsafe fn maybe_uninit_slice_assume_init_ref<T>(slice: &[MaybeUninit<T>]) -> &[T] {
115-
#[cfg(any(nightly, feature = "nightly"))]
115+
#[cfg(feature = "nightly")]
116116
unsafe {
117117
MaybeUninit::slice_assume_init_ref(slice)
118118
}
119-
#[cfg(not(any(nightly, feature = "nightly")))]
119+
#[cfg(not(feature = "nightly"))]
120120
unsafe {
121-
&*(slice as *const [MaybeUninit<T>] as *const [T])
121+
&*(std::ptr::from_ref::<[MaybeUninit<T>]>(slice) as *const [T])
122122
}
123123
}
124124

125125
fn maybe_uninit_uninit_array<T, const LEN: usize>() -> [MaybeUninit<T>; LEN] {
126-
#[cfg(any(nightly, feature = "nightly"))]
126+
#[cfg(feature = "nightly")]
127127
return MaybeUninit::<T>::uninit_array::<LEN>();
128-
#[cfg(not(any(nightly, feature = "nightly")))]
128+
#[cfg(not(feature = "nightly"))]
129129
unsafe {
130130
MaybeUninit::<[MaybeUninit<T>; LEN]>::uninit().assume_init()
131131
}

src/pdcstring/impl/traits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ pub(crate) trait ToStringErrorInner: Debug + Display + Error + Clone {
3636
fn index(&self) -> Option<usize>;
3737
}
3838

39+
#[allow(dead_code)]
3940
pub(crate) trait MissingNulTerminatorInner: Debug + Display + Error + Clone {}

src/pdcstring/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ impl PdCStr {
6767
pub(crate) fn from_inner(inner: &PdCStrInnerImpl) -> &Self {
6868
// Safety:
6969
// Safe because PdCStr has the same layout as PdCStrInnerImpl
70-
unsafe { &*(inner as *const PdCStrInnerImpl as *const PdCStr) }
70+
unsafe { &*(std::ptr::from_ref::<PdCStrInnerImpl>(inner) as *const PdCStr) }
7171
}
7272
#[inline]
7373
pub(crate) fn as_inner(&self) -> &PdCStrInnerImpl {
7474
// Safety:
7575
// Safe because PdCStr has the same layout as PdCStrInnerImpl
76-
unsafe { &*(self as *const PdCStr as *const PdCStrInnerImpl) }
76+
unsafe { &*(std::ptr::from_ref::<PdCStr>(self) as *const PdCStrInnerImpl) }
7777
}
7878

7979
/// Returns a raw pointer to the string.

0 commit comments

Comments
 (0)