Skip to content

enable mir inlining across trait methods #44389

Closed
@nikomatsakis

Description

@nikomatsakis

As the fix to #40473, @qmx disabled MIR inlining of trait calls altogether. This issue tracks the task of re-enabling the inlining, where possible! This is a slightly more involved task.

Here is the example text:

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

impl Foo for () {
    fn bar(&self) { println!("Hello, World!"); }
}

pub fn main() {
    ().bar();
}

The goal would be to have the call to bar() inlined. But we should draw up some more interesting tasks showing edge-cases: for example, generic functions and so forth (we should be able to use RevealMode::All to "see through" specialization, since inlining executes quite late).

I think roughly speaking the steps to solve this issue "properly" are to:

  • Refactor Instance and InstanceDef out of librustc_trans and (probably) into librustc
  • Rework inlining to use those mechanisms to resolve method calls (including trait ones)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-codegenArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.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