Closed
Description
This is related to #89196 and #85636 ; but is not the same issue: #85636 is already resolved and #89196 is dealing with a more complex case where inference is lacking.
Also perhaps related to #56556
I'm filing an ICE because that's what I'm hitting as I try to reduce it, however I have a related bug where the workaround from #85636 doesn't actually work. I wonder if fixing the ICE will make this code compile or if it will hit code that needs to be worked around (My unreduced code is at https://github.com/Manishearth/icu4x/tree/rm-rcstruct , cd provider/core && cargo check --all-features
)
Code
Code
trait Yokeable<'a>: 'static {
type Output: 'a;
}
trait IsCovariant<'a> {}
struct Yoke<Y: for<'a> Yokeable<'a>> {
data: Y,
}
impl<Y: for<'a> Yokeable<'a>> Yoke<Y> {
fn project<Y2: for<'a> Yokeable<'a>>(&self, f: for<'a> fn(<Y as Yokeable<'a>>::Output, &'a ()) -> <Y2 as Yokeable<'a>>::Output) -> Yoke<Y2> {
unimplemented!()
}
}
fn upcast<Y>(x: Yoke<Y>) -> Yoke<Box<dyn IsCovariant<'static> + 'static>> where
Y: for<'a> Yokeable<'a>,
for<'a> <Y as Yokeable<'a>>::Output: IsCovariant<'a>
{
x.project(|data, _| {
Box::new(data)
})
}
impl<'a> Yokeable<'a> for Box<dyn IsCovariant<'static> + 'static> {
type Output = Box<dyn IsCovariant<'a> + 'a>;
}
// this impl is mostly an example and unnecessary for the pure repro
use std::borrow::Cow;
impl<'a, T: Clone> Yokeable<'a> for Cow<'static, T> {
type Output = Cow<'a, T>;
}
impl<'a, T: Clone> IsCovariant<'a> for Cow<'a, T> {}
fn main() {}
Meta
rustc --version --verbose
:
<version>
Error output
error: internal compiler error: broken MIR in DefId(0:23 ~ test[68ae]::upcast::{closure#0}) (bb0[0]): equate_normalized_input_or_output: `&[closure@test.rs:23:15: 25:6]==&[closure@test.rs:23:15: 25:6]` failed with `NoSolution`
--> test.rs:23:15
|
23 | x.project(|data, _| {
| _______________^
24 | | Box::new(data)
25 | | })
| |_____^
|
= note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:319:27
Backtrace
error: internal compiler error: broken MIR in DefId(0:23 ~ test[68ae]::upcast::{closure#0}) (bb0[0]): equate_normalized_input_or_output: `&[closure@test.rs:23:15: 25:6]==&[closure@test.rs:23:15: 25:6]` failed with `NoSolution`
--> test.rs:23:15
|
23 | x.project(|data, _| {
| _______________^
24 | | Box::new(data)
25 | | })
| |_____^
|
= note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:319:27
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1166:13
stack backtrace:
0: rust_begin_unwind
at /rustc/efd0483949496b067cd5f7569d1b28cd3d5d3c72/library/std/src/panicking.rs:495:5
1: core::panicking::panic_fmt
at /rustc/efd0483949496b067cd5f7569d1b28cd3d5d3c72/library/core/src/panicking.rs:107:14
2: core::panicking::panic_display
3: rustc_errors::HandlerInner::flush_delayed
4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
5: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
6: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
7: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
8: rustc_span::with_source_map
9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic