Skip to content

resolve issue with reexports #5693

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
doy opened this issue Apr 3, 2013 · 4 comments
Closed

resolve issue with reexports #5693

doy opened this issue Apr 3, 2013 · 4 comments

Comments

@doy
Copy link
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.

@alexcrichton
Copy link
Member

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

@msullivan
Copy link
Contributor

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?

@msullivan
Copy link
Contributor

OK, I think this is working as intended.

@graydon
Copy link
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).

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 10, 2020
or_fn_call: ignore nullary associated const fns

The fix in rust-lang#5889 was missing associated functions.

changelog: Ignore also `const fn` methods in [`or_fun_call`]

Fixes rust-lang#5693
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

4 participants