Closed
Description
Summary
The problem is that arithmetic_side_effects
triggers on the code generated by macro. In my case by quote!
macro.
I think this issue is related to #9757.
So as said in #9757 dtolnay/quote#232 (comment) this thing should be fixed on clippy
side, not on quote
side.
arithmetic_side_effects
is being triggered only when I have ,
at the end.
Lint Name
arithmetic_side_effects
Reproducer
I tried this code:
#![deny(clippy::arithmetic_side_effects)]
fn main() {
let array = [1, 2, 3];
let _ = quote::quote!(#(#array),*);
}
I saw this happen:
error: arithmetic operation that can potentially result in unexpected side-effects
--> src/main.rs:5:13
|
5 | let _ = quote::quote!(#(#array),*);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(clippy::arithmetic_side_effects)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote::quote` (in Nightly builds, run with -Z macro-backtrace for more info)
I expected to see this happen:
Successful pass
Version
rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: aarch64-apple-darwin
release: 1.66.0
LLVM version: 15.0.2
Additional Labels
No response