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

Fix warnings for cloning references in generated code #1676

Commits on Jan 3, 2023

  1. fix: warnings for cloning references

    In tokio-rs#1674, it was pointed out that `axum-macros` causes some `clippy`
    warnings (and some `rustc` lints to fail) as the `FromRef` macro
    generates code which clones reference types unnecessarily.
    
    This seems to be when generating the body of the trait implementation,
    but since we have the type information from `syn` at that point it's
    relatively simple to resolve these.
    
    This change:
    * Avoids using `.clone` if we are generating the implementation for a
      reference type field
    * Adds a simple UI test to ensure this compiles with the `rustc` lint
      set to deny
    
    Fixes tokio-rs#1674.
    alexander-jackson committed Jan 3, 2023
    Configuration menu
    Copy the full SHA
    f9f718b View commit details
    Browse the repository at this point in the history