Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information