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

codegen output triggers clippy "from_over_into" #477

Open
jayvdb opened this issue Nov 2, 2022 · 0 comments
Open

codegen output triggers clippy "from_over_into" #477

jayvdb opened this issue Nov 2, 2022 · 0 comments

Comments

@jayvdb
Copy link

jayvdb commented Nov 2, 2022

The codegen output triggers https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/from_over_into.rs

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
  --> my_crate/my_model.rs:35:1
   |
35 | impl Into<MyModel> for MyModelBuilder<crate::generics::FooBarExists, crate::generics::FooBazExists, ..
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider to implement `From<my_model::MyModelBuilder<generics::FooBarExists, generics::FooBazExists, ...>>` instead
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into

Note clippy --fix doesnt automatically fix this one.

A quick fix is adding an allow.

diff --git a/src/v2/codegen/impls.rs b/src/v2/codegen/impls.rs
index 6c29fff8..10dd8d38 100644
--- a/src/v2/codegen/impls.rs
+++ b/src/v2/codegen/impls.rs
@@ -315,6 +315,8 @@ impl<'a> ApiObjectImpl<'a> {
         }
 
         let needs_container = builder.needs_container();
+
+        f.write_str("\n#[allow(clippy::from_over_into)]")?;
         f.write_str("\nimpl")?;
         if builder.needs_any {
             ApiObject::write_any_generic(f)?;
jayvdb added a commit to jayvdb/paperclip that referenced this issue Nov 2, 2022
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

1 participant