diff options
| author | yanglsh <yanglsh@shanghaitech.edu.cn> | 2025-07-27 22:11:36 +0800 |
|---|---|---|
| committer | yanglsh <yanglsh@shanghaitech.edu.cn> | 2025-07-28 21:45:40 +0800 |
| commit | 938e79fdac508c1cca01743b85cff11ed5f7aab6 (patch) | |
| tree | a46bae9f0247ebe4ba772339863eb7a3c98d53f1 /tests | |
| parent | 03978193a5900c0d4767891eee408a54aaf1915c (diff) | |
| download | rust-938e79fdac508c1cca01743b85cff11ed5f7aab6.tar.gz rust-938e79fdac508c1cca01743b85cff11ed5f7aab6.zip | |
fix: `cast-lossless` should not suggest when casting type is from macro input
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/cast_lossless_integer_unfixable.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/cast_lossless_integer_unfixable.rs b/tests/ui/cast_lossless_integer_unfixable.rs new file mode 100644 index 00000000000..db9cbbb5b66 --- /dev/null +++ b/tests/ui/cast_lossless_integer_unfixable.rs @@ -0,0 +1,17 @@ +//@check-pass +#![warn(clippy::cast_lossless)] + +fn issue15348() { + macro_rules! zero { + ($int:ty) => {{ + let data: [u8; 3] = [0, 0, 0]; + data[0] as $int + }}; + } + + let _ = zero!(u8); + let _ = zero!(u16); + let _ = zero!(u32); + let _ = zero!(u64); + let _ = zero!(u128); +} |
