Skip to content

Broken MIR: generator contains type ... after copy & destination propagation #76375

@tmiasko

Description

@tmiasko
Contributor

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.

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Sep 5, 2020
changed the title [-]Broken MIR: generator contains type ... after copy propagation[/-] [+]Broken MIR: generator contains type ... after copy & destination propagation[/+] on Sep 21, 2020
JohnTitor

JohnTitor commented on Sep 29, 2020

@JohnTitor
Member

The ICE is no longer reproduced with the latest nightly on glacier, marking as E-needs-test.

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Sep 29, 2020
tmiasko

tmiasko commented on Sep 29, 2020

@tmiasko
ContributorAuthor

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

JohnTitor commented on Sep 30, 2020

@JohnTitor
Member

@tmiasko Thanks for the heads-up!

Submitted a PR to readd this: rust-lang/glacier#479

removed
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Sep 30, 2020

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coroutinesArea: CoroutinesA-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @jonas-schievink@JohnTitor@tmiasko@rust-lang-glacier-bot

      Issue actions

        Broken MIR: generator contains type ... after copy & destination propagation · Issue #76375 · rust-lang/rust