Skip to content

UFCS form bypasses privacy checks in cross-crate scenario #21202

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

Closed
nikomatsakis opened this issue Jan 15, 2015 · 1 comment · Fixed by #21205
Closed

UFCS form bypasses privacy checks in cross-crate scenario #21202

nikomatsakis opened this issue Jan 15, 2015 · 1 comment · Fixed by #21205
Assignees
Milestone

Comments

@nikomatsakis
Copy link
Contributor

Crate 1:

#![crate_type="rlib"]

pub mod A {
    pub struct Foo;
    impl Foo {
        fn foo(&self) { }
    }
}

Crate 2:

extern crate crate1;

use crate1::A;

mod B {
    use crate1::A::Foo;
    fn bar(f: Foo) {
        Foo::foo(&f);
    }
}

fn main() { }

This builds for me. It does not if the crates are concatenated. In some cases, I've seen link failures, though I don't with this example.

cc @alexcrichton

@alexcrichton
Copy link
Member

Assigning to myself, investigating.

@alexcrichton alexcrichton self-assigned this Jan 15, 2015
@brson brson added this to the 1.0 beta milestone Jan 15, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 16, 2015
Loading methods from external crates was erroneously using the type's privacy
for each method instead of each method's privacy. This commit fixes that.

Closes rust-lang#21202
bors added a commit that referenced this issue Jan 17, 2015
Loading methods from external crates was erroneously using the type's privacy
for each method instead of each method's privacy. This commit fixes that.

Closes #21202

This commit also moves privacy to its own crate because I thought that was where the bug was. Turns out it wasn't, but it helped me iterate at least!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants