Skip to content
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

Link error with reexported structs/impls #9906

Closed
ydnax opened this issue Oct 17, 2013 · 0 comments
Closed

Link error with reexported structs/impls #9906

ydnax opened this issue Oct 17, 2013 · 0 comments

Comments

@ydnax
Copy link

ydnax commented Oct 17, 2013

given a modue testmod in src/testmod/ with this code

lib.rs

pub use other::FooBar;
pub use other::foo;
mod other;

other.rs

pub struct FooBar{value: int}
impl FooBar{
    pub fn new(val: int) -> FooBar {
       FooBar{value: val}
    }
}

pub fn foo(){
    1+1;
}

and test.rs

extern mod testmod;


#[test]
fn create() {
    testmod::foo();
    testmod::FooBar::new(1);
}

running

rustc --lib src/testmod/lib.rs -o src/testmod/testmod && rustc --test src/testmod/test.rs -L src/testmod/

fails with

error: linking with `cc` failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o src/testmod/test src/testmod/test.o -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-6c65cf4b443341b1-0.9-pre -Lsrc/testmod -ltestmod-15fb3a718ea23983-0.0 -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -lextra-a7c050cfd46b2c9a-0.9-pre -lrustrt -lrt -lpthread -Lsrc/testmod -L. -L/home/xandy/Projects/rusttest/.rust -L/home/xandy/Projects/rusttest -lrt -ldl -lm -lmorestack -lrustrt -Wl,-rpath,$ORIGIN/../../../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,$ORIGIN/. -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/home/xandy/Projects/rusttest/src/testmod
note: src/testmod/test.o: In function `create::hbb4547578de7b860ai::v0.0':
test.rc:(.text+0x41): undefined reference to `other::FooBar::new::h89aaf3c2942f8021LSaM::v0.0'
collect2: error: ld returned 1 exit status

error: aborting due to previous error
task '<unnamed>' failed at 'explicit failure', /home/xandy/src/rust/src/libsyntax/diagnostic.rs:98
task '<unnamed>' failed at 'explicit failure', /home/xandy/src/rust/src/librustc/rustc.rs:391

if lib.rs has pub mod other; instead of mod other; it works. is this intended?

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 1, 2022
Fix `unnecessary_cast` suggestion when taking a reference

fixes rust-lang#9906
changelog: `unnecessary_cast`: Fix suggestion when taking a reference
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

1 participant