Make your private trait private:
pub mod lib {
trait MyTraitInner<Item> {
type Iter: Iterator<Item = Item>;
fn get_item(&mut self) -> Item;
}
#[allow(private_bounds)]
pub trait MyTrait: MyTraitInner<Self::Item> {
type Item;
}
}
// Doesn't compile.
fn test1<T: lib::MyTrait>(iter: T::Iter) {
todo!()
}
// Doesn't compile.
fn test2<T: lib::MyTrait>(mut a: T) {
a.get_item();
}