about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-07 09:33:48 +0000
committerbors <bors@rust-lang.org>2024-06-07 09:33:48 +0000
commit0b441d5ac5934eecb4254f71a8557cf9cb6b882e (patch)
tree36422fee03327235a331a55194dcf2ca92e7bd8b /tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff
parentd9ae9367ba7814a380b6501c3ca67dadd3d72641 (diff)
parent25d40c9f6b09b4decd17c564c037e1f8de9859b2 (diff)
downloadrust-0b441d5ac5934eecb4254f71a8557cf9cb6b882e.tar.gz
rust-0b441d5ac5934eecb4254f71a8557cf9cb6b882e.zip
Auto merge of #12877 - y21:const_host_ice, r=dswij
Handle const effects inherited from parent correctly in `type_certainty`

This fixes a (debug) ICE in `type_certainty` that happened in the [k256 crate]. (I'm sure you can also specifically construct an edge test case that will run into type_certainty false positives visible outside of debug builds from this bug)

<details>
<summary>Minimal ICE repro</summary>

```rs
use std::ops::Add;
Add::add(1_i32, 1).add(i32::MIN);
```
</details>

The subtraction here overflowed:
https://github.com/rust-lang/rust-clippy/blob/436675b4772049a0ff535bd46d944689c90ed750/clippy_utils/src/ty/type_certainty/mod.rs#L209

... when we have something like `Add::add` where `add` fn has 0 generic params but the `host_effect_index` is `Some(2)` (inherited from the parent generics, the const trait `Add`), and we end up executing `0 - 1`.

(Even if the own generics weren't empty and we didn't overflow, this would still be wrong because it would assume that a trait method with 1 generic parameter didn't have any generics).

So, *only* exclude the "host" generic parameter if it's actually bound by the own generics

changelog: none

[k256 crate]: https://github.com/RustCrypto/elliptic-curves/tree/master/k256
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff')
0 files changed, 0 insertions, 0 deletions