]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/run-pass/issues/issue-31299.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 // Regression test for #31299. This was generating an overflow error
13 // because of eager normalization:
15 // proving `M: Sized` requires
16 // - proving `PtrBack<Vec<M>>: Sized` requires
17 // - normalizing `Vec<<Vec<M> as Front>::Back>>: Sized` requires
18 // - proving `Vec<M>: Front` requires
19 // - `M: Sized` <-- cycle!
21 // If we skip the normalization step, though, everything goes fine.
23 // This could be fixed by implementing lazy normalization everywhere.
25 // However, we want this to work before then. For that, when checking
26 // whether a type is Sized we only check that the tails are Sized. As
27 // PtrBack does not have a tail, we don't need to normalize anything
34 impl<T
> Front
for Vec
<T
> {
38 struct PtrBack
<T
: Front
>(Vec
<T
::Back
>);
40 struct M(PtrBack
<Vec
<M
>>);
43 std
::mem
::size_of
::<M
>();