rust-clippy/tests/ui/impl_trait_in_params.rs

21 lines
520 B
Rust
Raw Normal View History

#![allow(unused)]
#![warn(clippy::impl_trait_in_params)]
2023-07-27 11:40:22 +00:00
//@no-rustfix
pub trait Trait {}
2023-01-13 11:54:51 +00:00
pub trait AnotherTrait<T> {}
// Should warn
pub fn a(_: impl Trait) {}
//~^ ERROR: '`impl Trait` used as a function parameter'
//~| NOTE: `-D clippy::impl-trait-in-params` implied by `-D warnings`
pub fn c<C: Trait>(_: C, _: impl Trait) {}
//~^ ERROR: '`impl Trait` used as a function parameter'
2023-01-13 11:54:51 +00:00
fn d(_: impl AnotherTrait<u32>) {}
// Shouldn't warn
pub fn b<B: Trait>(_: B) {}
2023-01-13 11:54:51 +00:00
fn e<T: AnotherTrait<u32>>(_: T) {}
fn main() {}