diff --git a/src/google/protobuf/compiler/rust/generator.cc b/src/google/protobuf/compiler/rust/generator.cc index a659124bb9..02a92a6dc7 100644 --- a/src/google/protobuf/compiler/rust/generator.cc +++ b/src/google/protobuf/compiler/rust/generator.cc @@ -238,6 +238,7 @@ bool RustGenerator::Generate(const FileDescriptor* file_desc, {"pbi", "::__pb::__internal"}, {"pbr", "::__pb::__runtime"}, {"NonNull", "::__std::ptr::NonNull"}, + {"Phantom", "::__std::marker::PhantomData"}, }); file.Emit({{"kernel", KernelRsName(file.opts().kernel)}}, R"rs( diff --git a/src/google/protobuf/compiler/rust/message.cc b/src/google/protobuf/compiler/rust/message.cc index 24bbd88c06..2cd69f4940 100644 --- a/src/google/protobuf/compiler/rust/message.cc +++ b/src/google/protobuf/compiler/rust/message.cc @@ -303,7 +303,7 @@ void MessageGenerator::GenerateRs(Context msg) { #[derive(Debug, Copy, Clone)] pub struct $Msg$View<'a> { _msg: $pbi$::RawMessage, - _phantom: std::marker::PhantomData<&'a ()>, + _phantom: $Phantom$<&'a ()>, } impl<'a> $pb$::ViewProxy<'a> for $Msg$View<'a> { @@ -323,7 +323,7 @@ void MessageGenerator::GenerateRs(Context msg) { #[derive(Debug)] pub struct $Msg$Mut<'a> { - _phantom: std::marker::PhantomData<&'a mut ()>, + _phantom: $Phantom$<&'a mut ()>, } impl<'a> $pb$::MutProxy<'a> for $Msg$Mut<'a> {