2 // compile-flags: -Copt-level=0 -Zpolymorphize=on
4 #![feature(rustc_attrs)]
6 // This test checks that `T` is considered used in `foo`, because it is used in a predicate for
9 #[rustc_polymorphize_error]
11 //~^ ERROR item has unused generic parameters
14 #[rustc_polymorphize_error]
16 //~^ ERROR item has unused generic parameters
18 I: Iterator<Item = T>,
23 #[rustc_polymorphize_error]
25 //~^ ERROR item has unused generic parameters
27 std::iter::Repeat<I>: Iterator<Item = T>,
32 // In addition, check that `I` is considered used in `next::{{closure}}`, because `T` is used and
33 // `T` is really just `I::Item`. `E` is used due to the fixed-point marking of predicates.
35 pub(crate) struct Foo<'a, I, E>(I, &'a E);
37 impl<'a, I, T: 'a, E> Iterator for Foo<'a, I, E>
39 I: Iterator<Item = &'a (T, E)>,
43 #[rustc_polymorphize_error]
44 fn next(&mut self) -> Option<Self::Item> {
46 //~^ ERROR item has unused generic parameters
50 // Furthermore, check that `B` is considered used because `C` is used, and that `A` is considered
51 // used because `B` is now used.
55 impl Baz<u16> for u8 {}
56 impl Baz<u32> for u16 {}
58 #[rustc_polymorphize_error]
59 fn quux<A, B, C: Default>() -> usize
60 //~^ ERROR item has unused generic parameters
65 std::mem::size_of::<C>()
68 // Finally, check that `F` is considered used because `G` is used when neither are in the self-ty
73 impl Foobar<u32, u32> for () {}
75 #[rustc_polymorphize_error]
76 fn foobar<F, G>() -> usize
77 //~^ ERROR item has unused generic parameters
81 std::mem::size_of::<G>()
89 let mut a = Foo([(1u32, 1u16)].iter(), &1u16);
92 let _ = quux::<u8, u16, u32>();
94 let _ = foobar::<u32, u32>();