-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE on closures of trait bounds with indefinite lifetime parameters #74261
Comments
Presumably part of #62529 |
Encountered the same issues, here's the minimal example I managed to put together (playground): pub trait Trait<'a> {
type Output;
fn output(self) -> Self::Output;
}
impl<'a> Trait<'a> for () {
type Output = ();
fn output(self) -> () {
()
}
}
fn confused_hrtb<T, F>(value: T, f: F)
where
T: for<'a> Trait<'a>,
F: for<'b> FnOnce(<T as Trait<'b>>::Output),
{
f(value.output())
}
fn main() -> () {
confused_hrtb((), |_| ());
} |
Encountered a seemingly related ICE as well :( pub trait Ref<'a> {
type Type: Clone;
}
impl<'a, T: 'static + Clone> Ref<'a> for T {
type Type = T;
}
pub type EvalFn<I> = dyn FnMut(&<I as Ref<'_>>::Type);
pub trait Evaluator<T: for<'a> Ref<'a>> {
fn make_evaluator(&self) -> Box<EvalFn<T>>;
}
pub struct A;
impl Evaluator<i32> for A {
fn make_evaluator(&self) -> Box<EvalFn<i32>> {
Box::new(|_x| {})
}
}
fn main() {
let mut x: Vec<Box<EvalFn<i32>>> = vec![];
x.push(A.make_evaluator());
} resulting in
|
(Updated the link from the previously posted comment) One way to work around the ICE - wrapping closures in structs: example that seems to avoid the ICE in the above snippet. |
No longer ICEs with #85499, but emits an error. Need to look more into it to see if expected. |
It seems that a trait bound like
for<'a> FnOnce(<TT as A<'a>>::B)
, when applied to a closure, will cause an internal compiler error.Code
Meta
Tested on the playground with stable, beta and nightly versions:
This error also occurs on my local pc.
Error output
Backtrace
The text was updated successfully, but these errors were encountered: