mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
rust: pin-init: mark pin_init::zeroed and Zeroable::zeroed as #[inline]
The `pin_init::zeroed` function is a trivial wrapper around
`unsafe { core::mem::zeroed() }`, whereas `Zeroable::zeroed` is a trivial
wrapper around `pin_init::zeroed`. Mark them both as `#[inline]` to avoid
generating unnecessary symbols for them.
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
This commit is contained in:
committed by
Gary Guo
parent
9e813b9abd
commit
6d0795b507
@@ -1557,6 +1557,7 @@ pub unsafe trait Zeroable {
|
||||
/// assert_eq!(point.x, 0);
|
||||
/// assert_eq!(point.y, 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn zeroed() -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
@@ -1603,6 +1604,7 @@ pub fn init_zeroed<T: Zeroable>() -> impl Init<T> {
|
||||
/// assert_eq!(point.x, 0);
|
||||
/// assert_eq!(point.y, 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub const fn zeroed<T: Zeroable>() -> T {
|
||||
// SAFETY:By the type invariants of `Zeroable`, all zeroes is a valid bit pattern for `T`.
|
||||
unsafe { core::mem::zeroed() }
|
||||
|
||||
Reference in New Issue
Block a user