process cycles as soon as they are detected

We used to wait for the recursion limit, but that might well be too
long!
This commit is contained in:
Niko Matsakis 2016-03-28 19:21:10 -04:00
parent f92ce2e9fe
commit 944723b773
3 changed files with 188 additions and 130 deletions

View file

@ -0,0 +1,20 @@
// 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 #32326. We ran out of memory because we
// attempted to expand this case up to the recursion limit, and 2^N is
// too big.
enum Expr { //~ ERROR E0072
Plus(Expr, Expr),
Literal(i64),
}
fn main() { }

View file

@ -20,11 +20,11 @@ struct Baz { q: Option<Foo> }
struct Foo { q: Option<Baz> }
//~^ ERROR recursive type `Foo` has infinite size
//~| type `Foo` is embedded within `std::option::Option<Foo>`...
//~| ...which in turn is embedded within `std::option::Option<Foo>`...
//~| ...which in turn is embedded within `Baz`...
//~| ...which in turn is embedded within `std::option::Option<Baz>`...
//~| ...which in turn is embedded within `Foo`, completing the cycle.
//~| 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) {} }