Skip to content

Linking error when using a public inherent method on a value of an unnameable type in an external crate. #31568

Closed
@jseyfried

Description

@jseyfried

For example, consider a crate demo:

pub fn f() -> foo::Bar { foo::Bar }

mod foo {
    pub struct Bar;
    impl Bar {
        pub fn baz(&self) {}
    }
}

and another crate that uses demo:

extern crate demo;

fn main() {
    demo::f().baz();
}

Here, demo::foo::Bar is unnameable in the other crate.
Compiling the other crate will cause an error:

error: linking with `cc` failed: exit code: 1
note: /home/ubuntu/demo/target/debug/examples/example.0.o: In function `example::main':
/home/ubuntu/demo/examples/example.rs:4: undefined reference to `foo::Bar::baz::h2fcc0e6532120868paa'
collect2: error: ld returned 1 exit status

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions