Skip to content

Don't crash when extern type used as field #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions prost-build/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ impl<'a> Context<'a> {
assert_eq!(".", &fq_message_name[..1]);
self.message_graph
.get_message(fq_message_name)
.unwrap()
.field
.iter()
.all(|field| self.can_field_derive_copy(fq_message_name, field))
.map(|descriptor| {
descriptor
.field
.iter()
.all(|field| self.can_field_derive_copy(fq_message_name, field))
})
.unwrap_or_default()
}

/// Returns `true` if the type of this message field allows deriving the Copy trait.
Expand Down Expand Up @@ -233,10 +236,15 @@ impl<'a> Context<'a> {
pub fn can_message_derive_eq(&self, fq_message_name: &str) -> bool {
assert_eq!(".", &fq_message_name[..1]);

let msg = self.message_graph.get_message(fq_message_name).unwrap();
msg.field
.iter()
.all(|field| self.can_field_derive_eq(fq_message_name, field))
self.message_graph
.get_message(fq_message_name)
.map(|descriptor| {
descriptor
.field
.iter()
.all(|field| self.can_field_derive_eq(fq_message_name, field))
})
.unwrap_or_default()
}

/// Returns `true` if the type of this field allows deriving the Eq trait.
Expand Down
Loading