about summary refs log tree commit diff
path: root/tests/codegen/src-hash-algorithm
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-16 06:04:59 +0000
committerbors <bors@rust-lang.org>2023-09-16 06:04:59 +0000
commit59636a2aa3f0189b75936170e24f6f83ff993ccc (patch)
treec0163ea167f5ce7eab6e93655c7bbf63e5dd8f9b /tests/codegen/src-hash-algorithm
parentdaadab515a5df78c1745d306c59095abad4fcc56 (diff)
parent18f36897ef0844dc5e5a0d995356247cbee72ff3 (diff)
downloadrust-59636a2aa3f0189b75936170e24f6f83ff993ccc.tar.gz
rust-59636a2aa3f0189b75936170e24f6f83ff993ccc.zip
Auto merge of #11301 - y21:issue11300, r=dswij
[`useless_conversion`]: don't lint if type parameter has unsatisfiable bounds for `.into_iter()` receiver

Fixes #11300.

Before this PR, clippy assumed that if it sees a `f(x.into_iter())` call and the type at that argument position is generic over any `IntoIterator`, then the `.into_iter()` call must be useless because `x` already implements `IntoIterator`, *however* this assumption is not right if the generic parameter has more than just the `IntoIterator` bound (because other traits can be implemented for the IntoIterator target type but not the IntoIterator implementor, as can be seen in the linked issue: `<[i32; 3] as IntoIterator>::IntoIter` satisfies `ExactSizeIterator`, but `[i32; 3]` does not).

So, this PR makes it check that the type parameter only has a single `IntoIterator` bound. It *might* be possible to check if the type of `x` in `f(x.into_iter())` satisfies all the bounds on the generic type parameter as defined on the function (which would allow removing the `.into_iter()` call even with multiple bounds), however I'm not sure how to do that, and the current fix should always work.

**Edit:** This PR has been changed to check if any of the bounds don't hold for the type of the `.into_iter()` receiver, so we can still lint in some cases.

changelog: [`useless_conversion`]: don't lint `.into_iter()` if type parameter has multiple bounds
Diffstat (limited to 'tests/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions