Skip to content

Commit 4fd404f

Browse files
committed
Fixup style of test cases for rust-lang#7083
1 parent 95089d3 commit 4fd404f

12 files changed

+50
-12
lines changed

src/test/auxiliary/trait_superkinds_in_metadata.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test library crate for cross-crate usages of traits inheriting
12+
// from the builtin kinds. Mostly tests metadata correctness.
13+
1114
#[crate_type="lib"];
1215

13-
pub trait Bar : Freeze { }
14-
pub trait Foo : Bar + Send { }
16+
pub trait RequiresFreeze : Freeze { }
17+
pub trait RequiresRequiresFreezeAndSend : RequiresFreeze + Send { }

src/test/compile-fail/builtin-superkinds-double-superkind.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test for traits that inherit from multiple builtin kinds at once,
12+
// testing that all such kinds must be present on implementing types.
13+
1114
trait Foo : Send+Freeze { }
1215

1316
impl <T: Freeze> Foo for (T,) { } //~ ERROR cannot implement this trait

src/test/compile-fail/builtin-superkinds-in-metadata.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010

1111
// aux-build:trait_superkinds_in_metadata.rs
1212

13+
// Test for traits inheriting from the builtin kinds cross-crate.
14+
// Mostly tests correctness of metadata.
15+
1316
extern mod trait_superkinds_in_metadata;
14-
use trait_superkinds_in_metadata::{Foo, Bar};
17+
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
1518

1619
struct X<T>(T);
1720

18-
impl <T:Freeze> Bar for X<T> { }
21+
impl <T:Freeze> RequiresFreeze for X<T> { }
1922

20-
impl <T:Freeze> Foo for X<T> { } //~ ERROR cannot implement this trait
23+
impl <T:Freeze> RequiresRequiresFreezeAndSend for X<T> { } //~ ERROR cannot implement this trait
2124

2225
fn main() { }

src/test/compile-fail/builtin-superkinds-simple.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Basic test for traits inheriting from the builtin kinds, checking
12+
// the type contents of the implementing type (that's not a typaram).
13+
1114
trait Foo : Send { }
1215

1316
impl <'self> Foo for &'self mut () { } //~ ERROR cannot implement this trait

src/test/compile-fail/builtin-superkinds-typaram-not-send.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Basic test for traits inheriting from the builtin kinds.
12+
1113
trait Foo : Send { }
1214

1315
impl <T: Freeze> Foo for T { } //~ ERROR cannot implement this trait

src/test/run-pass/builtin-superkinds-capabilities-transitive.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Tests "transitivity" of super-builtin-kinds on traits. Here, if
12+
// we have a Foo, we know we have a Bar, and if we have a Bar, we
13+
// know we have a Send. So if we have a Foo we should know we have
14+
// a Send. Basically this just makes sure rustc is using
15+
// each_bound_trait_and_supertraits in type_contents correctly.
16+
1117
trait Bar : Send { }
1218
trait Foo : Bar { }
1319

src/test/run-pass/builtin-superkinds-capabilities-xc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@
1010

1111
// aux-build:trait_superkinds_in_metadata.rs
1212

13+
// Tests "capabilities" granted by traits with super-builtin-kinds,
14+
// even when using them cross-crate.
15+
1316
extern mod trait_superkinds_in_metadata;
14-
use trait_superkinds_in_metadata::{Foo, Bar};
17+
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
1518

1619
#[deriving(Eq)]
1720
struct X<T>(T);
1821

19-
impl <T: Freeze> Bar for X<T> { }
20-
impl <T: Freeze+Send> Foo for X<T> { }
22+
impl <T: Freeze> RequiresFreeze for X<T> { }
23+
impl <T: Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
2124

22-
fn foo<T: Foo>(val: T, chan: std::comm::Chan<T>) {
25+
fn foo<T: RequiresRequiresFreezeAndSend>(val: T, chan: std::comm::Chan<T>) {
2326
chan.send(val);
2427
}
2528

src/test/run-pass/builtin-superkinds-capabilities.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Tests "capabilities" granted by traits that inherit from super-
12+
// builtin-kinds, e.g., if a trait requires Send to implement, then
13+
// at usage site of that trait, we know we have the Send capability.
14+
1115
trait Foo : Send { }
1216

1317
impl <T: Send> Foo for T { }

src/test/run-pass/builtin-superkinds-in-metadata.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
// aux-build:trait_superkinds_in_metadata.rs
1212

13+
// Tests (correct) usage of trait super-builtin-kinds cross-crate.
14+
1315
extern mod trait_superkinds_in_metadata;
14-
use trait_superkinds_in_metadata::{Foo, Bar};
16+
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
1517

1618
struct X<T>(T);
1719

18-
impl <T:Freeze> Bar for X<T> { }
20+
impl <T:Freeze> RequiresFreeze for X<T> { }
1921

20-
impl <T:Freeze+Send> Foo for X<T> { }
22+
impl <T:Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
2123

2224
fn main() { }

src/test/run-pass/builtin-superkinds-shadow-typaram.rs renamed to src/test/run-pass/builtin-superkinds-phantom-typaram.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Tests that even when a type paramenter doesn't implement a required
12+
// super-builtin-kind of a trait, if the type parameter is never used,
13+
// the type can implement the trait anyway.
14+
1115
trait Foo : Send { }
1216

1317
struct X<T>(());

src/test/run-pass/builtin-superkinds-simple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Simple test case of implementing a trait with super-builtin-kinds.
12+
1113
trait Foo : Send { }
1214

1315
impl Foo for int { }

src/test/run-pass/builtin-superkinds-typaram.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Tests correct implementation of traits with super-builtin-kinds
12+
// using a bounded type parameter.
13+
1114
trait Foo : Send { }
1215

1316
impl <T: Send> Foo for T { }

0 commit comments

Comments
 (0)