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
This code snippet causes a link failure. I am guessing it is because the return type of foo is not publicly exported from the crate it is causing a link failure in the test.
I tried this (reduced) code:
lib.rs
mod helper {pubstructFoo;implFoo{pubfnbaz(&self){}}pubfnfoo() -> Foo{returnFoo;}}pubuse helper::foo;
I expected to see this happen: Definitely a clear error as opposed to a link failure. Probably an error stating that the return type of foo() is not visible outside the crate.
Instead, this happened: Linker error:
── env RUST_BACKTRACE=1 cargo test
Compiling lib v0.1.0 (file:///Users/nwr/tmp/cargo-test/lib)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "/Users/nwr/tmp/cargo-test/lib/target/debug/foo-5f1f39478ede92a5.0.o" "-o" "/Users/nwr/tmp/cargo-test/lib/target/debug/foo-5f1f39478ede92a5" "-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "-Wl,-dead_strip" "-nodefaultlibs" "/Users/nwr/tmp/cargo-test/lib/target/debug/liblib.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libtest-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libserialize-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libterm-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblog-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-74fa456f.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-74fa456f.rlib" "-L" "/Users/nwr/tmp/cargo-test/lib/target/debug" "-L" "/Users/nwr/tmp/cargo-test/lib/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/nwr/tmp/cargo-test/lib/.rust/lib/x86_64-apple-darwin" "-L" "/Users/nwr/tmp/cargo-test/lib/lib/x86_64-apple-darwin" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: ld: warning: directory not found for option '-L/Users/nwr/tmp/cargo-test/lib/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/nwr/tmp/cargo-test/lib/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
"helper::Foo::baz::heb3ebf21697cffffkaa", referenced from:
test::h63ea6d9d3e0d725cfaa in foo-5f1f39478ede92a5.0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
Could not compile `lib`.
To learn more, run the command again with --verbose.
Meta
rustc --version --verbose (repos on 1.1.0 stable as well):
This code snippet causes a link failure. I am guessing it is because the return type of foo is not publicly exported from the crate it is causing a link failure in the test.
I tried this (reduced) code:
lib.rs
test.rs
I expected to see this happen: Definitely a clear error as opposed to a link failure. Probably an error stating that the return type of
foo()
is not visible outside the crate.Instead, this happened: Linker error:
Meta
rustc --version --verbose
(repos on 1.1.0 stable as well):Backtrace: None
The text was updated successfully, but these errors were encountered: