Skip to content

-Clink-dead-code doesn't generate dead non-generic items appearing within (instantiated) generic impl blocks #74584

Open
@eggyal

Description

@eggyal

I tried this code:

struct Foo<T>(T);

impl<T> Foo<T> {
    fn foo(&self) {}
    fn bar(&self) {}
}

fn main() {
    let foo = Foo( () );
    foo.foo();
}

When compiled with -Clink-dead-code, I expected to see Foo::<()>::bar in the resulting binary.

Instead, it is omitted.

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (d7f945163 2020-07-19)
binary: rustc
commit-hash: d7f94516345a36ddfcd68cbdf1df835d356795c3
commit-date: 2020-07-19
host: x86_64-apple-darwin
release: 1.47.0-nightly
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Clink-dead-codeLinkage option: -Clink-dead-codeA-codegenArea: Code generationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions