Issue 1:
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 {
pub struct Foo;
impl Foo {
pub fn baz(&self) { }
}

pub fn foo() -> Foo {
return Foo;
}
}

pub use helper::foo;

test.rs

extern crate lib;

#[test]
fn test() {
lib::foo().baz();
}

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):

rustc 1.3.0-nightly (8ce69e856 2015-07-31)
binary: rustc
commit-hash: 8ce69e856a4def6ef39581823520c68944bd1c8e
commit-date: 2015-07-31
host: x86_64-apple-darwin
release: 1.3.0-nightly

Backtrace: None

Issue 2:
// foo.rs
pub use foo::Bar;

pub fn test() -> Bar<i32> {
loop {}
}

mod foo {
pub type Bar<T> = Result<T, Baz>;

pub struct Baz;

impl Baz {
pub fn foo(&self) {}
}
}

// bar.rs
extern crate foo;

fn main() {
match foo::test() {
Ok(..) => {}
Err(e) => e.foo()
}
}

$ rustc --crate-type lib foo.rs
foo.rs:13:9: 13:29 warning: code is never used: `foo`, #[warn(dead_code)] on by default
foo.rs:13 pub fn foo(&self) {}
^~~~~~~~~~~~~~~~~~~~
$ rustc bar.rs -L.
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'bar' 'bar.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib' '/home/alex/libfoo.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib' '/home/alex/code/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '-L' '.' '-L' '/home/alex/.rust' '-L' '/home/alex' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: bar.o: In function `main::hbeb79415393a4115faa':
bar.rs:(.text._ZN4main20hbeb79415393a4115faaE+0x45): undefined reference to `foo::Baz::foo::h3d69757c908833a5Yaa'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

There are a number of problems with this, and they may likely all be inter-related.

linker error

dead code which is not actually dead code

it should be an error that Baz is a publicly visible private type.

Nominating due to the publicly visible private type not generating an error.