Skip to content
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

Attribute configuration no longer allows multiple attributes per pattern #490

Closed
cab opened this issue Jun 21, 2021 · 2 comments
Closed

Comments

@cab
Copy link
Contributor

cab commented Jun 21, 2021

The type_attributes, field_attributes, etc methods are described as cumulative, but after this change there can only be one attribute per path.

It's not clear to me if this new behavior is the correct behavior or if the old behavior was unintentionally allowing this.

I think this is a regression from 79f0dfd. Previously, multiple values could exist with the same matcher, but now only one entry can exist in the PathMap's matchers hashmap.

Example

.type_attributes(".", "[derive(::serde::Serialize)]")
.type_attributes(".", "[serde(rename = \"camelCase\")]")

Before the regression (e.g. on 0.7), this would output

#[derive(::serde::Serialize)]
#[serde(rename = "camelCase")]
struct MyProto {}

After the regression, this outputs

#[serde(rename = "camelCase")]
struct MyProto {}
@cab
Copy link
Contributor Author

cab commented Jun 21, 2021

if this is a regression, one possible fix might be making Config#type_attributes a PathMap<Vec<String>> and then adding something like this to PathMap:

pub(crate) fn extend<A>(&mut self, matcher: String, value: T) where T: Extend<A> + IntoIterator<Item = A> + Default {
    self.matchers.entry(matcher).or_default().extend(value);
}

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
This address #490 #502 #507

Co-authored-by: Guilhem Vallat <guilhem@harfanglab.fr>
Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
@LucioFranco
Copy link
Member

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants