Open Sherlock-Holo opened 1 year ago
minimal reproducible example:
use std::borrow::Borrow;
use std::net::Ipv4Addr;
fn f<T>(_: impl Borrow<T>) -> T { todo!() }
fn main() {
let _: Ipv4Addr = f(&[1, 2, 3, 4].into());
}
Error message for the above:
error[[E0282]](https://doc.rust-lang.org/stable/error_codes/E0282.html): type annotations needed
--> src/main.rs:9:38
|
9 | let _: Ipv4Addr = f([1, 2, 3, 4].into());
| ^^^^
|
help: try using a fully qualified path to specify the expected types
|
9 | let _: Ipv4Addr = f(<[i32; 4] as Into<T>>::into([1, 2, 3, 4]));
| ++++++++++++++++++++++++++++ ~
error[[E0283]](https://doc.rust-lang.org/stable/error_codes/E0283.html): type annotations needed
--> src/main.rs:9:38
|
9 | let _: Ipv4Addr = f([1, 2, 3, 4].into());
| - ^^^^
| |
| required by a bound introduced by this call
|
= note: multiple `impl`s satisfying `_: Borrow<Ipv4Addr>` found in the following crates: `alloc`, `core`:
- impl<'a, B> Borrow<B> for Cow<'a, B>
where B: ToOwned, B: ?Sized;
- impl<T, A> Borrow<T> for Box<T, A>
where A: Allocator, T: ?Sized;
- impl<T> Borrow<T> for &T
where T: ?Sized;
- impl<T> Borrow<T> for &mut T
where T: ?Sized;
- impl<T> Borrow<T> for Arc<T>
where T: ?Sized;
- impl<T> Borrow<T> for Rc<T>
where T: ?Sized;
- impl<T> Borrow<T> for T
where T: ?Sized;
note: required by a bound in `f`
--> src/main.rs:4:17
|
4 | fn f<T>(_: impl Borrow<T>) -> T {
| ^^^^^^^^^ required by this bound in `f`
help: try using a fully qualified path to specify the expected types
|
9 | let _: Ipv4Addr = f(<[i32; 4] as Into<T>>::into([1, 2, 3, 4]));
| ++++++++++++++++++++++++++++ ~```
Summary
cargo clippy
report a warn messagewhen running the
cargo clippy --fix --lib -p mahiro
, it reportsLint Name
clippy::needless_borrow
Reproducer
my project can reproduce this problem:
cd mahiro
dircargo clippy
I am using nightly version toolchain
Version
Additional Labels
No response