add comments and tests
This commit is contained in:
parent
73f39a026a
commit
4bcabbd45a
6 changed files with 73 additions and 13 deletions
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Baz { q: Option<Foo> }
|
||||
//~^ ERROR recursive type `Baz` has infinite size
|
||||
|
||||
struct Foo { q: Option<Baz> }
|
||||
//~^ ERROR recursive type `Foo` has infinite size
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: overflow representing the type `S`
|
||||
|
||||
trait Mirror { type It: ?Sized; }
|
||||
impl<T: ?Sized> Mirror for T { type It = Self; }
|
||||
struct S(Option<<S as Mirror>::It>);
|
||||
//~^ ERROR recursive type `S` has infinite size
|
||||
|
||||
fn main() {
|
||||
let _s = S(None);
|
||||
|
|
|
|||
|
|
@ -23,5 +23,4 @@ pub fn main() {
|
|||
let arr: &[_] = &[1, 2, 3];
|
||||
let range = *arr..;
|
||||
//~^ ERROR `[_]: std::marker::Sized` is not satisfied
|
||||
//~| ERROR `[_]: std::marker::Sized` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,9 @@
|
|||
// 2. it should elaborate the steps that led to the cycle.
|
||||
|
||||
struct Baz { q: Option<Foo> }
|
||||
|
||||
//~^ ERROR recursive type `Baz` has infinite size
|
||||
struct Foo { q: Option<Baz> }
|
||||
//~^ ERROR recursive type `Foo` has infinite size
|
||||
//~| NOTE type `Foo` is embedded within `std::option::Option<Foo>`...
|
||||
//~| NOTE ...which in turn is embedded within `std::option::Option<Foo>`...
|
||||
//~| NOTE ...which in turn is embedded within `Baz`...
|
||||
//~| NOTE ...which in turn is embedded within `std::option::Option<Baz>`...
|
||||
//~| NOTE ...which in turn is embedded within `Foo`, completing the cycle.
|
||||
|
||||
impl Foo { fn bar(&self) {} }
|
||||
|
||||
|
|
|
|||
36
src/test/run-pass/issue-31299.rs
Normal file
36
src/test/run-pass/issue-31299.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Regression test for #31299. This was generating an overflow error
|
||||
// because of eager normalization:
|
||||
//
|
||||
// proving `M: Sized` requires
|
||||
// - proving `PtrBack<Vec<M>>: Sized` requis
|
||||
// - 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.
|
||||
|
||||
trait Front {
|
||||
type Back;
|
||||
}
|
||||
|
||||
impl<T> Front for Vec<T> {
|
||||
type Back = Vec<T>;
|
||||
}
|
||||
|
||||
struct PtrBack<T: Front>(Vec<T::Back>);
|
||||
|
||||
struct M(PtrBack<Vec<M>>);
|
||||
|
||||
fn main() {
|
||||
std::mem::size_of::<M>();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue