rust/tests
bors 6a281e9a73 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.
2024-10-13 15:49:30 +00:00
..
test_utils
ui Auto merge of #13487 - Coekjan:fix-slice-size-calc-on-ref-ref, r=dswij 2024-10-13 15:49:30 +00:00
ui-cargo
ui-internal
ui-toml Auto merge of #13444 - kpreid:fix-8524-private-rep, r=blyxyas 2024-10-12 16:46:31 +00:00
workspace_test
check-fmt.rs
clippy.toml
compile-test.rs Auto merge of #13269 - GuillaumeGomez:rewrite-lints-page, r=Alexendoo 2024-10-11 14:18:54 +00:00
config-metadata.rs
dogfood.rs
headers.rs
integration.rs
lint_message_convention.rs
missing-test-files.rs
versioncheck.rs
workspace.rs