From bc9ae36dba3bcacdec98af1495d99593bfc59cac Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 24 Feb 2015 09:24:42 -0500 Subject: 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. --- .../cycle-projection-based-on-where-clause.rs | 2 +- .../compile-fail/cycle-trait-default-type-trait.rs | 18 ++++++++++++++++++ .../compile-fail/cycle-trait-supertrait-indirect.rs | 5 ++++- src/test/compile-fail/duplicate-trait-bounds.rs | 15 --------------- src/test/compile-fail/infinite-vec-type-recursion.rs | 4 +--- src/test/compile-fail/issue-18389.rs | 9 ++++----- src/test/compile-fail/issue-3953.rs | 5 ++--- 7 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 src/test/compile-fail/cycle-trait-default-type-trait.rs delete mode 100644 src/test/compile-fail/duplicate-trait-bounds.rs (limited to 'src/test') diff --git a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs index abcbf567d44..5ca0700ce6e 100644 --- a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs +++ b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs @@ -25,7 +25,7 @@ trait Trait { type Item; } struct A where T : Trait, T : Add - //~^ ERROR illegal recursive type + //~^ ERROR unsupported cyclic reference between types/traits detected { data: T } diff --git a/src/test/compile-fail/cycle-trait-default-type-trait.rs b/src/test/compile-fail/cycle-trait-default-type-trait.rs new file mode 100644 index 00000000000..e6caeb34a8c --- /dev/null +++ b/src/test/compile-fail/cycle-trait-default-type-trait.rs @@ -0,0 +1,18 @@ +// 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. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a cycle where a type parameter on a trait has a default that +// again references the trait. + +trait Foo> { + //~^ ERROR unsupported cyclic reference +} + +fn main() { } diff --git a/src/test/compile-fail/cycle-trait-supertrait-indirect.rs b/src/test/compile-fail/cycle-trait-supertrait-indirect.rs index 6ebd9a1bcb6..c9bfde3f4ed 100644 --- a/src/test/compile-fail/cycle-trait-supertrait-indirect.rs +++ b/src/test/compile-fail/cycle-trait-supertrait-indirect.rs @@ -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 diff --git a/src/test/compile-fail/duplicate-trait-bounds.rs b/src/test/compile-fail/duplicate-trait-bounds.rs deleted file mode 100644 index d9aa9d9dfcc..00000000000 --- a/src/test/compile-fail/duplicate-trait-bounds.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo {} - -fn foo() {} //~ ERROR `Foo` already appears in the list of bounds - -fn main() {} diff --git a/src/test/compile-fail/infinite-vec-type-recursion.rs b/src/test/compile-fail/infinite-vec-type-recursion.rs index 5bcba350b2e..e5120840f76 100644 --- a/src/test/compile-fail/infinite-vec-type-recursion.rs +++ b/src/test/compile-fail/infinite-vec-type-recursion.rs @@ -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; +//~^ ERROR unsupported cyclic reference fn main() { let b: x = Vec::new(); } diff --git a/src/test/compile-fail/issue-18389.rs b/src/test/compile-fail/issue-18389.rs index 9065a5b9605..271c31bd375 100644 --- a/src/test/compile-fail/issue-18389.rs +++ b/src/test/compile-fail/issue-18389.rs @@ -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 { fn call(&self, p: P, r: R); } -pub trait Public: Private< +pub trait Public: Private< //~ ERROR private trait in exported type parameter bound ::P, -//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired ::R -//~^ ERROR unsupported cyclic reference between types/traits detected > { type P; type R; diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs index 0f1dd2d7fd6..678a7806e7a 100644 --- a/src/test/compile-fail/issue-3953.rs +++ b/src/test/compile-fail/issue-3953.rs @@ -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() { -- cgit 1.4.1-3-g733a5