Skip to content

MIR inlining inlines default trait methods #40473

Closed
@arielb1

Description

@arielb1

STR

$ cat mirline.rs
pub trait Foo {
    fn bar(&self) {}
}

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

pub fn main() {
    ().bar();
}
$ rustc mirline.rs -Z mir-opt-level=2
$ ./mirline

Expected Result

Code should print "Hello, World!"

Actual Result

Code does not print anything, because the empty default implementation is inlined.

cc @Aatch

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-mediumMedium 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