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

Linker error with private default methods used in a reachable method #11225

Closed
alexcrichton opened this issue Dec 30, 2013 · 1 comment
Closed

Comments

@alexcrichton
Copy link
Member

// foo.rs
mod inner {
    pub trait Trait {
        fn f(&self) { f(); }
    }

    impl Trait for int {}

    fn f() {}
}

pub fn foo<T: inner::Trait>(t: T) {
    t.f();
}
// bar.rs
extern mod foo;

fn main() {
    foo::foo(1);
}
$ rustc --lib foo.rs && rustc bar.rs -L.
foo.rs:8:4: 8:13 warning: code is never used: `f`, #[warn(dead_code)] on by default
foo.rs:8     fn f() {}
             ^~~~~~~~~
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/Users/alex/code/rust/lib/rustc/x86_64-apple-darwin/lib' '-o' 'bar' 'ba
r.o' '-L.' '-L/Users/alex/.rust' '-L/Users/alex' '-L/Users/alex/code/rust/lib/rustc/x86_64-apple-darw
in/lib' '-lstd-04ff901e-0.9-pre' '-L/Users/alex/code/rust/lib/rustc/x86_64-apple-darwin/lib' '-lgreen
-3b3a1962-0.9-pre' '-L/Users/alex/code/rust/lib/rustc/x86_64-apple-darwin/lib' '-lrustuv-7945354c-0.9
-pre' '-L.' '-lfoo-d4ab21d1-0.0' '-lpthread' '-lpthread' '-lmorestack' '-Wl,-rpath,@loader_path/code/
rust/lib/rustc/x86_64-apple-darwin/lib' '-Wl,-rpath,@loader_path/.' '-Wl,-rpath,/Users/alex/code/rust
/lib/rustc/x86_64-apple-darwin/lib' '-Wl,-rpath,/Users/alex'
note: Undefined symbols for architecture x86_64:
  "inner::f::h43f55e4ef1329dc2ab2b267e3dc9c21bd52230ed306d9a8f6f7cb8ea5526a838as::v0.0", referenced f
rom:
      inner::Trait::f::hbd66fdcd540500244e27378cca1f28a6e912ee31306da03d825a85f9538b613fah::v0.0 in b
ar.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
task 'rustc' failed at 'explicit failure', /Users/alex/code/rust2/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /Users/alex/code/rust2/src/librustc/lib.rs:441
@alexcrichton
Copy link
Member Author

Another possibly related case which needs fixing:

// foo.rs
use inner::Trait;

mod inner {
    pub struct Foo;
    pub trait Trait {
        fn f(&self);
    }

    impl Trait for Foo {
        fn f(&self) { }
    }
}

pub trait Outer {
    fn foo<T: Trait>(&self, t: T) { t.f(); }
}

impl Outer for int {}

pub fn foo<T: Outer>(t: T) {
    t.foo(inner::Foo);
}
// bar.rs
extern mod foo;

fn main() {
    foo::foo(1);
}

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 31, 2023
…r=flip1995

Fix integration tests rust-lang#2

fix integration tests.

It turned out that the following tests fail to build at all:

chalk, combine, stdarch and hyper.

This is often a problem of passing `--all-targets --all-features`, in case of combine though, outdated deps were to blame.

I have opened tickets against combine and rustfmt
rust-lang/rustfmt#5859
Marwes/combine#357

should we just remove the other failing repos? :/

changelog: fix integration tests on ci
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