提交 b88f8678 编写于 作者: N Niko Matsakis

Update error messages in compile-fail tests

上级 a8d478db
......@@ -9,7 +9,7 @@
// except according to those terms.
fn foo<T:'static>() {
1u.bar::<T>(); //~ ERROR: does not fulfill `Send`
1u.bar::<T>(); //~ ERROR `core::kinds::Send` is not implemented
}
trait bar {
......
......@@ -16,10 +16,8 @@ trait Trait {}
pub fn main() {
let x: Vec<Trait + Sized> = Vec::new();
//~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
//~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
//~^^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
let x: Vec<Box<RefCell<Trait + Sized>>> = Vec::new();
//~^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
//~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
......@@ -13,9 +13,9 @@
trait Foo : Send+Sync { }
impl <T: Sync> Foo for (T,) { } //~ ERROR cannot implement this trait
impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::kinds::Send` is not implemented
impl <T: Send> Foo for (T,T) { } //~ ERROR cannot implement this trait
impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::kinds::Sync` is not implemented
impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
......
......@@ -21,6 +21,7 @@
impl <T:Sync> RequiresShare for X<T> { }
impl <T:Sync> RequiresRequiresShareAndSend for X<T> { } //~ ERROR cannot implement this trait
impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
//~^ ERROR the trait `core::kinds::Send` is not implemented
fn main() { }
......@@ -12,12 +12,12 @@
// to use capabilities granted by builtin kinds as supertraits.
trait Foo : Sync+'static {
fn foo(self, mut chan: Sender<Self>) {
chan.send(self); //~ ERROR does not fulfill `Send`
}
fn foo(self, mut chan: Sender<Self>) { }
}
impl <T: Sync> Foo for T { }
//~^ ERROR the parameter type `T` may not live long enough
//~^^ ERROR the parameter type `T` may not live long enough
fn main() {
let (tx, rx) = channel();
......
......@@ -14,6 +14,6 @@
trait Foo : Send { }
impl <'a> Foo for &'a mut () { }
//~^ ERROR which does not fulfill `Send`, cannot implement this trait
//~^ ERROR does not fulfill the required lifetime
fn main() { }
......@@ -12,6 +12,6 @@
trait Foo : Send { }
impl <T: Sync> Foo for T { } //~ ERROR cannot implement this trait
impl <T: Sync+'static> Foo for T { } //~ ERROR the trait `core::kinds::Send` is not implemented
fn main() { }
......@@ -11,7 +11,7 @@
fn test<T: Sync>() {}
fn main() {
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync`
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Sync`
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync`
test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
test::<Receiver<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
}
......@@ -15,10 +15,7 @@
extern crate trait_impl_conflict;
use trait_impl_conflict::Foo;
impl<A> Foo for A {
//~^ ERROR conflicting implementations for trait `trait_impl_conflict::Foo`
//~^^ ERROR cannot provide an extension implementation where both trait and type
// are not defined in this crate
impl<A> Foo for A { //~ ERROR E0117
}
fn main() {
......
......@@ -8,15 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: conflicting implementations for trait `Foo`
trait Foo {
}
impl Foo for int {
impl Foo for int { //~ ERROR conflicting implementations
}
impl<A> Foo for A {
impl<A> Foo for A { //~ NOTE conflicting implementation here
}
......
......@@ -18,7 +18,7 @@
#[deriving(Default)]
struct Struct {
x: Error //~ ERROR
x: Error //~ ERROR `core::default::Default` is not implemented
}
fn main() {}
......@@ -16,11 +16,9 @@
struct Error;
#[deriving(Zero)] //~ ERROR failed to find an implementation
#[deriving(Zero)] //~ ERROR not implemented
struct Struct {
x: Error //~ ERROR failed to find an implementation
//~^ ERROR failed to find an implementation
//~^^ ERROR type `Error` does not implement any method in scope
x: Error
}
fn main() {}
......@@ -16,11 +16,9 @@
struct Error;
#[deriving(Zero)] //~ ERROR failed to find an implementation
#[deriving(Zero)] //~ ERROR not implemented
struct Struct(
Error //~ ERROR
//~^ ERROR failed to find an implementation
//~^^ ERROR type `Error` does not implement any method in scope
Error
);
fn main() {}
......@@ -8,12 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
type Foo = Vec<u8>;
impl Drop for Foo {
//~^ ERROR cannot provide an extension implementation
impl Drop for int {
//~^ ERROR the Drop trait may only be implemented on structures
//~^^ ERROR cannot provide an extension implementation
fn drop(&mut self) {
println!("kaboom");
}
......
......@@ -42,6 +42,6 @@ pub fn main() {
// Assignment.
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = *z; //~ ERROR dynamically sized type on lhs of assignment
//~^ ERROR E0161
f5.ptr = *z;
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
......@@ -43,4 +43,5 @@ pub fn main() {
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1`
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `ToBar`
}
......@@ -28,5 +28,5 @@ pub fn main() {
let f1 = Fat { ptr: Foo };
let f2: &Fat<Foo> = &f1;
let f3: &Fat<Bar> = f2;
//~^ ERROR failed to find an implementation of trait Bar for Foo
//~^ ERROR the trait `Bar` is not implemented for the type `Foo`
}
......@@ -22,10 +22,10 @@ pub fn main() {
// With a vec of ints.
let f1 = Fat { ptr: [1, 2, 3] };
let f2: &Fat<[int, ..3]> = &f1;
let f3: &mut Fat<[int]> = f2; //~ ERROR cannot borrow immutable dereference
let f3: &mut Fat<[int]> = f2; //~ ERROR mismatched types
// With a trait.
let f1 = Fat { ptr: Foo };
let f2: &Fat<Foo> = &f1;
let f3: &mut Fat<Bar> = f2; //~ ERROR cannot borrow immutable dereference
let f3: &mut Fat<Bar> = f2; //~ ERROR mismatched types
}
......@@ -30,10 +30,9 @@ pub fn main() {
let y: &T = x; //~ ERROR mismatched types
// Test that we cannot convert an immutable ptr to a mutable one using *-ptrs
let x: &mut T = &S; //~ ERROR types differ in mutability
let x: *mut T = &S; //~ ERROR types differ in mutability
let x: *mut S = &S;
//~^ ERROR mismatched types
let x: &mut T = &S; //~ ERROR mismatched types
let x: *mut T = &S; //~ ERROR mismatched types
let x: *mut S = &S; //~ ERROR mismatched types
// The below four sets of tests test that we cannot implicitly deref a *-ptr
// during a coercion.
......
......@@ -21,6 +21,5 @@ pub fn main() {
let f: Fat<[int, ..3]> = Fat { ptr: [5i, 6, 7] };
let g: &Fat<[int]> = &f;
let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
//~^ ERROR trying to initialise a dynamically sized struct
//~^^ ERROR E0161
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
// 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 <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.
// Check that when you implement a trait that has a sized type
// parameter, the corresponding value must be sized. Also that the
// self type must be sized if appropriate.
trait Foo<T> { fn take(self, x: &T) { } } // Note: T is sized
impl Foo<[int]> for uint { }
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[int]`
impl Foo<int> for [uint] { }
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[uint]`
pub fn main() { }
......@@ -13,5 +13,5 @@
fn check_bound<T:Copy>(_: T) {}
fn main() {
check_bound("nocopy".to_string()); //~ ERROR does not fulfill `Copy`
check_bound("nocopy".to_string()); //~ ERROR the trait `core::kinds::Copy` is not implemented
}
......@@ -10,5 +10,5 @@
fn main() {
format!("{:d}", "3");
//~^ ERROR: failed to find an implementation of trait core::fmt::Signed
//~^ ERROR: the trait `core::fmt::Signed` is not implemented
}
......@@ -17,7 +17,7 @@ trait Getter<T: Clone2> {
fn get(&self) -> T;
}
impl Getter<int> for int { //~ ERROR failed to find an implementation of trait Clone2 for int
impl Getter<int> for int { //~ ERROR the trait `Clone2` is not implemented
fn get(&self) -> int { *self }
}
......
......@@ -15,8 +15,8 @@ fn main() {
let y: Gc<int> = box (GC) 0;
println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
//~^ ERROR cannot determine a type for this bounded type parameter: unconstrained type
//~^ ERROR unable to infer enough type information
println!("{}", y + 1);
//~^ ERROR binary operation `+` cannot be applied to type `Gc<int>`
//~^^ ERROR cannot determine a type for this bounded type parameter: unconstrained type
//~^^ ERROR unable to infer enough type information
}
......@@ -17,6 +17,6 @@ struct S {
name: int
}
fn bar(_x: Foo) {} //~ ERROR variable `_x` has dynamically sized type
fn bar(_x: Foo) {} //~ ERROR the trait `core::kinds::Sized` is not implemented
fn main() {}
......@@ -11,6 +11,6 @@
trait I {}
type K = I+'static;
fn foo(_x: K) {} //~ ERROR: variable `_x` has dynamically sized type
fn foo(_x: K) {} //~ ERROR: the trait `core::kinds::Sized` is not implemented
fn main() {}
......@@ -15,10 +15,9 @@ struct Struct {
}
fn new_struct(r: A+'static) -> Struct {
//~^ ERROR variable `r` has dynamically sized type
Struct { r: r } //~ ERROR trying to initialise a dynamically sized struct
//~^ ERROR E0161
//~^^ ERROR E0161
//~^ ERROR the trait `core::kinds::Sized` is not implemented
Struct { r: r }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
trait Curve {}
......
......@@ -11,5 +11,6 @@
extern crate debug;
fn main() {
format!("{:?}", None); //~ ERROR: cannot determine a type for this bounded
// Unconstrained type:
format!("{:?}", None); //~ ERROR: E0101
}
......@@ -32,10 +32,5 @@ struct A {
fn main() {
let a = A {v: box B{v: None} as Box<Foo+Send>};
//~^ ERROR cannot pack type `Box<B>`, which does not fulfill `Send`, as a trait bounded by Send
let v = Rc::new(RefCell::new(a));
let w = v.clone();
let b = &*v;
let mut b = b.borrow_mut();
b.v.set(w.clone());
//~^ ERROR the trait `core::kinds::Send` is not implemented for the type `B`
}
......@@ -34,14 +34,14 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<&'a [int]>();
// ...unless they are mutable
assert_copy::<&'static mut int>(); //~ ERROR does not fulfill
assert_copy::<&'a mut int>(); //~ ERROR does not fulfill
assert_copy::<&'static mut int>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<&'a mut int>(); //~ ERROR `core::kinds::Copy` is not implemented
// ~ pointers are not ok
assert_copy::<Box<int>>(); //~ ERROR does not fulfill
assert_copy::<String>(); //~ ERROR does not fulfill
assert_copy::<Vec<int> >(); //~ ERROR does not fulfill
assert_copy::<Box<&'a mut int>>(); //~ ERROR does not fulfill
assert_copy::<Box<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<String>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Vec<int> >(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::kinds::Copy` is not implemented
// borrowed object types are generally ok
assert_copy::<&'a Dummy>();
......@@ -49,14 +49,14 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<&'static Dummy+Copy>();
// owned object types are not ok
assert_copy::<Box<Dummy>>(); //~ ERROR does not fulfill
assert_copy::<Box<Dummy+Copy>>(); //~ ERROR does not fulfill
assert_copy::<Box<Dummy>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::kinds::Copy` is not implemented
// mutable object types are not ok
assert_copy::<&'a mut Dummy+Copy>(); //~ ERROR does not fulfill
assert_copy::<&'a mut Dummy+Copy>(); //~ ERROR `core::kinds::Copy` is not implemented
// closures are like an `&mut` object
assert_copy::<||>(); //~ ERROR does not fulfill
assert_copy::<||>(); //~ ERROR `core::kinds::Copy` is not implemented
// unsafe ptrs are ok
assert_copy::<*const int>();
......@@ -74,11 +74,11 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<MyStruct>();
// structs containing non-POD are not ok
assert_copy::<MyNoncopyStruct>(); //~ ERROR does not fulfill
assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::kinds::Copy` is not implemented
// managed or ref counted types are not ok
assert_copy::<Gc<int>>(); //~ ERROR does not fulfill
assert_copy::<Rc<int>>(); //~ ERROR does not fulfill
assert_copy::<Gc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Rc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
}
pub fn main() {
......
......@@ -19,5 +19,5 @@ fn take_param<T:Foo>(foo: &T) { }
fn main() {
let x = box 3i;
take_param(&x);
//~^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR the trait `core::kinds::Copy` is not implemented
}
......@@ -20,20 +20,22 @@ impl<T: Send + Copy> Gettable<T> for S<T> {}
fn f<T>(val: T) {
let t: S<T> = S;
let a = &t as &Gettable<T>;
//~^ ERROR instantiating a type parameter with an incompatible type `T`
//~^ ERROR the trait `core::kinds::Send` is not implemented
//~^^ ERROR the trait `core::kinds::Copy` is not implemented
let a: &Gettable<T> = &t;
//~^ ERROR instantiating a type parameter with an incompatible type `T`
//~^ ERROR the trait `core::kinds::Send` is not implemented
//~^^ ERROR the trait `core::kinds::Copy` is not implemented
}
fn main() {
let t: S<&int> = S;
let a = &t as &Gettable<&int>;
//~^ ERROR instantiating a type parameter with an incompatible type
fn foo<'a>() {
let t: S<&'a int> = S;
let a = &t as &Gettable<&'a int>;
let t: Box<S<String>> = box S;
let a = t as Box<Gettable<String>>;
//~^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR the trait `core::kinds::Copy` is not implemented
let t: Box<S<String>> = box S;
let a: Box<Gettable<String>> = t;
//~^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR the trait `core::kinds::Copy` is not implemented
}
fn main() { }
......@@ -23,8 +23,8 @@ fn take_param<T:Foo>(foo: &T) { }
fn main() {
let x = box 3i;
take_param(&x); //~ ERROR does not fulfill `Copy`
take_param(&x); //~ ERROR `core::kinds::Copy` is not implemented
let y = &x;
let z = &x as &Foo; //~ ERROR does not fulfill `Copy`
let z = &x as &Foo; //~ ERROR `core::kinds::Copy` is not implemented
}
......@@ -13,10 +13,10 @@ fn is_freeze<T: Sync>() {}
fn foo<'a>() {
is_send::<proc()>();
//~^ ERROR: instantiating a type parameter with an incompatible type
//~^ ERROR: the trait `core::kinds::Send` is not implemented
is_freeze::<proc()>();
//~^ ERROR: instantiating a type parameter with an incompatible type
//~^ ERROR: the trait `core::kinds::Sync` is not implemented
}
fn main() { }
......@@ -19,19 +19,20 @@ trait Message : Send { }
// careful with object types, who knows what they close over...
fn object_ref_with_static_bound_not_ok() {
assert_send::<&'static Dummy+'static>(); //~ ERROR does not fulfill
assert_send::<&'static Dummy+'static>();
//~^ ERROR the trait `core::kinds::Send` is not implemented
}
fn box_object_with_no_bound_not_ok<'a>() {
assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill
assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::kinds::Send` is not implemented
}
fn proc_with_no_bound_not_ok<'a>() {
assert_send::<proc()>(); //~ ERROR does not fulfill
assert_send::<proc()>(); //~ ERROR the trait `core::kinds::Send` is not implemented
}
fn closure_with_no_bound_not_ok<'a>() {
assert_send::<||:'static>(); //~ ERROR does not fulfill
assert_send::<||:'static>(); //~ ERROR the trait `core::kinds::Send` is not implemented
}
fn object_with_send_bound_ok() {
......
......@@ -18,6 +18,7 @@ trait Dummy { }
// careful with object types, who knows what they close over...
fn test51<'a>() {
assert_send::<&'a Dummy>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
}
fn test52<'a>() {
assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill the required lifetime
......@@ -35,10 +36,12 @@ fn test61() {
// them not ok
fn test_70<'a>() {
assert_send::<proc():'a>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
}
fn test_71<'a>() {
assert_send::<Box<Dummy+'a>>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
}
fn main() { }
......@@ -14,11 +14,11 @@ fn assert_send<T:Send>() { }
trait Dummy { }
fn test50() {
assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send`
assert_send::<&'static Dummy>(); //~ ERROR the trait `core::kinds::Send` is not implemented
}
fn test53() {
assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill `Send`
assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::kinds::Send` is not implemented
}
// ...unless they are properly bounded
......
// 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 <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.
fn assert_send<T:Send>() { }
// unsafe ptrs are ok unless they point at unsendable things
fn test70() {
assert_send::<*mut int>();
}
fn test71<'a>() {
assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime
}
fn main() {
}
......@@ -18,6 +18,5 @@ fn main() {
let x: Box<HashMap<int, int>> = box HashMap::new();
let x: Box<Map<int, int>> = x;
let y: Box<Map<uint, int>> = box x;
//~^ ERROR failed to find an implementation of trait collections::Map<uint,int>
//~^^ ERROR failed to find an implementation of trait core::collections::Collection
//~^ ERROR the trait `collections::Map<uint,int>` is not implemented
}
......@@ -14,5 +14,5 @@ fn foo<P:Copy>(p: P) { }
fn main()
{
foo(marker::NoCopy); //~ ERROR does not fulfill
foo(marker::NoCopy); //~ ERROR the trait `core::kinds::Copy` is not implemented
}
......@@ -14,5 +14,5 @@ fn foo<P:Send>(p: P) { }
fn main()
{
foo(marker::NoSend); //~ ERROR does not fulfill `Send`
foo(marker::NoSend); //~ ERROR the trait `core::kinds::Send` is not implemented
}
......@@ -14,5 +14,5 @@ fn foo<P: Sync>(p: P) { }
fn main()
{
foo(marker::NoSync); //~ ERROR does not fulfill `Sync`
foo(marker::NoSync); //~ ERROR the trait `core::kinds::Sync` is not implemented
}
......@@ -14,5 +14,5 @@ fn f<T: Sync>(_: T) {}
fn main() {
let x = RefCell::new(0i);
f(x); //~ ERROR: which does not fulfill `Sync`
f(x); //~ ERROR `core::kinds::Sync` is not implemented
}
......@@ -19,5 +19,5 @@ fn bar<T: Sync>(_: T) {}
fn main() {
let x = A(marker::NoSync);
bar(&x); //~ ERROR type parameter with an incompatible type
bar(&x); //~ ERROR the trait `core::kinds::Sync` is not implemented
}
......@@ -36,7 +36,8 @@ fn foo(x: Port<()>) -> foo {
let x = foo(Port(box(GC) ()));
task::spawn(proc() {
let y = x; //~ ERROR does not fulfill `Send`
let y = x;
//~^ ERROR does not fulfill `Send`
println!("{:?}", y);
});
}
......@@ -19,6 +19,5 @@ fn bar<T: Send>(_: T) {}
fn main() {
let x = A(marker::NoSend);
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Send`
//~^ ERROR `core::kinds::Send` is not implemented
}
......@@ -15,6 +15,5 @@ fn bar<T: Send>(_: T) {}
fn main() {
let x = Rc::new(5i);
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `alloc::rc::Rc<int>`,
// which does not fulfill `Send`
//~^ ERROR `core::kinds::Send` is not implemented
}
......@@ -20,6 +20,5 @@ fn bar<T: Send>(_: T) {}
fn main() {
let x = Foo { a: 5, ns: marker::NoSend };
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Send`
//~^ ERROR the trait `core::kinds::Send` is not implemented
}
......@@ -17,6 +17,5 @@ fn bar<T: Sync>(_: T) {}
fn main() {
let x = A(marker::NoSync);
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Sync`
//~^ ERROR the trait `core::kinds::Sync` is not implemented
}
......@@ -16,6 +16,5 @@ fn bar<T: Sync>(_: T) {}
fn main() {
let x = Rc::new(RefCell::new(5i));
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Sync`
//~^ ERROR the trait `core::kinds::Sync` is not implemented
}
......@@ -17,6 +17,5 @@ fn bar<T: Sync>(_: T) {}
fn main() {
let x = Foo { a: 5, m: marker::NoSync };
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Sync`
//~^ ERROR the trait `core::kinds::Sync` is not implemented
}
......@@ -14,6 +14,6 @@
trait Foo {}
fn take_foo<F:Foo>(f: F) {}
fn take_object(f: Box<Foo>) { take_foo(f); } //~ ERROR failed to find an implementation of trait
//~^ ERROR failed to find an implementation
fn take_object(f: Box<Foo>) { take_foo(f); }
//~^ ERROR the trait `Foo` is not implemented
fn main() {}
......@@ -43,8 +43,7 @@ fn main() {
{
// Can't do this copy
let x = box box box A {y: r(i)};
let _z = x.clone(); //~ ERROR failed to find an implementation
//~^ ERROR failed to find an implementation
let _z = x.clone(); //~ ERROR not implemented
println!("{:?}", x);
}
println!("{:?}", *i);
......
......@@ -12,8 +12,6 @@
// nominal types (but not on other types) and that they are type
// checked.
#![no_std]
struct Inv<'a> { // invariant w/r/t 'a
x: &'a mut &'a int
}
......
......@@ -58,6 +58,7 @@ fn box_with_region_not_ok<'a>() {
fn object_with_random_bound_not_ok<'a>() {
assert_send::<&'a Dummy+'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
}
fn object_with_send_bound_not_ok<'a>() {
......@@ -66,10 +67,12 @@ fn object_with_send_bound_not_ok<'a>() {
fn proc_with_lifetime_not_ok<'a>() {
assert_send::<proc():'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
}
fn closure_with_lifetime_not_ok<'a>() {
assert_send::<||:'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
}
// unsafe pointers are ok unless they point at unsendable things
......
......@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![no_std]
// Check that explicit region bounds are allowed on the various
// nominal types (but not on other types) and that they are type
// checked.
......
......@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![no_std]
#![allow(dead_code)]
trait Deref {
......
......@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![no_std]
fn a<'a, 'b:'a>(x: &mut &'a int, y: &mut &'b int) {
// Note: this is legal because of the `'b:'a` declaration.
*x = *y;
......
......@@ -24,5 +24,6 @@ fn drop(&mut self) {
fn main() {
let a = Foo { x: 3 };
let _ = [ a, ..5 ]; //~ ERROR copying a value of non-copyable type
let _ = [ a, ..5 ];
//~^ ERROR the trait `core::kinds::Copy` is not implemented for the type `Foo`
}
......@@ -16,5 +16,5 @@ fn test_send<S: Send>() {}
pub fn main() {
test_send::<rand::TaskRng>();
//~^ ERROR: incompatible type `std::rand::TaskRng`, which does not fulfill `Send`
//~^ ERROR `core::kinds::Send` is not implemented
}
......@@ -14,7 +14,7 @@ trait Foo {
// This should emit the less confusing error, not the more confusing one.
fn foo(_x: Foo + Send) {
//~^ERROR variable `_x` has dynamically sized type `Foo+Send`
//~^ERROR the trait `core::kinds::Sized` is not implemented
}
fn main() { }
......@@ -16,12 +16,11 @@ struct Foo<T:Trait> {
fn main() {
let foo = Foo {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
x: 3i
};
let baz: Foo<uint> = fail!();
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
}
......@@ -15,8 +15,7 @@ struct Foo<T:Trait> {
}
static X: Foo<uint> = Foo {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
x: 1,
};
......
......@@ -15,22 +15,11 @@
use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait};
fn explode(x: Foo<uint>) {}
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
fn kaboom(y: Bar<f32>) {}
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
fn main() {
let foo = Foo {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
x: 3i
};
let bar: Bar<f64> = return;
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
let _ = bar;
}
// 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 <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.
// aux-build:trait_bounds_on_structs_and_enums_xc.rs
extern crate trait_bounds_on_structs_and_enums_xc;
use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait};
fn main() {
let foo = Foo {
//~^ ERROR not implemented
x: 3i
};
let bar: Bar<f64> = return;
//~^ ERROR not implemented
let _ = bar;
}
......@@ -20,40 +20,34 @@ enum Bar<T:Trait> {
CBar(uint),
}
fn explode(x: Foo<uint>) {}
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
fn explode(x: Foo<u32>) {}
//~^ ERROR not implemented
fn kaboom(y: Bar<f32>) {}
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
impl<T> Foo<T> { //~ ERROR failed to find an implementation
//~^ ERROR instantiating a type parameter with an incompatible type
impl<T> Foo<T> {
//~^ ERROR the trait `Trait` is not implemented
fn uhoh() {}
}
struct Baz {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
a: Foo<int>,
}
enum Boo {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
Quux(Bar<uint>),
}
struct Badness<T> {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
b: Foo<T>,
}
enum MoreBadness<T> {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
EvenMoreBadness(Bar<T>),
}
......@@ -64,15 +58,10 @@ fn whatever() {}
struct Struct;
impl PolyTrait<Foo<uint>> for Struct {
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
//~^ ERROR not implemented
fn whatever() {}
}
fn main() {
let bar: Bar<f64> = return;
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
let _ = bar;
}
......@@ -25,7 +25,6 @@ fn f(&self, x: &'static str) {
fn main() {
let s: Box<Trait<int>> = box Struct { person: "Fred" };
//~^ ERROR expected Trait<int>, found Trait<&'static str>
//~^^ ERROR expected Trait<int>, found Trait<&'static str>
//~^ ERROR type mismatch
s.f(1);
}
......@@ -15,12 +15,12 @@ trait Tr<T> {
// these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T>
trait A: Tr<Self> {
fn test<U>(u: U) -> Self {
Tr::op(u) //~ ERROR expected Tr<U>, found Tr<Self>
Tr::op(u) //~ ERROR type mismatch
}
}
trait B<T>: Tr<T> {
fn test<U>(u: U) -> Self {
Tr::op(u) //~ ERROR expected Tr<U>, found Tr<T>
Tr::op(u) //~ ERROR type mismatch
}
}
......
......@@ -39,5 +39,5 @@ fn main() {
let ns = NoSync{m: marker::NoSync};
test(ns);
//~^ ERROR instantiating a type parameter with an incompatible type `NoSync`, which does not fulfill `Sync`
//~^ ERROR `core::kinds::Sync` is not implemented
}
......@@ -18,8 +18,7 @@ fn call_it<F:FnMut<(int,int),int>>(y: int, mut f: F) -> int {
pub fn main() {
let f = |&mut: x: uint, y: int| -> int { (x as int) + y };
let z = call_it(3, f); //~ ERROR expected core::ops::FnMut
//~^ ERROR expected core::ops::FnMut
let z = call_it(3, f); //~ ERROR type mismatch
println!("{}", z);
}
......@@ -17,6 +17,6 @@ fn c<F:|: int, int| -> int>(f: F) -> int {
fn main() {
let z: int = 7;
assert_eq!(c(|&: x: int, y| x + y + z), 10);
//~^ ERROR failed to find an implementation
//~^ ERROR not implemented
}
......@@ -20,7 +20,6 @@ fn drop(&mut self) {}
fn main() {
let i = box r { b: true };
let _j = i.clone(); //~ ERROR failed to find an implementation
//~^ ERROR failed to find an implementation
let _j = i.clone(); //~ ERROR not implemented
println!("{:?}", i);
}
......@@ -16,5 +16,5 @@ fn f<T:Send>(_i: T) {
fn main() {
let i = box box(GC) 100i;
f(i); //~ ERROR does not fulfill `Send`
f(i); //~ ERROR `core::kinds::Send` is not implemented
}
......@@ -36,10 +36,8 @@ fn main() {
let r1 = vec!(box r { i: i1 });
let r2 = vec!(box r { i: i2 });
f(r1.clone(), r2.clone());
//~^ ERROR failed to find an implementation of
//~^^ ERROR failed to find an implementation of
//~^^^ ERROR failed to find an implementation of
//~^^^^ ERROR failed to find an implementation of
//~^ ERROR the trait `core::clone::Clone` is not implemented
//~^^ ERROR the trait `core::clone::Clone` is not implemented
println!("{:?}", (r2, i1.get()));
println!("{:?}", (r1, i2.get()));
}
......@@ -28,6 +28,6 @@ fn foo(i:int, j: Gc<String>) -> foo {
fn main() {
let cat = "kitty".to_string();
let (tx, _) = channel(); //~ ERROR does not fulfill `Send`
tx.send(foo(42, box(GC) (cat))); //~ ERROR does not fulfill `Send`
let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented
tx.send(foo(42, box(GC) (cat))); //~ ERROR `core::kinds::Send` is not implemented
}
......@@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: instantiating a type parameter with an incompatible type
fn bar<T: Sized>() { }
fn foo<Sized? T>() { bar::<T>() }
fn foo<Sized? T>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
fn main() { }
......@@ -8,7 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: instantiating a type parameter with an incompatible type
enum Foo<T> { FooSome(T), FooNone }
fn bar<T: Sized>() { }
fn foo<Sized? T>() { bar::<Option<T>>() }
fn foo<Sized? T>() { bar::<Foo<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
//
// One error is for T being provided to Foo<T>, the other is
// for Foo<T> being provided to bar.
fn main() { }
......@@ -8,10 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: instantiating a type parameter with an incompatible type
struct Foo<T> { data: T }
fn bar<T: Sized>() { }
fn foo<Sized? T>() { bar::<Foo<T>>() }
//~^ ERROR the trait `core::kinds::Sized` is not implemented
//~^^ ERROR the trait `core::kinds::Sized` is not implemented
// One error is for the T in Foo<T>, the other is for Foo<T> as a value
// for bar's type parameter.
fn main() { }
......@@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test sized-ness checking in substitution.
// Test sized-ness checking in substitution within fn bodies..
// Unbounded.
fn f1<Sized? X>(x: &X) {
f2::<X>(x); //~ ERROR instantiating a type parameter with an incompatible type `X`, which does n
f2::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
fn f2<X>(x: &X) {
}
......@@ -21,7 +22,8 @@ fn f2<X>(x: &X) {
// Bounded.
trait T for Sized? {}
fn f3<Sized? X: T>(x: &X) {
f4::<X>(x); //~ ERROR instantiating a type parameter with an incompatible type `X`, which does n
f4::<X>(x);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
fn f4<X: T>(x: &X) {
}
......@@ -34,7 +36,8 @@ enum E<Sized? X> {
fn f5<Y>(x: &Y) {}
fn f6<Sized? X>(x: &X) {}
fn f7<Sized? X>(x1: &E<X>, x2: &E<X>) {
f5(x1); //~ERROR instantiating a type parameter with an incompatible type `E<X>`, which does not
f5(x1);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
f6(x2); // ok
}
......@@ -45,40 +48,18 @@ struct S<Sized? X> {
}
fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) {
f5(x1); //~ERROR instantiating a type parameter with an incompatible type `S<X>`, which does not
f5(x1);
//~^ ERROR the trait `core::kinds::Sized` is not implemented
f6(x2); // ok
}
// Test some tuples.
fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(*x1, 34i)); //~ERROR E0161
//~^ ERROR instantiating a type parameter with an incompatible type
f5(&(32i, *x2)); //~ERROR E0161
//~^ ERROR instantiating a type parameter with an incompatible type
f5(&(*x1, 34i));
//~^ ERROR the trait `core::kinds::Sized` is not implemented
f5(&(32i, *x2));
//~^ ERROR the trait `core::kinds::Sized` is not implemented
}
// impl - bounded
trait T1<Z: T> {
}
struct S3<Sized? Y>;
impl<Sized? X: T> T1<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible
}
// impl - unbounded
trait T2<Z> {
}
impl<Sized? X> T2<X> for S3<X> { //~ ERROR instantiating a type parameter with an incompatible type
}
// impl - struct
trait T3<Sized? Z> {
}
struct S4<Y>;
impl<Sized? X> T3<X> for S4<X> { //~ ERROR instantiating a type parameter with an incompatible type
}
impl<Sized? X> S4<X> { //~ ERROR instantiating a type parameter with an incompatible type
}
pub fn main() {
}
......@@ -14,33 +14,29 @@
trait T for Sized? {}
fn f1<Sized? X>(x: &X) {
let _: X; //~ERROR variable `_` has dynamically sized type `X`
let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))`
let y: X; //~ERROR variable `y` has dynamically sized type `X`
let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))`
let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (int, (X, int)); // same
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
}
fn f2<Sized? X: T>(x: &X) {
let _: X; //~ERROR variable `_` has dynamically sized type `X`
let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))`
let y: X; //~ERROR variable `y` has dynamically sized type `X`
let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))`
let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
}
fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X`
let y = *x2; //~ERROR variable `y` has dynamically sized type `X`
let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X`
//~^ ERROR E0161
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
}
fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X`
let y = *x2; //~ERROR variable `y` has dynamically sized type `X`
let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X`
//~^ ERROR E0161
let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
}
fn g1<Sized? X>(x: X) {} //~ERROR variable `x` has dynamically sized type `X`
fn g2<Sized? X: T>(x: X) {} //~ERROR variable `x` has dynamically sized type `X`
fn g1<Sized? X>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
fn g2<Sized? X: T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
pub fn main() {
}
// 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 <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 sized-ness checking in substitution in impls.
trait T for Sized? {}
// I would like these to fail eventually.
// impl - bounded
trait T1<Z: T> {
}
struct S3<Sized? Y>;
impl<Sized? X: T> T1<X> for S3<X> {
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
}
// impl - unbounded
trait T2<Z> {
}
struct S4<Sized? Y>;
impl<Sized? X> T2<X> for S4<X> {
//~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
}
// impl - struct
trait T3<Sized? Z> {
}
struct S5<Y>;
impl<Sized? X> T3<X> for S5<X> { //~ ERROR not implemented
}
impl<Sized? X> S5<X> { //~ ERROR not implemented
}
fn main() { }
......@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: failed to find an implementation
struct r {
i:int
}
......@@ -25,5 +23,7 @@ fn main() {
let i = vec!(r(0));
let j = vec!(r(1));
let k = i + j;
//~^ ERROR not implemented
println!("{}", j);
//~^ ERROR not implemented
}
......@@ -24,8 +24,7 @@ fn gimme_an_a<A:TraitA>(&self, a: A) -> int {
fn call_it<B:TraitB>(b: B) -> int {
let y = 4u;
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait TraitA
//~^ ERROR failed to find an implementation of trait TraitA
b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented
}
fn main() {
......
......@@ -15,9 +15,6 @@ fn equal<T>(_: &T, _: &T) -> bool where T : Eq {
fn main() {
drop(equal(&Struct, &Struct))
//~^ ERROR failed to find an implementation of trait core::cmp::Eq
//~^^ ERROR failed to find an implementation of trait core::cmp::PartialEq
//~^^^ ERROR failed to find an implementation of trait core::cmp::Eq
//~^^^^ ERROR failed to find an implementation of trait core::cmp::PartialEq
//~^ ERROR the trait `core::cmp::Eq` is not implemented
}
// Copyright 2012-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 <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 destructor on a struct runs successfully after the struct
// is boxed and converted to an object.
static mut value: uint = 0;
struct Cat {
name : uint,
}
trait Dummy {
fn get(&self) -> uint;
}
impl Dummy for Cat {
fn get(&self) -> uint { self.name }
}
impl Drop for Cat {
fn drop(&mut self) {
unsafe { value = self.name; }
}
}
pub fn main() {
{
let x = box Cat {name: 22};
let nyan: Box<Dummy> = x as Box<Dummy>;
}
unsafe {
assert_eq!(value, 22);
}
}
// 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 <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.
// Testing creating two vtables with the same self type, but different
// traits.
use std::any::Any;
use std::any::AnyRefExt;
trait Wrap {
fn get(&self) -> int;
fn wrap(self: Box<Self>) -> Box<Any+'static>;
}
impl Wrap for int {
fn get(&self) -> int {
*self
}
fn wrap(self: Box<int>) -> Box<Any+'static> {
self as Box<Any+'static>
}
}
fn is<T:'static>(x: &Any) -> bool {
x.is::<T>()
}
fn main() {
let x = box 22i as Box<Wrap>;
println!("x={}", x.get());
let y = x.wrap();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册