Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c0293ace3f56fd3d1d3c79ed971331f3
UPDATE: MCVE is here: https://github.com/rust-lang/rust/issues/71546#issuecomment-619446412
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.
Would be nice to figure out if this is a regression or not and if it is when has this regressed.
@rustbot ping cleanup
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
It has been present since at least 2019-08-01 according to bisect-rustc
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
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`.
Assigning P-medium as discussed as part of the Prioritization WG procedure
Even simpler:
pub trait T {
fn t<F: Fn()>(&self, _: F) {}
}
pub fn crash<V>(v: &V)
where
for<'a> &'a V: T + 'static,
{
v.t(|| {});
}
Triage: This ICE has been fixed in the latest nightly, I assume it's fixed by #73503. Marking as E-needs-test.
Wait, the original code and https://github.com/rust-lang/rust/issues/71546#issuecomment-619446412 still triggers the ICE... glacier was tracking with https://github.com/rust-lang/rust/issues/71546#issuecomment-620638437 but it seems the others encounter another roadblock. Dropping E-needs-test.
Most helpful comment
From what I can tell the first time this ICE would happen is in 1.24.0