Skip to content

Broken MIR on HRTB #71546

Closed
Closed

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.

Activity

  1. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 25, 2020
  2. spastorino commented on Apr 25, 2020

    @spastorino
    Member

    Would be nice to figure out if this is a regression or not and if it is when has this regressed.

    @rustbot ping cleanup

  3. rustbot commented on Apr 25, 2020

    @rustbot
    Collaborator

    Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
    "Cleanup ICE-breaking candidate". In case it's useful, here are some
    instructions for tackling these sorts of bugs. Maybe take a look?
    Thanks! <3

    cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

  4. chrissimpkins commented on Apr 25, 2020

    @chrissimpkins
    Contributor

    It has been present since at least 2019-08-01 according to bisect-rustc

  5. AminArria commented on Apr 25, 2020

    @AminArria
    Contributor

    Simplified code to remove dependencies

    pub fn serialize_as_csv<V>(value: &V) -> Result<String, &str>
    where
        V: 'static,
        for<'a> &'a V: IntoIterator,
        for<'a> <&'a V as IntoIterator>::Item: ToString + 'static
    {
        let csv_str: String = value.into_iter().map(|elem| elem.to_string()).collect::<String>();
        Ok(csv_str)
    }

    This compiles for 1.20.0 and not for 1.30.0 (setting edition to 2015)

    I'll try and pinpoint at least the version where it causes the ICE

  6. AminArria commented on Apr 25, 2020

    @AminArria
    Contributor

    From what I can tell the first time this ICE would happen is in 1.24.0

    ~/r/i71546> cargo +1.24.0 build
       Compiling i71546 v0.1.0 (file:///Users/aminarria/rust-cleanup/i71546)
    error: internal compiler error: broken MIR in NodeId(4) (""): errors selecting obligation: [FulfillmentError(Obligation(predicate=Binder(OutlivesPredicate(<&'a V as std::iter::IntoIterator>::Item, ReStatic)),depth=0),Unimplemented)]
     --> src/lib.rs:7:49
      |
    7 |     let csv_str: String = value.into_iter().map(|elem| elem.to_string()).collect::<String>();
      |                                                 ^^^^^^^^^^^^^^^^^^^^^^^
    
    error: aborting due to previous error
    
    error: Could not compile `i71546`.
    
  7. LeSeulArtichaut commented on Apr 26, 2020

    @LeSeulArtichaut
    Contributor
  8. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Apr 26, 2020
  9. 7 remaining items

  10. added a commit that references this issue on Jul 28, 2020
  11. added a commit that references this issue on Jul 29, 2020
  12. added 2 commits that reference this issue on Aug 6, 2020
  13. added a commit that references this issue on Aug 6, 2020
  14. Alexendoo commented on Dec 4, 2021

    @Alexendoo
    Member

    No longer ICEs since ff23ad3, likely from #91321

  15. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Dec 4, 2021
  16. added a commit that references this issue on May 31, 2022
  17. added a commit that references this issue on Jun 1, 2022
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-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