-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
privacy: Fix regression in impl reachability #57344
Conversation
I think the invariant the impl rule tries to rely on should be documented somewhere: The invariant is that type-inference won't let you use an impl without knowing the "shallow" version of its self type (which requires reaching the I noted this is not handled correctly with projections, so I have an example that ICEs even older rustcs: aux.rs: mod inner {
#[derive(Default)]
pub struct PubUnnameable;
}
trait Mirror { type Image; }
impl<T> Mirror for T { type Image = T; }
pub enum Pub<T> { Nothing, Just(T) }
pub trait Aux {}
impl Aux for <Pub<inner::PubUnnameable> as Mirror>::Image {}
pub fn assert_aux<T: Aux>(_t: &T) {}
impl inner::PubUnnameable {
pub fn pub_method(self) {}
} main.rs: extern crate aux;
fn get_default<T: Default>(_t: &aux::Pub<T>) -> T { T::default() }
fn main() {
let pub_ = aux::Pub::Nothing;
aux::assert_aux(&pub_);
let def = get_default(&pub_);
def.pub_method();
} |
I would rename |
r=me with these changes |
Waiting on rust-lang/rust#57344 to be merged.
Projections are not necessary in that case, the root reason is a public trait that's implemented for a single type, so type inference can make conclusion " @bors r=arielb1 |
📌 Commit 46d53e53bd20613e1921efbc529726b306732fd2 has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 46d53e53bd20613e1921efbc529726b306732fd2 has been approved by |
Ok. And there's no inherent problem with projections because accessibility computation has to treat projections as public anyway.
I would prefer you to not do a @bors r=me after you make a change this size. In any case: Looking at the code, the one point that I think is missing an adequate explanation is the Treating opaque types with private predicates as private when computing the However, I think that is remarkable enough I'll want it as a comment. @bors r- |
📌 Commit 46d53e53bd20613e1921efbc529726b306732fd2 has been approved by |
@bors r- |
r=me with a comment on (If you are only changing the comment, I'm ok with a |
@arielb1 This intent is somewhat hidden because impl-Trait and dyn-Trait use such different structures in |
@bors r=arielb1 |
📌 Commit fb00313 has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Rollback to pre-#56878 logic of determining reachability.
reachability(impl Trait<Substs> for Type<Substs>) = reachability(Trait & Type)
, substs are ignored.Fixes #57264