Skip to content

Invalid "error: source trait is inaccessible" error #28394

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
emidoots opened this issue Sep 13, 2015 · 1 comment
Closed

Invalid "error: source trait is inaccessible" error #28394

emidoots opened this issue Sep 13, 2015 · 1 comment

Comments

@emidoots
Copy link

This code does not compile (playpen):

pub mod mymod{

    mod foo {

        pub trait ToFoo{
            fn to_foo(self) -> i32;
        }
    }
    pub use self::foo::ToFoo;

}

pub fn foobar<T: mymod::ToFoo>(x: T) {
    let v = x.to_foo();
}

fn main() {}

Output:

<anon>:14:13: 14:23 error: source trait is inaccessible
<anon>:14     let v = x.to_foo();
                      ^~~~~~~~~~
<anon>:14:13: 14:23 note: module `foo` is private
<anon>:14     let v = x.to_foo();
                      ^~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101

Strangely as @bluss pointed out on IRC, this style does compile (playpen):

pub mod mymod{

    mod foo {

        pub trait ToFoo{
            fn to_foo(self) -> i32;
        }
    }
    pub use self::foo::ToFoo;

}

use mymod::ToFoo;

pub fn foobar<T: ToFoo>(x: T) {
    let v = ToFoo::to_foo(x);
}

fn main() {}
@ghost
Copy link

ghost commented Sep 13, 2015

Duplicate of #16264.

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

No branches or pull requests

2 participants