-
Notifications
You must be signed in to change notification settings - Fork 508
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
prost-build 0.8.0 regression: field_attribute
on a oneof field gets added to enum variants
#507
Comments
This was referenced Jul 12, 2021
This was referenced Jul 24, 2021
Guiguiprim
pushed a commit
to Guiguiprim/prost
that referenced
this issue
Aug 27, 2021
Guiguiprim
pushed a commit
to Guiguiprim/prost
that referenced
this issue
Aug 30, 2021
Guiguiprim
pushed a commit
to Guiguiprim/prost
that referenced
this issue
Sep 7, 2021
Guiguiprim
pushed a commit
to Guiguiprim/prost
that referenced
this issue
Sep 8, 2021
LucioFranco
added a commit
that referenced
this issue
Sep 15, 2021
Fixed in #522 |
ajguerrer
pushed a commit
to ajguerrer/prost
that referenced
this issue
Sep 17, 2021
This address tokio-rs#490 tokio-rs#502 tokio-rs#507 Co-authored-by: Guilhem Vallat <guilhem@harfanglab.fr> Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
This issue does not appear to be fixed. It still happens to me in master. |
Is this an example of the same issue: syntax="proto3";
package api;
message Init {
string msg_id = 1;
message SetOs {
enum OS {
OS_UNKNOWN = 0;
OS_WIN = 1;
OS_MAC = 2;
}
OS os_type = 2;
}
oneof Command {
SetOs os_cmd = 3;
}
} when I use the following code ( let mut config = prost_build::Config::new();
config.type_attribute(".", "#[derive(serde::Deserialize, serde::Serialize)]");
config.field_attribute(".api.Init.SetOs", "#[serde(default)]");
config.compile_protos(&["test_enum.proto"], &["../Proto"]) Then the variants of the enum also get attribute pub mod init {
// ...
pub mod set_os {
// ...
#[repr(i32)]
pub enum Os {
#[serde(default)]
Unknown = 0,
#[serde(default)]
Win = 1,
#[serde(default)]
Mac = 2,
}
impl Os { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding field attributes on oneof fields in prost-build 0.8.0 also adds the attributes to the enum variants. In this example, adding
#[serde(flatten)]
toTestMessage.some_field
correctly adds the attribute to theTestMessage.some_field
field of the struct, but also adds the attribute to each enum variant.proto
build.rs
Outputs:
Notice the extra
#[serde(flatten)]
on each variant. This results inunknown serde variant attribute flatten
since serde macro gets wrongly added to the enum variants.The text was updated successfully, but these errors were encountered: