Skip to content

Instantly share code, notes, and snippets.

@Fiona-J-W
Created October 14, 2014 15:08
Show Gist options
  • Save Fiona-J-W/0840b55e6925b7d36f66 to your computer and use it in GitHub Desktop.
Save Fiona-J-W/0840b55e6925b7d36f66 to your computer and use it in GitHub Desktop.
Nonworking Rust
mod tu1;
fn main() {
println!("Hello World");
tu1::fun1();
}
mod tu2;
pub fn fun1() {
println!("fun1()");
::tu2::fun2();
}
pub fn fun2() {
println!("fun2()");
}
@Fiona-J-W
Copy link
Author

$ rustc mod.rs
tu1.rs:2:5: 2:8 error: cannot declare a new module at this location
tu1.rs:2 mod tu2;
^~~
tu1.rs:2:5: 2:8 note: maybe move this module tu1 to its own directory via tu1/mod.rs
tu1.rs:2 mod tu2;
^~~
tu1.rs:2:5: 2:8 note: ... or maybe use the module tu2 instead of possibly redeclaring it
tu1.rs:2 mod tu2;
^~~

@bstrie
Copy link

bstrie commented Oct 14, 2014

Looks like Rust is trying to enforce a certain directory structure to your modules. Does http://thread.gmane.org/gmane.comp.lang.rust.devel/10032 help?

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