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

New stack macro implementation triggers clippy::toplevel_ref_arg warning #1422

Open
dsemi opened this issue Jun 28, 2024 · 3 comments
Open

Comments

@dsemi
Copy link

dsemi commented Jun 28, 2024

This line triggers the clippy::toplevel_ref_arg warning for users of stack!.

Example warning:

warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
  --> src/main.rs:35:15
   |
35 |       let rhs = stack![ bp.cross(&bv) - ap.cross(&av);
   |  _______________^
36 | |                       cp.cross(&cv) - ap.cross(&av) ];
   | |_____________________________________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
   = note: `#[warn(clippy::toplevel_ref_arg)]` on by default
   = note: this warning originates in the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info)
@Andlon
Copy link
Sponsor Collaborator

Andlon commented Jun 28, 2024

Uhm, does clippy normally give warnings from code generated by macros in external crates? That seems... excessive? Did you enable any particular options?

@dsemi
Copy link
Author

dsemi commented Jun 28, 2024

It seems so: rust-lang/rust-clippy#702. I don't understand why that decision was made.

@Andlon
Copy link
Sponsor Collaborator

Andlon commented Jun 30, 2024

This comment suggests that it's due to our use of spans in the stack! macro to improve error messages. We should fix this by just plastering #[allow(clippy::all)] in the macro-generated code.

I'm not sure off the top of my head if we can put these attributes on code blocks though (not a function/impl block).

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