Open
Description
I was surprised to get a private_in_public deprecation warning for using a private trait to compute an associated type that's itself pub.
De-macro'd, shortened example of what I was doing:
#![feature(try_from)]
trait Bar {
type Inner;
}
pub struct B16(u16);
pub struct B32(u32);
impl Bar for B16 {
type Inner = u16;
}
impl Bar for B32 {
type Inner = u32;
}
use std::convert::{TryFrom, TryInto};
impl TryFrom<B32> for B16 {
type Error = <<B16 as Bar>::Inner as TryFrom<<B32 as Bar>::Inner>>::Error;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// warning: private type `<B16 as Bar>::Inner` in public interface (error E0446)
// (Despite the fact that that actual type is core::num::TryFromIntError)
fn try_from(x: B32) -> Result<Self, Self::Error> {
Ok(B16(x.0.try_into()?))
}
}
fn main() {}
Repro: https://play.rust-lang.org/?gist=1f84c630e07ddd54d2bf208aa85ed8bb&version=nightly
I don't understand how that type is part of the public interface, since I can't get to it using TryFrom.
(Do close if this is known and covered by things like rust-lang/rfcs#1671 (comment), but I couldn't find any issues talking about this part at least.)