Description
x.rs:
#![crate_type = "lib"]
#[inline(always)]
pub fn f(s: bool) -> String {
let a = "Hello world!".to_string();
let b = a;
let c = b;
if s {
c
} else {
String::new()
}
}
y.rs
#![crate_type = "lib"]
pub async fn g() {
x::f(true);
h().await;
}
pub async fn h() {}
$ rustc --edition=2018 -Zmir-opt-level=2 x.rs -Zunsound-mir-opts x.rs
$ rustc --edition=2018 -Zmir-opt-level=2 y.rs --extern x -L.
error: internal compiler error: src/librustc_mir/transform/generator.rs:752:13: Broken MIR: generator contains type std::string::String in MIR, but typeck only knows about {std::future::ResumeTy, impl std::future::Future, ()}
The copy propagation removes storage markers during optimization. Afterwards state transforms considers them to be always live across yield. Due to pass ordering, requires inliner to expose the issue.
Metadata
Metadata
Assignees
Labels
Area: CoroutinesArea: MIR optimizationsCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.
Activity
[-]Broken MIR: generator contains type ... after copy propagation[/-][+]Broken MIR: generator contains type ... after copy & destination propagation[/+]JohnTitor commentedon Sep 29, 2020
The ICE is no longer reproduced with the latest nightly on glacier, marking as
E-needs-test
.tmiasko commentedon Sep 29, 2020
For copy propagation this is still an issue, but the test case now requires
-Zunsound-mir-opts
.For destination propagation the test case was fixed after changes that stop propagation if either local was ever borrowed. Hard to say if this fixed the issue more generally.
JohnTitor commentedon Sep 30, 2020
@tmiasko Thanks for the heads-up!
Submitted a PR to readd this: rust-lang/glacier#479
10 remaining items