diff options
| author | bors <bors@rust-lang.org> | 2024-10-13 15:49:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-13 15:49:30 +0000 |
| commit | 6a281e9a73e258b8b60157736390f221d6c924da (patch) | |
| tree | 47dbfbd02dd451d44b17b03b3796a28f083cdc61 /library/std/src/sys/pal/unix/stack_overflow.rs | |
| parent | f883e28e3d16853a6fb57543e8abf8b2bc8f3a19 (diff) | |
| parent | 2080634d336ac73a00aa256993ee035da7226aca (diff) | |
| download | rust-6a281e9a73e258b8b60157736390f221d6c924da.tar.gz rust-6a281e9a73e258b8b60157736390f221d6c924da.zip | |
Auto merge of #13487 - Coekjan:fix-slice-size-calc-on-ref-ref, r=dswij
Fix lint `manual_slice_size_calculation` when a slice is ref more than once When a slice is ref more than once, current suggestion given by `manual_slice_size_calculation` is wrong. For example: ```rs let s: &[i32] = &[1, 2][..]; let ss: &&[i32] = &s; // <----- let _ = size_of::<i32>() * ss.len(); ``` clippy now suggests: ```patch - let _ = size_of::<i32>() * ss.len(); + let _ = size_of_val(ss); ``` However, this can result in calculating the size of `&[i32]`, instead of `[i32]` (this wrong suggestion also leads to `size_of_ref` warning: https://rust-lang.github.io/rust-clippy/master/index.html#/size_of_ref ) Now I am sending this PR to fix this bug, so that clippy will suggest (some deref added): ```patch - let _ = size_of::<i32>() * ss.len(); + let _ = size_of_val(*ss); ``` As I am not familiar with current clippy code-base, please correct me if I am not doing well or I can do it better :) changelog: [`manual_slice_size_calculation`]: fix a bug when a slice is ref more than once.
Diffstat (limited to 'library/std/src/sys/pal/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
