Re: [rust-dev] Compilation Error in Rust in Nesting of Modules

2013-02-04 Thread Felix S Klock II

Ranvijay (cc'ing rust-dev)-

Since you put your source code in the file c/c.rs, that code belongs to 
a module named `c` *inside* of the `c` module you have already put into 
your orig.rs crate.


You can see the git diff invocation in the transcript below to see how 
I fixed your code.


Cheers,
-Felix

% rustc --version
rustc 0.5 (09bb07b 2012-12-24 18:29:02 -0800)
host: x86_64-apple-darwin

% git diff
diff --git a/orig.rs b/orig.rs
index 8a81117..decb7fe 100644
--- a/orig.rs
+++ b/orig.rs
@@ -7,6 +7,9 @@ pub mod a ;
 pub mod b ;
 pub mod c {
 pub mod inner_mod ;
+
+// Fixed code:
+pub mod c;
 }


diff --git a/test_orig.rs b/test_orig.rs
index 9b0bd63..babf26f 100644
--- a/test_orig.rs
+++ b/test_orig.rs
@@ -5,7 +5,12 @@ orig::c::inner_mod::inner_mod();
 orig::dummy();
 orig::a::a_func();
 orig::b::b_func();
-orig::c::c_func();
+
+// // Original code:
+// orig::c::c_func();
+//
+// // Fixed Code:
+orig::c::c::c_func();
 //parserutils::utils::inner_mod::inner_mod();
 }


% rustc orig.rs  rustc -L. test_orig.rs
warning: no debug symbols in executable (-arch x86_64)
warning: no debug symbols in executable (-arch x86_64)

% ./test_orig
 i am in inner_mod
 i am in dummy
 i am in a
 i am in b
 i am in c


On Fri Feb 1 12:29:44 2013, Ranvijay Singh wrote:


Hi,
I am getting compilation error while implementing the nesting of
modules as per the Rust Language tutorial.
Below is the description of my code structure.

Inside example directory,I created a file orig.rs http://orig.rs and
declared 3 modules a, b and c inside it. Inside module c, I declared
another module inner_mod. I created 3 files a.rs http://a.rs, b.rs
http://b.rs and c.rs http://c.rs and one directory c, all inside
the example directory.Also, I created another file inner_mod.rs
http://inner_mod.rs and kept it in c directory. In c.rs
http://c.rs, I defined a function *C_func* as below.

pub fn *c_func*() {
io::println(I am in c);
}
I called the function c_func in file test_orig.rs
http://test_orig.rs which is in example directory.
As per the tutorial, I can create c.rs http://c.rs file and c
directory both, but nothing is mentioned about the location of c.rs
http://c.rs with respect to c directory i.e. whether c.rs
http://c.rs will be kept inside c directory or outside of it at the
same level as c directory inside example directory. I tried both and
got the below error in each case when compiled:

*test_orig.rs:8:0: 8:15 error: unresolved name: orig::c::c_func
test_orig.rs:8 http://test_orig.rs:8 orig::c::c_func();*

Tar file of the code is attached.Please suggest a solution to this.


thanks
Ranvijay



___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev




--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.org

___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


[rust-dev] Compilation Error in Rust in Nesting of Modules

2013-02-01 Thread Ranvijay Singh
Hi,
I am getting compilation error while implementing the nesting of modules as
per the Rust Language tutorial.
Below is the description of my code structure.

Inside example directory,I created a file orig.rs and declared 3 modules a,
b and c inside it. Inside module c, I declared another module inner_mod. I
created 3 files a.rs, b.rs and c.rs and one directory c, all inside the
example directory.Also, I created another file inner_mod.rs and kept it in
c directory. In c.rs, I defined a function *C_func* as below.

pub fn *c_func*() {
io::println(I am in c);
}
I called the function c_func in file test_orig.rs which is in example
directory.
As per the tutorial, I can create c.rs file and c directory both,  but
nothing is mentioned about the location of c.rs with respect to c directory
i.e. whether c.rs will be kept inside c directory or outside of it at the
same level as c directory inside example directory. I tried both and got
the below error in each case when compiled:

*test_orig.rs:8:0: 8:15 error: unresolved name: orig::c::c_func
test_orig.rs:8 orig::c::c_func();*

Tar file of the code is attached.Please suggest a solution to this.


thanks
Ranvijay


example.tar
Description: Unix tar archive
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev