-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #101050 - pnkfelix:revert-mir-inline-policy-for-beta-1.…
…64, r=compiler-errors revert mir inlining policy for beta-1.64 revert mir inlining policy for beta-1.64 Fix #101004
- Loading branch information
Showing
4 changed files
with
95 additions
and
10 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
39 changes: 39 additions & 0 deletions
39
src/test/ui/issues/issue-100550-normalization-ice-exposed-by-mir-inlining.rs
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,39 @@ | ||
// check-pass | ||
|
||
// compile-flags: --emit=mir,link -O | ||
|
||
// There is an ICE somewhere in type normalization, and we are hitting it during | ||
// the MIR inlining pass on this code. | ||
// | ||
// Long term, we should fix that ICE and change the compile-flags for this test | ||
// to explicitly enable MIR inlining. | ||
// | ||
// Short term, we are diabling MIR inlining for Rust 1.64-beta, so that we avoid | ||
// this ICE in this instance. | ||
|
||
pub trait Trait { | ||
type Associated; | ||
} | ||
impl<T> Trait for T { | ||
type Associated = T; | ||
} | ||
|
||
pub struct Struct<T>(<T as Trait>::Associated); | ||
|
||
pub fn foo<T>() -> Struct<T> | ||
where | ||
T: Trait, | ||
{ | ||
bar() | ||
} | ||
|
||
#[inline] | ||
fn bar<T>() -> Struct<T> { | ||
Struct(baz()) | ||
} | ||
|
||
fn baz<T>() -> T { | ||
unimplemented!() | ||
} | ||
|
||
fn main() { } |
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,42 @@ | ||
// check-pass | ||
|
||
// compile-flags: --emit=mir,link -O | ||
|
||
// At one point the MIR inlining, when guarding against infinitely (or even just | ||
// excessive) recursion, was using `ty::Instance` as the basis for its history | ||
// check. The problem is that when you have polymorphic recursion, you can have | ||
// distinct instances of the same code (because you're inlining the same code | ||
// with differing substitutions), causing the amount of inlining to blow up | ||
// exponentially. | ||
// | ||
// This test illustrates an example of that filed in issue rust#100476. | ||
|
||
#![allow(unconditional_recursion)] | ||
#![feature(decl_macro)] | ||
|
||
macro emit($($m:ident)*) {$( | ||
// Randomize `def_path_hash` by defining them under a module with | ||
// different names | ||
pub mod $m { | ||
pub trait Tr { | ||
type Next: Tr; | ||
} | ||
|
||
pub fn hoge<const N: usize, T: Tr>() { | ||
inner::<N, T>(); | ||
} | ||
|
||
#[inline(always)] | ||
fn inner<const N: usize, T: Tr>() { | ||
inner::<N, T::Next>(); | ||
} | ||
} | ||
)*} | ||
|
||
// Increase the chance of triggering the bug | ||
emit!( | ||
m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 | ||
m10 m11 m12 m13 m14 m15 m16 m17 m18 m19 | ||
); | ||
|
||
fn main() { } |