Closed
Description
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
andInstanceDef
out oflibrustc_trans
and (probably) intolibrustc
- Rework inlining to use those mechanisms to resolve method calls (including trait ones)