Skip to content

Methods that return unsized types can be (uselessly) codegened #26376

Closed
@arielb1

Description

@arielb1
trait Foo {
    fn foo(&self) -> [u8];
}

fn foo(f: Option<&Foo>) {
    if let Some(f) = f {
        let _ = f.foo();
    }
}

fn main() { foo(None) }

This does generate code that calls foo in the vtable, but is not particularly useful.

cc @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.P-lowLow priorityT-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