rust/src/test/mir-opt/inline-trait-method.rs
Wesley Wiser 69eaa11633 [mir-inlining] Don't inline virtual calls
Prior to this change, the test case would output `1` instead of `2` like
it should.
2018-10-14 13:45:46 -04:00

32 lines
408 B
Rust

// compile-flags: -Z span_free_formats
fn main() {
println!("{}", test(&()));
}
fn test(x: &dyn X) -> u32 {
x.y()
}
trait X {
fn y(&self) -> u32 {
1
}
}
impl X for () {
fn y(&self) -> u32 {
2
}
}
// END RUST SOURCE
// START rustc.test.Inline.after.mir
// ...
// bb0: {
// ...
// _0 = const X::y(move _2) -> bb1;
// }
// ...
// END rustc.test.Inline.after.mir