You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just came across a linker error, which should probably give an error during compilation instead. Minimal example:
lib.rs:
mod stuff {pubstructMyStruct(u8);//some very useful structimplMyStruct{pubfnnew() -> MyStruct{MyStruct(42)}pubfnget_data(self) -> u8{self.0}}}use stuff::MyStruct;pubfnfoo() -> MyStruct{MyStruct::new()}
When adding a binary target bin/exe.rs like this:
externcrate crash;fnmain(){//linker error herelet n = crash::foo().get_data();println!("Got: {}",n);}
I get the following linker error on cargo build or cargo build --bin exe:
note: /.../crash/target/debug/exe.0.o: In function `exe::main':
/.../crash/src/bin/exe.rs:5: undefined reference to `stuff::_$LT$impl$GT$::get_data::hda4b62b5e3688f36taa'
collect2: error: ld returned 1 exit status
I am not familiar with the way rust handles modules, but I think this should indeed not work, so the compiler should probably give an error here.
Note that this compiles (and runs) fine if pub mod stuff is used instead of mod stuff, or if pub use stuff::MyStruct is used, which would make MyStruct accessible.
I just came across a linker error, which should probably give an error during compilation instead. Minimal example:
lib.rs:
When adding a binary target
bin/exe.rs
like this:I get the following linker error on
cargo build
orcargo build --bin exe
:I am not familiar with the way rust handles modules, but I think this should indeed not work, so the compiler should probably give an error here.
Note that this compiles (and runs) fine if
pub mod stuff
is used instead ofmod stuff
, or ifpub use stuff::MyStruct
is used, which would makeMyStruct
accessible.Compiler versions used:
The text was updated successfully, but these errors were encountered: