Skip to content

Commit 146871e

Browse files
committed
chore: revert can_message_derive_copy behavior
Avoid behavioral changes in the Context refactoring.
1 parent 01854ba commit 146871e

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

prost-build/src/code_generator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,8 @@ impl<'a, 'b> CodeGenerator<'a, 'b> {
593593
self.push_indent();
594594

595595
let can_oneof_derive_copy = oneof.fields.iter().all(|field| {
596-
self.context.can_oneof_field_derive_copy(
597-
fq_message_name,
598-
oneof.descriptor.name(),
599-
&field.descriptor,
600-
)
596+
self.context
597+
.can_field_derive_copy(fq_message_name, &field.descriptor)
601598
});
602599
self.buf.push_str(&format!(
603600
"#[derive(Clone, {}PartialEq, {}::Oneof)]\n",

prost-build/src/context.rs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,33 +181,14 @@ impl<'a> Context<'a> {
181181
.unwrap()
182182
.field
183183
.iter()
184-
.all(|field| self.can_message_field_derive_copy(fq_message_name, field))
184+
.all(|field| self.can_field_derive_copy(fq_message_name, field))
185185
}
186186

187187
/// Returns `true` if the type of this message field allows deriving the Copy trait.
188-
pub fn can_message_field_derive_copy(
188+
pub fn can_field_derive_copy(
189189
&self,
190190
fq_message_name: &str,
191191
field: &FieldDescriptorProto,
192-
) -> bool {
193-
self.can_field_derive_copy_impl(fq_message_name, None, field)
194-
}
195-
196-
/// Returns `true` if the type of this field in a oneof allows deriving the Copy trait.
197-
pub fn can_oneof_field_derive_copy(
198-
&self,
199-
fq_message_name: &str,
200-
oneof_name: &str,
201-
field: &FieldDescriptorProto,
202-
) -> bool {
203-
self.can_field_derive_copy_impl(fq_message_name, Some(oneof_name), field)
204-
}
205-
206-
fn can_field_derive_copy_impl(
207-
&self,
208-
fq_message_name: &str,
209-
oneof: Option<&str>,
210-
field: &FieldDescriptorProto,
211192
) -> bool {
212193
assert_eq!(".", &fq_message_name[..1]);
213194

@@ -222,14 +203,10 @@ impl<'a> Context<'a> {
222203
{
223204
return false;
224205
}
225-
let config_path = match oneof {
226-
None => Cow::Borrowed(fq_message_name),
227-
Some(oneof_name) => Cow::Owned(format!("{fq_message_name}.{oneof_name}")),
228-
};
229206
if self
230207
.config
231208
.boxed
232-
.get_first_field(&config_path, field.name())
209+
.get_first_field(fq_message_name, field.name())
233210
.is_some()
234211
{
235212
false

0 commit comments

Comments
 (0)