Skip to content

Broken MIR on HRTB #71546

Closed
Closed
@smessmer

Description

@smessmer

Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c0293ace3f56fd3d1d3c79ed971331f3

UPDATE: MCVE is here: #71546 (comment)

Code:

use serde::Serializer;
use itertools::Itertools;

pub fn serialize_as_csv<V, S>(value: &V, serializer: S) -> Result<S::Ok, S::Error>
where
    V: 'static,
    for<'a> &'a V: IntoIterator,
    for<'a> <&'a V as IntoIterator>::Item: ToString + 'static,
    S: Serializer,
{
    let csv_str = value.into_iter().map(|elem| elem.to_string()).join(",");
    serializer.serialize_str(&csv_str)
}

Crashes compiler with

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: broken MIR in DefId(0:5 ~ playground[59fe]::serialize_as_csv[0]) (NoSolution): could not prove Binder(OutlivesPredicate(<&'a V as std::iter::IntoIterator>::Item, ReStatic))
  --> src/lib.rs:11:41
   |
11 |     let csv_str = value.into_iter().map(|elem| elem.to_string()).join(",");
   |                                         ^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:355:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.43.0 (4fb7144ed 2020-04-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-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) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions