test: Remove Freeze / NoFreeze from tests
This commit is contained in:
parent
b4ddee6327
commit
90e9d8ee62
@ -13,6 +13,6 @@
|
||||
|
||||
#[crate_type="lib"];
|
||||
|
||||
pub trait RequiresFreeze : Freeze { }
|
||||
pub trait RequiresRequiresFreezeAndSend : RequiresFreeze + Send { }
|
||||
pub trait RequiresShare : Share { }
|
||||
pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
|
||||
pub trait RequiresPod : Pod { }
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
// Test that attempt to freeze an `&mut` pointer while referent is
|
||||
// claimed yields an error.
|
||||
//
|
||||
// Example from src/middle/borrowck/doc.rs
|
||||
|
||||
fn foo<'a>(mut t0: &'a mut int,
|
||||
mut t1: &'a mut int) {
|
||||
let p: &mut int = &mut *t0; // Claims `*t0`
|
||||
let mut t2 = &t0; //~ ERROR cannot borrow `t0`
|
||||
let q: &int = &**t2; // Freezes `*t0` but not through `*p`
|
||||
*p += 1; // violates type of `*q`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
@ -16,12 +16,12 @@
|
||||
// Mostly tests correctness of metadata.
|
||||
|
||||
extern crate trait_superkinds_in_metadata;
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
|
||||
|
||||
struct X<T>(T);
|
||||
|
||||
impl <T:Freeze> RequiresFreeze for X<T> { }
|
||||
impl <T:Share> RequiresShare for X<T> { }
|
||||
|
||||
impl <T:Freeze> RequiresRequiresFreezeAndSend for X<T> { } //~ ERROR cannot implement this trait
|
||||
impl <T:Share> RequiresRequiresShareAndSend for X<T> { } //~ ERROR cannot implement this trait
|
||||
|
||||
fn main() { }
|
||||
|
@ -13,10 +13,7 @@
|
||||
|
||||
trait Foo : Send { }
|
||||
|
||||
impl <'a> Foo for &'a mut () { } //~ ERROR cannot implement this trait
|
||||
|
||||
trait Bar : Freeze { }
|
||||
|
||||
impl <'a> Bar for &'a mut () { } //~ ERROR cannot implement this trait
|
||||
impl <'a> Foo for &'a mut () { }
|
||||
//~^ ERROR which does not fulfill `Send`, cannot implement this trait
|
||||
|
||||
fn main() { }
|
||||
|
@ -12,7 +12,7 @@
|
||||
fn take_any(_: ||:) {
|
||||
}
|
||||
|
||||
fn take_const_owned(_: ||:Freeze+Send) {
|
||||
fn take_const_owned(_: ||:Share+Send) {
|
||||
}
|
||||
|
||||
fn give_any(f: ||:) {
|
||||
@ -21,7 +21,7 @@ fn give_any(f: ||:) {
|
||||
|
||||
fn give_owned(f: ||:Send) {
|
||||
take_any(f);
|
||||
take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Send`
|
||||
take_const_owned(f); //~ ERROR expected bounds `Send+Share` but found bounds `Send`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,57 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Test which of the builtin types are considered freezeable.
|
||||
|
||||
|
||||
fn assert_freeze<T:Freeze>() { }
|
||||
trait Dummy { }
|
||||
|
||||
fn test<'a,T,U:Freeze>(_: &'a int) {
|
||||
// lifetime pointers are ok...
|
||||
assert_freeze::<&'static int>();
|
||||
assert_freeze::<&'a int>();
|
||||
assert_freeze::<&'a str>();
|
||||
assert_freeze::<&'a [int]>();
|
||||
|
||||
// ...unless they are mutable
|
||||
assert_freeze::<&'static mut int>(); //~ ERROR does not fulfill `Freeze`
|
||||
assert_freeze::<&'a mut int>(); //~ ERROR does not fulfill `Freeze`
|
||||
|
||||
// ~ pointers are ok
|
||||
assert_freeze::<~int>();
|
||||
assert_freeze::<~str>();
|
||||
assert_freeze::<Vec<int> >();
|
||||
|
||||
// but not if they own a bad thing
|
||||
assert_freeze::<~&'a mut int>(); //~ ERROR does not fulfill `Freeze`
|
||||
|
||||
// careful with object types, who knows what they close over...
|
||||
assert_freeze::<&'a Dummy>(); //~ ERROR does not fulfill `Freeze`
|
||||
assert_freeze::<~Dummy>(); //~ ERROR does not fulfill `Freeze`
|
||||
|
||||
// ...unless they are properly bounded
|
||||
assert_freeze::<&'a Dummy:Freeze>();
|
||||
assert_freeze::<&'static Dummy:Freeze>();
|
||||
assert_freeze::<~Dummy:Freeze>();
|
||||
|
||||
// ...but even then the pointer overrides
|
||||
assert_freeze::<&'a mut Dummy:Freeze>(); //~ ERROR does not fulfill `Freeze`
|
||||
|
||||
// closures are like an `&mut` object
|
||||
assert_freeze::<||>(); //~ ERROR does not fulfill `Freeze`
|
||||
|
||||
// unsafe ptrs are ok unless they point at unfreezeable things
|
||||
assert_freeze::<*int>();
|
||||
assert_freeze::<*&'a mut int>(); //~ ERROR does not fulfill `Freeze`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
@ -13,11 +13,11 @@
|
||||
|
||||
use std::kinds::marker;
|
||||
|
||||
enum Foo { A(marker::NoFreeze) }
|
||||
enum Foo { A(marker::NoShare) }
|
||||
|
||||
fn bar<T: Freeze>(_: T) {}
|
||||
fn bar<T: Share>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
let x = A(marker::NoFreeze);
|
||||
let x = A(marker::NoShare);
|
||||
bar(&x); //~ ERROR type parameter with an incompatible type
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn is_send<T: Send>() {}
|
||||
fn is_freeze<T: Freeze>() {}
|
||||
fn is_freeze<T: Share>() {}
|
||||
fn is_static<T: 'static>() {}
|
||||
|
||||
fn main() {
|
||||
|
@ -14,7 +14,7 @@ trait Foo {
|
||||
fn a(_x: ~Foo:Send) {
|
||||
}
|
||||
|
||||
fn c(x: ~Foo:Freeze+Send) {
|
||||
fn c(x: ~Foo:Share+Send) {
|
||||
a(x);
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,11 @@ fn a(_x: ~Foo) { // should be same as ~Foo:Send
|
||||
fn b(_x: &'static Foo) { // should be same as &'static Foo:'static
|
||||
}
|
||||
|
||||
fn c(x: ~Foo:Freeze) {
|
||||
fn c(x: ~Foo:Share) {
|
||||
a(x); //~ ERROR expected bounds `Send`
|
||||
}
|
||||
|
||||
fn d(x: &'static Foo:Freeze) {
|
||||
fn d(x: &'static Foo:Share) {
|
||||
b(x); //~ ERROR expected bounds `'static`
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
trait Tr { }
|
||||
impl Tr for int { }
|
||||
|
||||
fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
|
||||
fn foo(x: ~Tr: Share) -> ~Tr: Share { x }
|
||||
|
||||
fn main() {
|
||||
let x: ~Tr: Freeze;
|
||||
let x: ~Tr: Share;
|
||||
|
||||
~1 as ~Tr: Freeze;
|
||||
~1 as ~Tr: Share;
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,15 @@
|
||||
// even when using them cross-crate.
|
||||
|
||||
extern crate trait_superkinds_in_metadata;
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
|
||||
|
||||
#[deriving(Eq)]
|
||||
struct X<T>(T);
|
||||
|
||||
impl <T: Freeze> RequiresFreeze for X<T> { }
|
||||
impl <T: Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
|
||||
impl <T: Share> RequiresShare for X<T> { }
|
||||
impl <T: Share+Send> RequiresRequiresShareAndSend for X<T> { }
|
||||
|
||||
fn foo<T: RequiresRequiresFreezeAndSend>(val: T, chan: Sender<T>) {
|
||||
fn foo<T: RequiresRequiresShareAndSend>(val: T, chan: Sender<T>) {
|
||||
chan.send(val);
|
||||
}
|
||||
|
||||
|
@ -15,14 +15,14 @@
|
||||
// Tests (correct) usage of trait super-builtin-kinds cross-crate.
|
||||
|
||||
extern crate trait_superkinds_in_metadata;
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresFreezeAndSend, RequiresFreeze};
|
||||
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
|
||||
use trait_superkinds_in_metadata::{RequiresPod};
|
||||
|
||||
struct X<T>(T);
|
||||
|
||||
impl <T:Freeze> RequiresFreeze for X<T> { }
|
||||
impl <T:Share> RequiresShare for X<T> { }
|
||||
|
||||
impl <T:Freeze+Send> RequiresRequiresFreezeAndSend for X<T> { }
|
||||
impl <T:Share+Send> RequiresRequiresShareAndSend for X<T> { }
|
||||
|
||||
impl <T:Pod> RequiresPod for X<T> { }
|
||||
|
||||
|
@ -12,18 +12,18 @@ fn foo<T>() {}
|
||||
fn bar<T>(_: T) {}
|
||||
|
||||
fn is_send<T: Send>() {}
|
||||
fn is_freeze<T: Freeze>() {}
|
||||
fn is_freeze<T: Share>() {}
|
||||
fn is_static<T: 'static>() {}
|
||||
|
||||
pub fn main() {
|
||||
foo::<proc()>();
|
||||
foo::<proc:()>();
|
||||
foo::<proc:Send()>();
|
||||
foo::<proc:Send + Freeze()>();
|
||||
foo::<proc:'static + Send + Freeze()>();
|
||||
foo::<proc:Send + Share()>();
|
||||
foo::<proc:'static + Send + Share()>();
|
||||
|
||||
is_send::<proc:Send()>();
|
||||
is_freeze::<proc:Freeze()>();
|
||||
is_freeze::<proc:Share()>();
|
||||
is_static::<proc:'static()>();
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ fn a(_x: ~Foo:) {
|
||||
fn b(_x: ~Foo:Send) {
|
||||
}
|
||||
|
||||
fn c(x: ~Foo:Freeze+Send) {
|
||||
fn c(x: ~Foo:Share+Send) {
|
||||
a(x);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
// Tests that a heterogeneous list of existential types can be put inside an Arc
|
||||
// and shared between tasks as long as all types fulfill Freeze+Send.
|
||||
// and shared between tasks as long as all types fulfill Send.
|
||||
|
||||
// ignore-fast
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user