Issue 1:
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() {}

Issue 2:
STR

use array::ArrayShape;

pub mod array {
pub use self::traits::ArrayShape;

mod traits {
pub trait ArrayShape {
fn shape(&self) -> (usize, usize) {
(0, 0)
}
}
}
}

struct Array;

impl ArrayShape for Array {}

fn main() {
println!("{:?}", Array.shape()); //~ error: source trait is inaccessible
}

trait MatrixShape: ArrayShape {
fn nrows(&self) -> usize { self.shape().0 } //~ error: source trait is inaccessible
}

fn show() {
println!("{:?}", (&Array as &ArrayShape).shape()); //~ error: source trait is inaccessible
}

Version

rustc 1.0.0-nightly (458a6a2f6 2015-01-25 21:20:37 +0000)

Original issue

STR

use array::ArrayShape;

pub mod array {
pub use self::traits::ArrayShape;

mod traits {
pub trait ArrayShape {
fn shape(&self) -> (uint, uint) {
(0, 0)
}
}
}
}

struct Array;

// `ArrayShape` is available in this scope, it can be implemented ...
impl ArrayShape for Array {}

fn main() {
// ... and can also be used
println!("{}", Array.shape());
}

// But this super trait doesn't work
#[cfg(not(working))]
trait MatrixShape: ArrayShape {
fn nrows(&self) -> uint { self.shape().val0() }
}

#[cfg(not(working))]
fn bad() {
// This doesn't work either
println!("{}", (&Array as &ArrayShape).shape());
}

Output:

trait.rs:28:31: 28:43 error: source trait is inaccessible
trait.rs:28 fn nrows(&self) -> uint { self.shape().val0() }
^~~~~~~~~~~~
trait.rs:28:31: 28:43 note: module `traits` is private
trait.rs:28 fn nrows(&self) -> uint { self.shape().val0() }
^~~~~~~~~~~~
trait.rs:34:20: 34:51 error: source trait is inaccessible
trait.rs:34 println!("{}", (&Array as &ArrayShape).shape());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
trait.rs:34:5: 34:53 note: expansion site
trait.rs:34:20: 34:51 note: module `traits` is private
trait.rs:34 println!("{}", (&Array as &ArrayShape).shape());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
trait.rs:34:5: 34:53 note: expansion site
error: aborting due to 2 previous errors

I'm no longer sure if this is a bug or is intended? The impl block works, but the super trait and the trait object don't. Do the latter two have different scoping/privacy rules?

Version:

rustc 0.12.0-pre (795f6ae82 2014-08-04 07:01:10 +0000)