Skip to content

Public methods on private types are not exported symbols #11685

Closed
@huonw

Description

@huonw
// foo.rs
struct Foo;

impl Foo {
    pub fn bar(&self) {}
}

pub fn foo() -> Foo { Foo }
extern mod foo;

fn main() {
    foo::foo().bar();
}
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'foo' 'foo.o' '-Wl,--as-needed' '-L.' '-L/home/huon/projects/test-rust/.rust' '-L/home/huon/projects/test-rust' '-L/home/huon/.rust' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lstd-3e5aeb83-0.9' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lgreen-83b1c0e5-0.9' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustuv-2ba3695a-0.9' '-L.' '-lfoo-23ba3019-0.0' '-ldl' '-lm' '-lpthread' '-lpthread' '-lrt' '-lmorestack' '-Wl,-rpath,$ORIGIN/../../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,$ORIGIN/.' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/home/huon/projects/test-rust'
note: foo.o: In function `main::he2babae7630579acai::v0.0':
foo.rc:(.text+0x46): undefined reference to `Foo::bar::hc8b32dcced346a16vjaI::v0.0'
collect2: error: ld returned 1 exit status

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binaries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions