Skip to content

Commit

Permalink
Merge pull request torvalds#492 from nbdd0121/rust
Browse files Browse the repository at this point in the history
rust: remove usage of `const_raw_ptr_deref`
  • Loading branch information
ojeda authored Sep 6, 2021
2 parents 9b7314a + 25ac90d commit 3976bd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
const_fn_trait_bound,
const_mut_refs,
const_panic,
const_raw_ptr_deref,
const_fn_transmute,
const_unreachable_unchecked,
doc_cfg,
ptr_metadata,
Expand Down
8 changes: 1 addition & 7 deletions rust/kernel/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,8 @@ impl CStr {
/// `NUL` byte (or the string will be truncated).
#[inline]
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
// Note: This can be done using pointer deref (which requires
// `const_raw_ptr_deref` to be const) or `transmute` (which requires
// `const_transmute` to be const) or `ptr::from_raw_parts` (which
// requires `ptr_metadata`).
// While none of them are current stable, it is very likely that one of
// them will eventually be.
// SAFETY: Properties of `bytes` guaranteed by the safety precondition.
unsafe { &*(bytes as *const [u8] as *const Self) }
unsafe { core::mem::transmute(bytes) }
}

/// Returns a C pointer to the string.
Expand Down

0 comments on commit 3976bd9

Please sign in to comment.