-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
.
Lint Name
trait_duplication_in_bounds
Reproducer
I tried this code:
fn main() {
multiple_constraints(&[[""]]);
}
fn multiple_constraints<T, U, V, X, Y>(_: T)
where
T: IntoIterator<Item = U> + IntoIterator<Item = X>,
U: IntoIterator<Item = V>,
V: AsRef<str>,
X: IntoIterator<Item = Y>,
Y: AsRef<std::ffi::OsStr>,
{
}
I saw this happen:
warning: these where clauses contain repeated elements
--> ./src/tools/clippy/tests/ui/needless_borrow.rs:7:8
|
7 | T: IntoIterator<Item = U> + IntoIterator<Item = X>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `IntoIterator<Item = U>`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds
= note: requested on the command line with `-W clippy::trait-duplication-in-bounds`
warning: 1 warning emitted
I expected to see this happen:
Suggetsion does not compile:
fn main() {
multiple_constraints(&[[""]]);
}
fn multiple_constraints<T, U, V, X, Y>(_: T)
where
T: IntoIterator<Item = U>,
U: IntoIterator<Item = V>,
V: AsRef<str>,
X: IntoIterator<Item = Y>,
Y: AsRef<std::ffi::OsStr>,
{
}
error[E0282]: type annotations needed
--> ./src/tools/clippy/tests/ui/needless_borrow.rs:2:5
|
2 | multiple_constraints(&[[""]]);
| ^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `X` declared on the function `multiple_constraints`
|
help: consider specifying the generic arguments
|
2 | multiple_constraints::<&[[&str; 1]; 1], &[&str; 1], &&str, X, Y>(&[[""]]);
| ++++++++++++++++++++++++++++++++++++++++++++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
Version
rustc 1.72.0-nightly (32d81eccd 2023-07-02)
binary: rustc
commit-hash: 32d81eccd64513bacef9dfa1574543ada6b45d85
commit-date: 2023-07-02
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied