|
| 1 | +//@aux-build:proc_macros.rs |
| 2 | +#![allow(clippy::extra_unused_type_parameters)] |
| 3 | + |
| 4 | +extern crate proc_macros; |
| 5 | + |
| 6 | +fn projection_with_existing_assoc_bounds<T>() |
| 7 | +where |
| 8 | + T: Iterator<Item: Clone + Copy + Sized>, |
| 9 | + |
| 10 | + //~^ could_be_assoc_type_bounds |
| 11 | +{ |
| 12 | +} |
| 13 | + |
| 14 | +fn projection_with_existing_bounds<T: Iterator<Item: Clone + Copy + Sized>>() |
| 15 | + //~^ could_be_assoc_type_bounds |
| 16 | +{ |
| 17 | +} |
| 18 | + |
| 19 | +fn no_fully_qualified_path<T: Iterator<Item: Clone>>() |
| 20 | +where |
| 21 | + // False negative for now: `T::Item` has a `Res::Err` resolution |
| 22 | + T::Item: Copy + Sized, |
| 23 | +{ |
| 24 | +} |
| 25 | + |
| 26 | +fn ty_param<T: Iterator<Item: Clone>, >() {} |
| 27 | + |
| 28 | +fn multiple_projections<T>() |
| 29 | +where |
| 30 | + T: Iterator<Item: Sized + Clone>, |
| 31 | + |
| 32 | +{ |
| 33 | +} |
| 34 | + |
| 35 | +fn ty_param_used_in_body<T: Iterator<Item = P>, P: Clone + Default>() { |
| 36 | + P::default(); |
| 37 | +} |
| 38 | + |
| 39 | +fn nested_impl_trait(_: impl Iterator<Item = impl Sized>) {} |
| 40 | + |
| 41 | +fn impl_trait_generic(_: impl Iterator<Item: Copy>) {} |
| 42 | + |
| 43 | +fn single_impl_trait(_: impl Iterator<Item = ()>) {} |
| 44 | + |
| 45 | +fn parenthesized<T: Iterator<Item: Fn()>, >() {} //~ could_be_assoc_type_bounds |
| 46 | + |
| 47 | +// Make sure implicit generic lifetime parameters for delim doesn't mess up spans |
| 48 | +pub fn elided_lifetime<I, >(iter: I, delim: &str) |
| 49 | +where |
| 50 | + I: IntoIterator<Item: std::fmt::Display>, |
| 51 | + //~ could_be_assoc_type_bounds |
| 52 | +{ |
| 53 | +} |
| 54 | + |
| 55 | +fn parenthesized2<F: Fn()>() |
| 56 | +where |
| 57 | + F::Output: Copy, |
| 58 | +{ |
| 59 | +} |
| 60 | +fn many_ty_params<T, X>() |
| 61 | +//~^ could_be_assoc_type_bounds |
| 62 | +where |
| 63 | + T: Iterator<Item: Copy>, |
| 64 | +{ |
| 65 | +} |
| 66 | + |
| 67 | +#[clippy::msrv = "1.78.0"] |
| 68 | +fn low_msrv<T: Iterator<Item = P>, P: Copy + Default>() { |
| 69 | + #[clippy::msrv = "1.79.0"] |
| 70 | + P::default(); |
| 71 | +} |
| 72 | + |
| 73 | +// More involved test case with multiple associated types and generic parameters |
| 74 | +trait Trait1<G1, G2>: Default { |
| 75 | + type A2; |
| 76 | + type A3; |
| 77 | + type A4; |
| 78 | +} |
| 79 | + |
| 80 | +fn complex<T, G1, G2>() |
| 81 | +where |
| 82 | + (T, T): Trait1<G1, G2, A2 = u32, A3: Clone, A4: Clone>, |
| 83 | + |
| 84 | +{ |
| 85 | +} |
| 86 | + |
| 87 | +proc_macros::external! { |
| 88 | + fn external<T: Iterator<Item = I>, I: Copy>() {} |
| 89 | +} |
| 90 | +proc_macros::with_span! { |
| 91 | + span |
| 92 | + fn external2<T: Iterator<Item = I>, I: Copy>() {} |
| 93 | +} |
| 94 | + |
| 95 | +fn main() {} |
0 commit comments