librasn / compiler

An ASN1 compiler producing Rust bindings for the rasn framework
Other
13 stars 7 forks source link

Compiler config to disable generation of new method #23

Closed dudycz closed 3 months ago

dudycz commented 6 months ago

Hello,

In case of complex and big ASN1 definitions (like the ones from 3gpp) generated new() methods are causing clippy warnings: "this function has too many arguments" Having an option to choose whether to generate new or not would solve this kind of issue.

6d7a commented 6 months ago

Thank you for your issue. The generated new constructors are provided to create instances of non_exhaustive structs, as these cannot be constructed with a StructExpression. If we don't want to plainly ignore the clippy warning in the generated bindings, we would need to generate another way of constructing non_exhaustive types, for example a builder. To be honest, I would simply #![allow(clippy::too_many_arguments)], but if you feel motivated to implement a more elegant solution I'd be more than happy to review it.

dudycz commented 6 months ago

Do you mean to add #![allow(clippy::too_many_arguments)] in the generated module, right? It would be great and solve this problem.

6d7a commented 6 months ago

Yes, it's merely a matter of adding too_many_arguments to the allowed lints here.

shahn commented 3 months ago

I believe this could be closed with #29, not sure why it did not auto-close.