Skip to content

Commit 95089d3

Browse files
committed
Add tests for super-builtin-kind capabilities (rust-lang#7083)
1 parent 3c3bfb4 commit 95089d3

3 files changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Bar : Send { }
12+
trait Foo : Bar { }
13+
14+
impl <T: Send> Foo for T { }
15+
impl <T: Send> Bar for T { }
16+
17+
fn foo<T: Foo>(val: T, chan: std::comm::Chan<T>) {
18+
chan.send(val);
19+
}
20+
21+
fn main() {
22+
let (p,c) = std::comm::stream();
23+
foo(31337, c);
24+
assert!(p.recv() == 31337);
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:trait_superkinds_in_metadata.rs
12+
13+
extern mod trait_superkinds_in_metadata;
14+
use trait_superkinds_in_metadata::{Foo, Bar};
15+
16+
#[deriving(Eq)]
17+
struct X<T>(T);
18+
19+
impl <T: Freeze> Bar for X<T> { }
20+
impl <T: Freeze+Send> Foo for X<T> { }
21+
22+
fn foo<T: Foo>(val: T, chan: std::comm::Chan<T>) {
23+
chan.send(val);
24+
}
25+
26+
fn main() {
27+
let (p,c) = std::comm::stream();
28+
foo(X(31337), c);
29+
assert!(p.recv() == X(31337));
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo : Send { }
12+
13+
impl <T: Send> Foo for T { }
14+
15+
fn foo<T: Foo>(val: T, chan: std::comm::Chan<T>) {
16+
chan.send(val);
17+
}
18+
19+
fn main() {
20+
let (p,c) = std::comm::stream();
21+
foo(31337, c);
22+
assert!(p.recv() == 31337);
23+
}

0 commit comments

Comments
 (0)