2 // compile-flags:-Zpolymorphize=on
3 #![feature(rustc_attrs)]
5 // This test checks that `T` is considered used in `foo`, because it is used in a predicate for
8 #[rustc_polymorphize_error]
10 //~^ ERROR item has unused generic parameters
13 #[rustc_polymorphize_error]
15 //~^ ERROR item has unused generic parameters
17 I: Iterator<Item = T>,
22 #[rustc_polymorphize_error]
24 //~^ ERROR item has unused generic parameters
26 std::iter::Repeat<I>: Iterator<Item = T>,
31 // In addition, check that `I` is considered used in `next::{{closure}}`, because `T` is used and
32 // `T` is really just `I::Item`. `E` is used due to the fixed-point marking of predicates.
34 pub(crate) struct Foo<'a, I, E>(I, &'a E);
36 impl<'a, I, T: 'a, E> Iterator for Foo<'a, I, E>
38 I: Iterator<Item = &'a (T, E)>,
42 #[rustc_polymorphize_error]
43 fn next(&mut self) -> Option<Self::Item> {
45 //~^ ERROR item has unused generic parameters
49 // Furthermore, check that `B` is considered used because `C` is used, and that `A` is considered
50 // used because `B` is now used.
54 impl Baz<u16> for u8 {}
55 impl Baz<u32> for u16 {}
57 #[rustc_polymorphize_error]
58 fn quux<A, B, C: Default>() -> usize
59 //~^ ERROR item has unused generic parameters
64 std::mem::size_of::<C>()
67 // Finally, check that `F` is considered used because `G` is used when neither are in the self-ty
72 impl Foobar<u32, u32> for () {}
74 #[rustc_polymorphize_error]
75 fn foobar<F, G>() -> usize
76 //~^ ERROR item has unused generic parameters
80 std::mem::size_of::<G>()
88 let mut a = Foo([(1u32, 1u16)].iter(), &1u16);
91 let _ = quux::<u8, u16, u32>();
93 let _ = foobar::<u32, u32>();