Separate supertrait collection from processing a TraitDef. This allows

us to construct trait-references and do other things without forcing a
full evaluation of the supertraits. One downside of this scheme is that
we must invoke `ensure_super_predicates` before using any construct that
might require knowing about the super-predicates.
This commit is contained in:
Niko Matsakis 2015-02-24 09:24:42 -05:00
parent 4ee002a17c
commit bc9ae36dba
23 changed files with 486 additions and 416 deletions

View file

@ -25,7 +25,7 @@ trait Trait { type Item; }
struct A<T>
where T : Trait,
T : Add<T::Item>
//~^ ERROR illegal recursive type
//~^ ERROR unsupported cyclic reference between types/traits detected
{
data: T
}

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,8 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Foo {}
// Test a cycle where a type parameter on a trait has a default that
// again references the trait.
fn foo<T: Foo + Foo>() {} //~ ERROR `Foo` already appears in the list of bounds
trait Foo<X = Box<Foo>> {
//~^ ERROR unsupported cyclic reference
}
fn main() {}
fn main() { }

View file

@ -12,9 +12,12 @@
// a direct participant in the cycle.
trait A: B {
//~^ ERROR unsupported cyclic reference
}
trait B: C { }
trait B: C {
//~^ ERROR unsupported cyclic reference
}
trait C: B { }
//~^ ERROR unsupported cyclic reference

View file

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: illegal recursive type
type x = Vec<x>;
//~^ ERROR unsupported cyclic reference
fn main() { let b: x = Vec::new(); }

View file

@ -12,18 +12,17 @@
use std::any::Any;
use std::any::TypeId;
use std::marker::MarkerTrait;
pub trait Pt {}
pub trait Rt {}
pub trait Pt : MarkerTrait {}
pub trait Rt : MarkerTrait {}
trait Private<P: Pt, R: Rt> {
fn call(&self, p: P, r: R);
}
pub trait Public: Private<
pub trait Public: Private< //~ ERROR private trait in exported type parameter bound
<Self as Public>::P,
//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired
<Self as Public>::R
//~^ ERROR unsupported cyclic reference between types/traits detected
> {
type P;
type R;

View file

@ -13,7 +13,6 @@
use std::cmp::PartialEq;
trait Hahaha: PartialEq + PartialEq {
//~^ ERROR trait `PartialEq` already appears in the list of bounds
}
struct Lol(isize);
@ -21,8 +20,8 @@ struct Lol(isize);
impl Hahaha for Lol { }
impl PartialEq for Lol {
fn eq(&self, other: &Lol) -> bool { **self != **other }
fn ne(&self, other: &Lol) -> bool { **self == **other }
fn eq(&self, other: &Lol) -> bool { loop { } }
fn ne(&self, other: &Lol) -> bool { loop { } }
}
fn main() {