Open
Description
Summary
Rust 1.15.0 is the first release that allows ?Sized
bound in a where-clause. https://blog.rust-lang.org/2017/02/02/Rust-1.15.html#other-improvements
On older versions, one would need to write all bounds in the angle bracketed generic parameter list (not always reasonable) or put ?Sized
in the angle bracketed generic parameter list and rest of the bounds in the where-clause.
Lint Name
multiple_bound_locations
Reproducer
# Cargo.toml
[package]
name = "repro"
version = "0.0.0"
rust-version = "1.14"
// src/lib.rs
pub fn f<T: ?Sized>()
where
T: Iterator<Item = Vec<u8>>,
{
}
$ cargo clippy
warning: bound is defined in more than one place
--> src/lib.rs:3:10
|
3 | pub fn f<T: ?Sized>()
| ^
4 | where
5 | T: Iterator<Item = Vec<u8>>,
| ^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
= note: `#[warn(clippy::multiple_bound_locations)]` on by default
Clippy's preference is for one of the following, neither of which is better.
// unreadable for a verbose bound
pub fn f<T: ?Sized + Iterator<Item = Vec<u8>>>()
// incompatible with msrv
pub fn f<T>()
where
T: ?Sized + Iterator<Item = Vec<u8>>
Version
rustc 1.78.0-nightly (ef324565d 2024-02-27)
binary: rustc
commit-hash: ef324565d071c6d7e2477a195648549e33d6a465
commit-date: 2024-02-27
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Additional Labels
No response