diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index a44a4b94f1..65c176bc3d 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -875,12 +875,15 @@ void GenerateRs(Context& ctx, const Descriptor& msg) { } // SAFETY: - // - `$Msg$` does not provide shared mutation with its arena. - // - `$Msg$Mut` is not `Send`, and so even in the presence of mutator - // splitting, synchronous access of an arena that would conflict with - // field access is impossible. + // - `$Msg$` is `Sync` because it does not implement interior mutability. + // Neither does `$Msg$Mut`. unsafe impl Sync for $Msg$ {} + // SAFETY: + // - `$Msg$` is `Send` because it uniquely owns its arena and does + // not use thread-local data. + unsafe impl Send for $Msg$ {} + impl $pb$::Proxied for $Msg$ { type View<'msg> = $Msg$View<'msg>; type Mut<'msg> = $Msg$Mut<'msg>; @@ -912,12 +915,12 @@ void GenerateRs(Context& ctx, const Descriptor& msg) { } // SAFETY: - // - `$Msg$View` does not perform any mutation. - // - While a `$Msg$View` exists, a `$Msg$Mut` can't exist to mutate - // the arena that would conflict with field access. - // - `$Msg$Mut` is not `Send`, and so even in the presence of mutator - // splitting, synchronous access of an arena is impossible. + // - `$Msg$View` is `Sync` because it does not support mutation. unsafe impl Sync for $Msg$View<'_> {} + + // SAFETY: + // - `$Msg$View` is `Send` because while its alive a `$Msg$Mut` cannot. + // - `$Msg$View` does not use thread-local data. unsafe impl Send for $Msg$View<'_> {} impl<'msg> $pb$::ViewProxy<'msg> for $Msg$View<'msg> {