Add `unsafe` keyword to unsafe block in rust code (#18264)

Closes #18264

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/18264 from tempoz:tempoz-fix-unsafe-block-rust aca540fac9
PiperOrigin-RevId: 676912529
pull/18456/head
Zoey Greer 5 months ago committed by Copybara-Service
parent ac29f8c0cd
commit 3bc5991d11
  1. 21
      src/google/protobuf/compiler/rust/message.cc

@ -285,21 +285,36 @@ void UpbGeneratedMessageTraitImpls(Context& ctx, const Descriptor& msg) {
unsafe impl $pbr$::AssociatedMiniTable for $Msg$ {
#[inline(always)]
fn mini_table() -> *const $pbr$::upb_MiniTable {
$std$::ptr::addr_of!($minitable$)
// This is unsafe only for Rust 1.80 and below and thus can be dropped
// once our MSRV is 1.81+
#[allow(unused_unsafe)]
unsafe {
$std$::ptr::addr_of!($minitable$)
}
}
}
unsafe impl $pbr$::AssociatedMiniTable for $Msg$View<'_> {
#[inline(always)]
fn mini_table() -> *const $pbr$::upb_MiniTable {
$std$::ptr::addr_of!($minitable$)
// This is unsafe only for Rust 1.80 and below and thus can be dropped
// once our MSRV is 1.81+
#[allow(unused_unsafe)]
unsafe {
$std$::ptr::addr_of!($minitable$)
}
}
}
unsafe impl $pbr$::AssociatedMiniTable for $Msg$Mut<'_> {
#[inline(always)]
fn mini_table() -> *const $pbr$::upb_MiniTable {
$std$::ptr::addr_of!($minitable$)
// This is unsafe only for Rust 1.80 and below and thus can be dropped
// once our MSRV is 1.81+
#[allow(unused_unsafe)]
unsafe {
$std$::ptr::addr_of!($minitable$)
}
}
}
)rs");

Loading…
Cancel
Save