resolve issue with reexports #5693

Closed
doy opened this Issue Apr 3, 2013 · 4 comments

Comments

Projects
None yet
4 participants
Contributor

doy commented Apr 3, 2013

// foo.rs
#[link(name = "foo", vers = "0")];
#[crate_type = "lib"];

pub use bar::MyValue;

mod bar;
pub mod baz;
// bar.rs
pub enum MyType { MyValue }

pub fn blorg (_: MyType) { }
// baz.rs
mod bar;
pub fn quux (m: bar::MyType) { bar::blorg(m) }
// app.rs
extern mod foo;

fn main () {
    foo::baz::quux(foo::MyValue);
}
$ rustc foo.rs
$ rustc -L. app.rs
app.rs:4:19: 4:31 error: mismatched types: expected `foo::baz::bar::MyType` but found `foo::bar::MyType` (expected enum foo::baz::bar::MyType but found enum foo::bar::MyType)
app.rs:4     foo::baz::quux(foo::MyValue);
                            ^~~~~~~~~~~~
error: aborting due to previous error

As far as I can tell, foo::baz::bar::MyType is nonsense here.

Owner

alexcrichton commented Apr 20, 2013

Whoops just realized the reference from that pull request was a typo, disregard that...

Contributor

msullivan commented Jun 13, 2013

What is going on here is that bar.rs is getting compiled twice, once for each time it is referenced with "mod bar;". Is this as intended?

Contributor

msullivan commented Jun 13, 2013

OK, I think this is working as intended.

@msullivan msullivan closed this Jun 13, 2013

Contributor

graydon commented Jun 13, 2013

Yes, this is doing what it was supposed to do. The bar module is being compiled at two different locations in the local module tree. There is no restriction on doing this (indeed, there are a few weird cases where you want to do it, such as we used to do with the int template module).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment