Skip to content

Broken MIR on HRTB #71546

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
smessmer opened this issue Apr 25, 2020 · 10 comments · Fixed by #97580
Closed

Broken MIR on HRTB #71546

smessmer opened this issue Apr 25, 2020 · 10 comments · Fixed by #97580
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@smessmer
Copy link

smessmer commented Apr 25, 2020

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.
@jonas-schievink jonas-schievink added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-prioritize Issue: Indicates that prioritization has been requested for this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 25, 2020
@spastorino
Copy link
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

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Apr 25, 2020
@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2020

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

@chrissimpkins
Copy link
Member

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

@AminArria
Copy link
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

@AminArria
Copy link
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`.

@LeSeulArtichaut LeSeulArtichaut added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 25, 2020
@LeSeulArtichaut
Copy link
Contributor

@LeSeulArtichaut LeSeulArtichaut added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 26, 2020
@hellow554

This comment has been minimized.

@JohnTitor
Copy link
Member

Triage: This ICE has been fixed in the latest nightly, I assume it's fixed by #73503. Marking as E-needs-test.

@JohnTitor JohnTitor added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections labels Jul 28, 2020
@JohnTitor
Copy link
Member

Wait, the original code and #71546 (comment) still triggers the ICE... glacier was tracking with #71546 (comment) but it seems the others encounter another roadblock. Dropping E-needs-test.

@JohnTitor JohnTitor removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 28, 2020
JohnTitor added a commit to JohnTitor/glacier that referenced this issue Jul 28, 2020
Alexendoo added a commit to rust-lang/glacier that referenced this issue Jul 29, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 6, 2020
Add HRTB-related regression test

Closes rust-lang#59311 and cc rust-lang#71546
This closes the former but the test is taken from rust-lang#71546 (comment) since it seems they have the same cause and it's simplified.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 6, 2020
Add HRTB-related regression test

Closes rust-lang#59311 and cc rust-lang#71546
This closes the former but the test is taken from rust-lang#71546 (comment) since it seems they have the same cause and it's simplified.
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 6, 2020
Add HRTB-related regression test

Closes rust-lang#59311 and cc rust-lang#71546
This closes the former but the test is taken from rust-lang#71546 (comment) since it seems they have the same cause and it's simplified.
@Alexendoo
Copy link
Member

No longer ICEs since ff23ad3, likely from #91321

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 4, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue May 31, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 31, 2022
…rrors

Add regression test for rust-lang#71546

Closes rust-lang#71546
r? `@compiler-errors`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 1, 2022
Rollup of 9 pull requests

Successful merges:

 - rust-lang#94647 (Expose `get_many_mut` and `get_many_unchecked_mut` to HashMap)
 - rust-lang#97216 (Ensure we never consider the null pointer dereferencable)
 - rust-lang#97399 (simplify code of finding arg index in `opt_const_param_of`)
 - rust-lang#97470 (rustdoc: add more test coverage)
 - rust-lang#97498 (Corrected EBNF grammar for from_str)
 - rust-lang#97562 (Fix comment in `poly_project_and_unify_type`)
 - rust-lang#97580 (Add regression test for rust-lang#71546)
 - rust-lang#97611 (Tweak insert docs)
 - rust-lang#97616 (Remove an unnecessary `Option`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in a7bd0d0 Jun 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.