2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2016-04-16 12:16:36 +00:00
|
|
|
// Regression test for #31299. This was generating an overflow error
|
|
|
|
// because of eager normalization:
|
|
|
|
//
|
|
|
|
// proving `M: Sized` requires
|
2016-04-22 13:38:17 +00:00
|
|
|
// - proving `PtrBack<Vec<M>>: Sized` requires
|
2016-04-16 12:16:36 +00:00
|
|
|
// - normalizing `Vec<<Vec<M> as Front>::Back>>: Sized` requires
|
|
|
|
// - proving `Vec<M>: Front` requires
|
|
|
|
// - `M: Sized` <-- cycle!
|
|
|
|
//
|
|
|
|
// If we skip the normalization step, though, everything goes fine.
|
2016-04-22 13:38:17 +00:00
|
|
|
//
|
|
|
|
// This could be fixed by implementing lazy normalization everywhere.
|
|
|
|
//
|
|
|
|
// However, we want this to work before then. For that, when checking
|
|
|
|
// whether a type is Sized we only check that the tails are Sized. As
|
|
|
|
// PtrBack does not have a tail, we don't need to normalize anything
|
|
|
|
// and this compiles
|
2016-04-16 12:16:36 +00:00
|
|
|
|
|
|
|
trait Front {
|
|
|
|
type Back;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Front for Vec<T> {
|
|
|
|
type Back = Vec<T>;
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:36:03 +00:00
|
|
|
struct PtrBack<T: Front>(#[allow(unused_tuple_struct_fields)] Vec<T::Back>);
|
2016-04-16 12:16:36 +00:00
|
|
|
|
2022-07-25 20:36:03 +00:00
|
|
|
struct M(#[allow(unused_tuple_struct_fields)] PtrBack<Vec<M>>);
|
2016-04-16 12:16:36 +00:00
|
|
|
|
2021-10-13 02:28:14 +00:00
|
|
|
#[allow(unused_must_use)]
|
2016-04-16 12:16:36 +00:00
|
|
|
fn main() {
|
|
|
|
std::mem::size_of::<M>();
|
|
|
|
}
|