containerd / ttrpc-rust

Rust implementation of ttrpc (GRPC for low-memory environments)
Apache License 2.0
195 stars 45 forks source link

Clippy error: the generated code may bring clippy error `redundant_field_names` #193

Closed YushuoEdge closed 1 year ago

YushuoEdge commented 1 year ago

When compiled with rust-1.60, the xxxClient::new() will introduce clippy error redundant_field_names:

impl AgentServiceClient {
    pub fn new(client: ::ttrpc::Client) -> Self {
        AgentServiceClient {
            client: client,         // <== here: clippy error
        }
    }
    ...
}
YushuoEdge commented 1 year ago

Hi community! When encountering this issue, I think maybe the best solution is to add handling for empty values to field_entry method (introduced by protobuf-codegen crate). However, this might be a long-term solution. In the short term, we may need to add support for this clippy error in the generated code files. But I am not sure if this is appropriate. Would you happen to have any good suggestions?

jsturtevant commented 1 year ago

We are currently building against 1.66 (https://github.com/containerd/ttrpc-rust/pull/179). I don't think we see this in CI. What happens if you upgrade your Rust version?

YushuoEdge commented 1 year ago

Thanks for your reply @jsturtevant!

This clippy error still exists when I upgrade the Rust version to 1.66 and higher. I think the problem in this issue is that the code generated by ttrpc-codegen has clippy error, which may not be consistent with #179.

If I understand correctly, I found that in https://github.com/containerd/ttrpc-rust/blob/master/compiler/src/codegen.rs#L637-L658, it seems to allow some clippy in the generated files. I think this may be some similar cases.