Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mir-inlining] Don't inline virtual calls
Prior to this change, the test case would output `1` instead of `2` like it should.
- Loading branch information
1 parent
24faa97
commit 69eaa11
Showing
2 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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 |