Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIR inlining inlines default trait methods #40473

Closed
arielb1 opened this Issue Mar 13, 2017 · 8 comments

Comments

Projects
None yet
8 participants
@arielb1
Copy link
Contributor

arielb1 commented Mar 13, 2017

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

@wesleywiser

This comment has been minimized.

Copy link
Member

wesleywiser commented Mar 16, 2017

Is this just a matter of preventing the inliner from inlining trait default methods?

@arielb1

This comment has been minimized.

Copy link
Contributor Author

arielb1 commented Mar 16, 2017

1.17 is now beta.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 16, 2017

triage: P-medium

Marking this as medium because it requires you to opt-in to the higher "MIR opt level", which is unstable, but we should definitely fix this.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Apr 11, 2017

cc @Aatch @nikomatsakis just pinging for an update.

@arielb1

This comment has been minimized.

Copy link
Contributor Author

arielb1 commented Apr 27, 2017

1.17 is now stable. This is a nightly -> nightly regression affecting only -Z mir-opt-level.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Aug 24, 2017

triage: P-medium

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Aug 31, 2017

I have been talking to @qmx, who is going to take a look at implementing this. I'll leave some mentoring instructions shortly!

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Sep 7, 2017

So #44383 will fix this by just not inlining trait calls -- the simplest possible fix. I just opened #44389 as an enhancement issue to track a more complete fix.

bors added a commit that referenced this issue Sep 11, 2017

Auto merge of #44383 - qmx:gh/40473/no-inline-trait-method, r=nikomat…
…sakis

MIR: should not inline trait method

Fixes #40473.

The idea here is bailing out of inlining if we're talking about a trait method.

@bors bors closed this in #44383 Sep 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.