2016-11-04 03:34:54 -05:00
|
|
|
// This is a regression test for the ICE from issue #10846.
|
|
|
|
//
|
|
|
|
// The original issue causing the ICE: the LUB-computations during
|
|
|
|
// type inference were encountering late-bound lifetimes, and
|
|
|
|
// asserting that such lifetimes should have already been substituted
|
|
|
|
// with a concrete lifetime.
|
|
|
|
//
|
|
|
|
// However, those encounters were occurring within the lexical scope
|
|
|
|
// of the binding for the late-bound lifetime; that is, the late-bound
|
2019-02-15 19:43:56 -06:00
|
|
|
// lifetimes were perfectly valid. The core problem was that the type
|
2016-11-04 03:34:54 -05:00
|
|
|
// folding code was over-zealously passing back all lifetimes when
|
|
|
|
// doing region-folding, when really all clients of the region-folding
|
2019-02-15 19:43:56 -06:00
|
|
|
// case only want to see *free* lifetime variables, not bound ones.
|
2016-11-04 03:34:54 -05:00
|
|
|
|
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
fn explicit() {
|
2022-06-22 00:57:06 -05:00
|
|
|
fn test<F>(_x: Option<Box<F>>)
|
|
|
|
where
|
|
|
|
F: FnMut(Box<dyn for<'a> FnMut(&'a isize)>),
|
|
|
|
{
|
|
|
|
}
|
2019-05-30 03:58:30 -05:00
|
|
|
test(Some(box |_f: Box<dyn for<'a> FnMut(&'a isize)>| {}));
|
2016-11-04 03:34:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// The code below is shorthand for the code above (and more likely
|
|
|
|
// to represent what one encounters in practice).
|
|
|
|
fn implicit() {
|
2022-06-22 00:57:06 -05:00
|
|
|
fn test<F>(_x: Option<Box<F>>)
|
|
|
|
where
|
|
|
|
F: FnMut(Box<dyn FnMut(&isize)>),
|
|
|
|
{
|
|
|
|
}
|
|
|
|
test(Some(box |_f: Box<dyn FnMut(&isize)>| {}));
|
2016-11-04 03:34:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit();
|
|
|
|
implicit();
|
|
|
|
}
|