1
Fork 0

Update error messages in compile-fail tests

This commit is contained in:
Niko Matsakis 2014-09-12 10:45:39 -04:00
parent a8d478db51
commit b88f86782e
87 changed files with 381 additions and 256 deletions

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn foo<T:'static>() { fn foo<T:'static>() {
1u.bar::<T>(); //~ ERROR: does not fulfill `Send` 1u.bar::<T>(); //~ ERROR `core::kinds::Send` is not implemented
} }
trait bar { trait bar {

View file

@ -16,10 +16,8 @@ trait Trait {}
pub fn main() { pub fn main() {
let x: Vec<Trait + Sized> = Vec::new(); let x: Vec<Trait + Sized> = Vec::new();
//~^ 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 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 instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
let x: Vec<Box<RefCell<Trait + Sized>>> = Vec::new(); 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 the trait `core::kinds::Sized` is not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type `Trait+Sized`, which does not fulfill `Sized`
} }

View file

@ -13,9 +13,9 @@
trait Foo : Send+Sync { } 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) impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)

View file

@ -21,6 +21,7 @@ struct X<T>(T);
impl <T:Sync> RequiresShare for X<T> { } 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() { } fn main() { }

View file

@ -12,12 +12,12 @@
// to use capabilities granted by builtin kinds as supertraits. // to use capabilities granted by builtin kinds as supertraits.
trait Foo : Sync+'static { trait Foo : Sync+'static {
fn foo(self, mut chan: Sender<Self>) { fn foo(self, mut chan: Sender<Self>) { }
chan.send(self); //~ ERROR does not fulfill `Send`
}
} }
impl <T: Sync> Foo for T { } 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() { fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();

View file

@ -14,6 +14,6 @@
trait Foo : Send { } trait Foo : Send { }
impl <'a> Foo for &'a mut () { } 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() { } fn main() { }

View file

@ -12,6 +12,6 @@
trait Foo : Send { } 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() { } fn main() { }

View file

@ -11,7 +11,7 @@
fn test<T: Sync>() {} fn test<T: Sync>() {}
fn main() { fn main() {
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync` test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Sync` test::<Receiver<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync` test::<Sender<int>>(); //~ ERROR: `core::kinds::Sync` is not implemented
} }

View file

@ -15,10 +15,7 @@
extern crate trait_impl_conflict; extern crate trait_impl_conflict;
use trait_impl_conflict::Foo; use trait_impl_conflict::Foo;
impl<A> Foo for A { impl<A> Foo for A { //~ ERROR E0117
//~^ 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
} }
fn main() { fn main() {

View file

@ -8,15 +8,14 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: conflicting implementations for trait `Foo`
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
} }

View file

@ -18,7 +18,7 @@ struct Error;
#[deriving(Default)] #[deriving(Default)]
struct Struct { struct Struct {
x: Error //~ ERROR x: Error //~ ERROR `core::default::Default` is not implemented
} }
fn main() {} fn main() {}

View file

@ -16,11 +16,9 @@ extern crate rand;
struct Error; struct Error;
#[deriving(Zero)] //~ ERROR failed to find an implementation #[deriving(Zero)] //~ ERROR not implemented
struct Struct { struct Struct {
x: Error //~ ERROR failed to find an implementation x: Error
//~^ ERROR failed to find an implementation
//~^^ ERROR type `Error` does not implement any method in scope
} }
fn main() {} fn main() {}

View file

@ -16,11 +16,9 @@ extern crate rand;
struct Error; struct Error;
#[deriving(Zero)] //~ ERROR failed to find an implementation #[deriving(Zero)] //~ ERROR not implemented
struct Struct( struct Struct(
Error //~ ERROR Error
//~^ ERROR failed to find an implementation
//~^^ ERROR type `Error` does not implement any method in scope
); );
fn main() {} fn main() {}

View file

@ -8,12 +8,9 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
impl Drop for int {
//~^ ERROR the Drop trait may only be implemented on structures
type Foo = Vec<u8>; //~^^ ERROR cannot provide an extension implementation
impl Drop for Foo {
//~^ ERROR cannot provide an extension implementation
fn drop(&mut self) { fn drop(&mut self) {
println!("kaboom"); println!("kaboom");
} }

View file

@ -42,6 +42,6 @@ pub fn main() {
// Assignment. // Assignment.
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36}; let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = *z; //~ ERROR dynamically sized type on lhs of assignment f5.ptr = *z;
//~^ ERROR E0161 //~^ ERROR the trait `core::kinds::Sized` is not implemented
} }

View file

@ -43,4 +43,5 @@ pub fn main() {
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let z: Box<ToBar> = box Bar1 {f: 36}; let z: Box<ToBar> = box Bar1 {f: 36};
f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1` 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`
} }

View file

@ -28,5 +28,5 @@ pub fn main() {
let f1 = Fat { ptr: Foo }; let f1 = Fat { ptr: Foo };
let f2: &Fat<Foo> = &f1; let f2: &Fat<Foo> = &f1;
let f3: &Fat<Bar> = f2; 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`
} }

View file

@ -22,10 +22,10 @@ pub fn main() {
// With a vec of ints. // With a vec of ints.
let f1 = Fat { ptr: [1, 2, 3] }; let f1 = Fat { ptr: [1, 2, 3] };
let f2: &Fat<[int, ..3]> = &f1; 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. // With a trait.
let f1 = Fat { ptr: Foo }; let f1 = Fat { ptr: Foo };
let f2: &Fat<Foo> = &f1; 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
} }

View file

@ -30,10 +30,9 @@ pub fn main() {
let y: &T = x; //~ ERROR mismatched types let y: &T = x; //~ ERROR mismatched types
// Test that we cannot convert an immutable ptr to a mutable one using *-ptrs // 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 mismatched types
let x: *mut T = &S; //~ ERROR types differ in mutability let x: *mut T = &S; //~ ERROR mismatched types
let x: *mut S = &S; let x: *mut S = &S; //~ ERROR mismatched types
//~^ ERROR mismatched types
// The below four sets of tests test that we cannot implicitly deref a *-ptr // The below four sets of tests test that we cannot implicitly deref a *-ptr
// during a coercion. // during a coercion.

View file

@ -21,6 +21,5 @@ pub fn main() {
let f: Fat<[int, ..3]> = Fat { ptr: [5i, 6, 7] }; let f: Fat<[int, ..3]> = Fat { ptr: [5i, 6, 7] };
let g: &Fat<[int]> = &f; let g: &Fat<[int]> = &f;
let h: &Fat<Fat<[int]>> = &Fat { ptr: *g }; let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
//~^ ERROR trying to initialise a dynamically sized struct //~^ ERROR the trait `core::kinds::Sized` is not implemented
//~^^ ERROR E0161
} }

View file

@ -0,0 +1,23 @@
// 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() { }

View file

@ -13,5 +13,5 @@
fn check_bound<T:Copy>(_: T) {} fn check_bound<T:Copy>(_: T) {}
fn main() { 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
} }

View file

@ -10,5 +10,5 @@
fn main() { fn main() {
format!("{:d}", "3"); format!("{:d}", "3");
//~^ ERROR: failed to find an implementation of trait core::fmt::Signed //~^ ERROR: the trait `core::fmt::Signed` is not implemented
} }

View file

@ -17,7 +17,7 @@ trait Getter<T: Clone2> {
fn get(&self) -> T; 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 } fn get(&self) -> int { *self }
} }

View file

@ -15,8 +15,8 @@ fn main() {
let y: Gc<int> = box (GC) 0; let y: Gc<int> = box (GC) 0;
println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>` 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); println!("{}", y + 1);
//~^ ERROR binary operation `+` cannot be applied to type `Gc<int>` //~^ 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
} }

View file

@ -17,6 +17,6 @@ struct S {
name: int 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() {} fn main() {}

View file

@ -11,6 +11,6 @@
trait I {} trait I {}
type K = I+'static; 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() {} fn main() {}

View file

@ -15,10 +15,9 @@ struct Struct {
} }
fn new_struct(r: A+'static) -> Struct { fn new_struct(r: A+'static) -> Struct {
//~^ ERROR variable `r` has dynamically sized type //~^ ERROR the trait `core::kinds::Sized` is not implemented
Struct { r: r } //~ ERROR trying to initialise a dynamically sized struct Struct { r: r }
//~^ ERROR E0161 //~^ ERROR the trait `core::kinds::Sized` is not implemented
//~^^ ERROR E0161
} }
trait Curve {} trait Curve {}

View file

@ -11,5 +11,6 @@
extern crate debug; extern crate debug;
fn main() { fn main() {
format!("{:?}", None); //~ ERROR: cannot determine a type for this bounded // Unconstrained type:
format!("{:?}", None); //~ ERROR: E0101
} }

View file

@ -32,10 +32,5 @@ struct A {
fn main() { fn main() {
let a = A {v: box B{v: None} as Box<Foo+Send>}; 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 //~^ ERROR the trait `core::kinds::Send` is not implemented for the type `B`
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());
} }

View file

@ -34,14 +34,14 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<&'a [int]>(); assert_copy::<&'a [int]>();
// ...unless they are mutable // ...unless they are mutable
assert_copy::<&'static mut int>(); //~ ERROR does not fulfill assert_copy::<&'static mut int>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<&'a mut int>(); //~ ERROR does not fulfill assert_copy::<&'a mut int>(); //~ ERROR `core::kinds::Copy` is not implemented
// ~ pointers are not ok // ~ pointers are not ok
assert_copy::<Box<int>>(); //~ ERROR does not fulfill assert_copy::<Box<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<String>(); //~ ERROR does not fulfill assert_copy::<String>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Vec<int> >(); //~ ERROR does not fulfill assert_copy::<Vec<int> >(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Box<&'a mut int>>(); //~ ERROR does not fulfill assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::kinds::Copy` is not implemented
// borrowed object types are generally ok // borrowed object types are generally ok
assert_copy::<&'a Dummy>(); assert_copy::<&'a Dummy>();
@ -49,14 +49,14 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<&'static Dummy+Copy>(); assert_copy::<&'static Dummy+Copy>();
// owned object types are not ok // owned object types are not ok
assert_copy::<Box<Dummy>>(); //~ ERROR does not fulfill assert_copy::<Box<Dummy>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Box<Dummy+Copy>>(); //~ ERROR does not fulfill assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::kinds::Copy` is not implemented
// mutable object types are not ok // 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 // 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 // unsafe ptrs are ok
assert_copy::<*const int>(); assert_copy::<*const int>();
@ -74,11 +74,11 @@ fn test<'a,T,U:Copy>(_: &'a int) {
assert_copy::<MyStruct>(); assert_copy::<MyStruct>();
// structs containing non-POD are not ok // 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 // managed or ref counted types are not ok
assert_copy::<Gc<int>>(); //~ ERROR does not fulfill assert_copy::<Gc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
assert_copy::<Rc<int>>(); //~ ERROR does not fulfill assert_copy::<Rc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented
} }
pub fn main() { pub fn main() {

View file

@ -19,5 +19,5 @@ fn take_param<T:Foo>(foo: &T) { }
fn main() { fn main() {
let x = box 3i; let x = box 3i;
take_param(&x); take_param(&x);
//~^ ERROR instantiating a type parameter with an incompatible type //~^ ERROR the trait `core::kinds::Copy` is not implemented
} }

View file

@ -20,20 +20,22 @@ impl<T: Send + Copy> Gettable<T> for S<T> {}
fn f<T>(val: T) { fn f<T>(val: T) {
let t: S<T> = S; let t: S<T> = S;
let a = &t as &Gettable<T>; 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; 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() { fn foo<'a>() {
let t: S<&int> = S; let t: S<&'a int> = S;
let a = &t as &Gettable<&int>; let a = &t as &Gettable<&'a int>;
//~^ ERROR instantiating a type parameter with an incompatible type
let t: Box<S<String>> = box S; let t: Box<S<String>> = box S;
let a = t as Box<Gettable<String>>; 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 t: Box<S<String>> = box S;
let a: Box<Gettable<String>> = t; 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() { }

View file

@ -23,8 +23,8 @@ fn take_param<T:Foo>(foo: &T) { }
fn main() { fn main() {
let x = box 3i; 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 y = &x;
let z = &x as &Foo; //~ ERROR does not fulfill `Copy` let z = &x as &Foo; //~ ERROR `core::kinds::Copy` is not implemented
} }

View file

@ -13,10 +13,10 @@ fn is_freeze<T: Sync>() {}
fn foo<'a>() { fn foo<'a>() {
is_send::<proc()>(); is_send::<proc()>();
//~^ ERROR: instantiating a type parameter with an incompatible type //~^ ERROR: the trait `core::kinds::Send` is not implemented
is_freeze::<proc()>(); is_freeze::<proc()>();
//~^ ERROR: instantiating a type parameter with an incompatible type //~^ ERROR: the trait `core::kinds::Sync` is not implemented
} }
fn main() { } fn main() { }

View file

@ -19,19 +19,20 @@ trait Message : Send { }
// careful with object types, who knows what they close over... // careful with object types, who knows what they close over...
fn object_ref_with_static_bound_not_ok() { 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>() { 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>() { 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>() { 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() { fn object_with_send_bound_ok() {

View file

@ -18,6 +18,7 @@ trait Dummy { }
// careful with object types, who knows what they close over... // careful with object types, who knows what they close over...
fn test51<'a>() { fn test51<'a>() {
assert_send::<&'a Dummy>(); //~ ERROR does not fulfill the required lifetime assert_send::<&'a Dummy>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
} }
fn test52<'a>() { fn test52<'a>() {
assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill the required lifetime assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill the required lifetime
@ -35,10 +36,12 @@ fn test61() {
// them not ok // them not ok
fn test_70<'a>() { fn test_70<'a>() {
assert_send::<proc():'a>(); //~ ERROR does not fulfill the required lifetime assert_send::<proc():'a>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
} }
fn test_71<'a>() { fn test_71<'a>() {
assert_send::<Box<Dummy+'a>>(); //~ ERROR does not fulfill the required lifetime assert_send::<Box<Dummy+'a>>(); //~ ERROR does not fulfill the required lifetime
//~^ ERROR the trait `core::kinds::Send` is not implemented
} }
fn main() { } fn main() { }

View file

@ -14,11 +14,11 @@ fn assert_send<T:Send>() { }
trait Dummy { } trait Dummy { }
fn test50() { 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() { 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 // ...unless they are properly bounded

View file

@ -0,0 +1,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.
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() {
}

View file

@ -18,6 +18,5 @@ fn main() {
let x: Box<HashMap<int, int>> = box HashMap::new(); let x: Box<HashMap<int, int>> = box HashMap::new();
let x: Box<Map<int, int>> = x; let x: Box<Map<int, int>> = x;
let y: Box<Map<uint, int>> = box x; let y: Box<Map<uint, int>> = box x;
//~^ ERROR failed to find an implementation of trait collections::Map<uint,int> //~^ ERROR the trait `collections::Map<uint,int>` is not implemented
//~^^ ERROR failed to find an implementation of trait core::collections::Collection
} }

View file

@ -14,5 +14,5 @@ fn foo<P:Copy>(p: P) { }
fn main() fn main()
{ {
foo(marker::NoCopy); //~ ERROR does not fulfill foo(marker::NoCopy); //~ ERROR the trait `core::kinds::Copy` is not implemented
} }

View file

@ -14,5 +14,5 @@ fn foo<P:Send>(p: P) { }
fn main() fn main()
{ {
foo(marker::NoSend); //~ ERROR does not fulfill `Send` foo(marker::NoSend); //~ ERROR the trait `core::kinds::Send` is not implemented
} }

View file

@ -14,5 +14,5 @@ fn foo<P: Sync>(p: P) { }
fn main() fn main()
{ {
foo(marker::NoSync); //~ ERROR does not fulfill `Sync` foo(marker::NoSync); //~ ERROR the trait `core::kinds::Sync` is not implemented
} }

View file

@ -14,5 +14,5 @@ fn f<T: Sync>(_: T) {}
fn main() { fn main() {
let x = RefCell::new(0i); let x = RefCell::new(0i);
f(x); //~ ERROR: which does not fulfill `Sync` f(x); //~ ERROR `core::kinds::Sync` is not implemented
} }

View file

@ -19,5 +19,5 @@ fn bar<T: Sync>(_: T) {}
fn main() { fn main() {
let x = A(marker::NoSync); 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
} }

View file

@ -36,7 +36,8 @@ fn main() {
let x = foo(Port(box(GC) ())); let x = foo(Port(box(GC) ()));
task::spawn(proc() { task::spawn(proc() {
let y = x; //~ ERROR does not fulfill `Send` let y = x;
//~^ ERROR does not fulfill `Send`
println!("{:?}", y); println!("{:?}", y);
}); });
} }

View file

@ -19,6 +19,5 @@ fn bar<T: Send>(_: T) {}
fn main() { fn main() {
let x = A(marker::NoSend); let x = A(marker::NoSend);
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`, //~^ ERROR `core::kinds::Send` is not implemented
// which does not fulfill `Send`
} }

View file

@ -15,6 +15,5 @@ fn bar<T: Send>(_: T) {}
fn main() { fn main() {
let x = Rc::new(5i); let x = Rc::new(5i);
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `alloc::rc::Rc<int>`, //~^ ERROR `core::kinds::Send` is not implemented
// which does not fulfill `Send`
} }

View file

@ -20,6 +20,5 @@ fn bar<T: Send>(_: T) {}
fn main() { fn main() {
let x = Foo { a: 5, ns: marker::NoSend }; let x = Foo { a: 5, ns: marker::NoSend };
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`, //~^ ERROR the trait `core::kinds::Send` is not implemented
// which does not fulfill `Send`
} }

View file

@ -17,6 +17,5 @@ fn bar<T: Sync>(_: T) {}
fn main() { fn main() {
let x = A(marker::NoSync); let x = A(marker::NoSync);
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`, //~^ ERROR the trait `core::kinds::Sync` is not implemented
// which does not fulfill `Sync`
} }

View file

@ -16,6 +16,5 @@ fn bar<T: Sync>(_: T) {}
fn main() { fn main() {
let x = Rc::new(RefCell::new(5i)); let x = Rc::new(RefCell::new(5i));
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type //~^ ERROR the trait `core::kinds::Sync` is not implemented
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Sync`
} }

View file

@ -17,6 +17,5 @@ fn bar<T: Sync>(_: T) {}
fn main() { fn main() {
let x = Foo { a: 5, m: marker::NoSync }; let x = Foo { a: 5, m: marker::NoSync };
bar(x); bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`, //~^ ERROR the trait `core::kinds::Sync` is not implemented
// which does not fulfill `Sync`
} }

View file

@ -14,6 +14,6 @@
trait Foo {} trait Foo {}
fn take_foo<F:Foo>(f: F) {} fn take_foo<F:Foo>(f: F) {}
fn take_object(f: Box<Foo>) { take_foo(f); } //~ ERROR failed to find an implementation of trait fn take_object(f: Box<Foo>) { take_foo(f); }
//~^ ERROR failed to find an implementation //~^ ERROR the trait `Foo` is not implemented
fn main() {} fn main() {}

View file

@ -43,8 +43,7 @@ fn main() {
{ {
// Can't do this copy // Can't do this copy
let x = box box box A {y: r(i)}; let x = box box box A {y: r(i)};
let _z = x.clone(); //~ ERROR failed to find an implementation let _z = x.clone(); //~ ERROR not implemented
//~^ ERROR failed to find an implementation
println!("{:?}", x); println!("{:?}", x);
} }
println!("{:?}", *i); println!("{:?}", *i);

View file

@ -12,8 +12,6 @@
// nominal types (but not on other types) and that they are type // nominal types (but not on other types) and that they are type
// checked. // checked.
#![no_std]
struct Inv<'a> { // invariant w/r/t 'a struct Inv<'a> { // invariant w/r/t 'a
x: &'a mut &'a int x: &'a mut &'a int
} }

View file

@ -58,6 +58,7 @@ fn box_with_region_not_ok<'a>() {
fn object_with_random_bound_not_ok<'a>() { fn object_with_random_bound_not_ok<'a>() {
assert_send::<&'a Dummy+'a>(); //~ ERROR does not fulfill assert_send::<&'a Dummy+'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
} }
fn object_with_send_bound_not_ok<'a>() { 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>() { fn proc_with_lifetime_not_ok<'a>() {
assert_send::<proc():'a>(); //~ ERROR does not fulfill assert_send::<proc():'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
} }
fn closure_with_lifetime_not_ok<'a>() { fn closure_with_lifetime_not_ok<'a>() {
assert_send::<||:'a>(); //~ ERROR does not fulfill assert_send::<||:'a>(); //~ ERROR does not fulfill
//~^ ERROR not implemented
} }
// unsafe pointers are ok unless they point at unsendable things // unsafe pointers are ok unless they point at unsendable things

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![no_std]
// Check that explicit region bounds are allowed on the various // Check that explicit region bounds are allowed on the various
// nominal types (but not on other types) and that they are type // nominal types (but not on other types) and that they are type
// checked. // checked.

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![no_std]
#![allow(dead_code)] #![allow(dead_code)]
trait Deref { trait Deref {

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![no_std]
fn a<'a, 'b:'a>(x: &mut &'a int, y: &mut &'b int) { fn a<'a, 'b:'a>(x: &mut &'a int, y: &mut &'b int) {
// Note: this is legal because of the `'b:'a` declaration. // Note: this is legal because of the `'b:'a` declaration.
*x = *y; *x = *y;

View file

@ -24,5 +24,6 @@ impl Drop for Foo {
fn main() { fn main() {
let a = Foo { x: 3 }; 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`
} }

View file

@ -16,5 +16,5 @@ fn test_send<S: Send>() {}
pub fn main() { pub fn main() {
test_send::<rand::TaskRng>(); test_send::<rand::TaskRng>();
//~^ ERROR: incompatible type `std::rand::TaskRng`, which does not fulfill `Send` //~^ ERROR `core::kinds::Send` is not implemented
} }

View file

@ -14,7 +14,7 @@ trait Foo {
// This should emit the less confusing error, not the more confusing one. // This should emit the less confusing error, not the more confusing one.
fn foo(_x: Foo + Send) { 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() { } fn main() { }

View file

@ -16,12 +16,11 @@ struct Foo<T:Trait> {
fn main() { fn main() {
let foo = Foo { let foo = Foo {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
x: 3i x: 3i
}; };
let baz: Foo<uint> = fail!(); let baz: Foo<uint> = fail!();
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
} }

View file

@ -15,8 +15,7 @@ struct Foo<T:Trait> {
} }
static X: Foo<uint> = Foo { static X: Foo<uint> = Foo {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
x: 1, x: 1,
}; };

View file

@ -15,22 +15,11 @@ extern crate trait_bounds_on_structs_and_enums_xc;
use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait}; use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait};
fn explode(x: Foo<uint>) {} fn explode(x: Foo<uint>) {}
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
fn kaboom(y: Bar<f32>) {} fn kaboom(y: Bar<f32>) {}
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
fn main() { 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;
} }

View file

@ -0,0 +1,26 @@
// 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;
}

View file

@ -20,40 +20,34 @@ enum Bar<T:Trait> {
CBar(uint), CBar(uint),
} }
fn explode(x: Foo<uint>) {} fn explode(x: Foo<u32>) {}
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
fn kaboom(y: Bar<f32>) {} fn kaboom(y: Bar<f32>) {}
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
impl<T> Foo<T> { //~ ERROR failed to find an implementation impl<T> Foo<T> {
//~^ ERROR instantiating a type parameter with an incompatible type //~^ ERROR the trait `Trait` is not implemented
fn uhoh() {} fn uhoh() {}
} }
struct Baz { struct Baz {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
a: Foo<int>, a: Foo<int>,
} }
enum Boo { enum Boo {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
Quux(Bar<uint>), Quux(Bar<uint>),
} }
struct Badness<T> { struct Badness<T> {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
b: Foo<T>, b: Foo<T>,
} }
enum MoreBadness<T> { enum MoreBadness<T> {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
EvenMoreBadness(Bar<T>), EvenMoreBadness(Bar<T>),
} }
@ -64,15 +58,10 @@ trait PolyTrait<T> {
struct Struct; struct Struct;
impl PolyTrait<Foo<uint>> for Struct { impl PolyTrait<Foo<uint>> for Struct {
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
//~^^ ERROR instantiating a type parameter with an incompatible type
fn whatever() {} fn whatever() {}
} }
fn main() { fn main() {
let bar: Bar<f64> = return;
//~^ ERROR failed to find an implementation
//~^^ ERROR instantiating a type parameter with an incompatible type
let _ = bar;
} }

View file

@ -25,7 +25,6 @@ impl Trait<&'static str> for Struct {
fn main() { fn main() {
let s: Box<Trait<int>> = box Struct { person: "Fred" }; let s: Box<Trait<int>> = box Struct { person: "Fred" };
//~^ ERROR expected Trait<int>, found Trait<&'static str> //~^ ERROR type mismatch
//~^^ ERROR expected Trait<int>, found Trait<&'static str>
s.f(1); s.f(1);
} }

View file

@ -15,12 +15,12 @@ trait Tr<T> {
// these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T> // these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T>
trait A: Tr<Self> { trait A: Tr<Self> {
fn test<U>(u: U) -> 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> { trait B<T>: Tr<T> {
fn test<U>(u: U) -> Self { fn test<U>(u: U) -> Self {
Tr::op(u) //~ ERROR expected Tr<U>, found Tr<T> Tr::op(u) //~ ERROR type mismatch
} }
} }

View file

@ -39,5 +39,5 @@ fn main() {
let ns = NoSync{m: marker::NoSync}; let ns = NoSync{m: marker::NoSync};
test(ns); test(ns);
//~^ ERROR instantiating a type parameter with an incompatible type `NoSync`, which does not fulfill `Sync` //~^ ERROR `core::kinds::Sync` is not implemented
} }

View file

@ -18,8 +18,7 @@ fn call_it<F:FnMut<(int,int),int>>(y: int, mut f: F) -> int {
pub fn main() { pub fn main() {
let f = |&mut: x: uint, y: int| -> int { (x as int) + y }; let f = |&mut: x: uint, y: int| -> int { (x as int) + y };
let z = call_it(3, f); //~ ERROR expected core::ops::FnMut let z = call_it(3, f); //~ ERROR type mismatch
//~^ ERROR expected core::ops::FnMut
println!("{}", z); println!("{}", z);
} }

View file

@ -17,6 +17,6 @@ fn c<F:|: int, int| -> int>(f: F) -> int {
fn main() { fn main() {
let z: int = 7; let z: int = 7;
assert_eq!(c(|&: x: int, y| x + y + z), 10); assert_eq!(c(|&: x: int, y| x + y + z), 10);
//~^ ERROR failed to find an implementation //~^ ERROR not implemented
} }

View file

@ -20,7 +20,6 @@ impl Drop for r {
fn main() { fn main() {
let i = box r { b: true }; let i = box r { b: true };
let _j = i.clone(); //~ ERROR failed to find an implementation let _j = i.clone(); //~ ERROR not implemented
//~^ ERROR failed to find an implementation
println!("{:?}", i); println!("{:?}", i);
} }

View file

@ -16,5 +16,5 @@ fn f<T:Send>(_i: T) {
fn main() { fn main() {
let i = box box(GC) 100i; let i = box box(GC) 100i;
f(i); //~ ERROR does not fulfill `Send` f(i); //~ ERROR `core::kinds::Send` is not implemented
} }

View file

@ -36,10 +36,8 @@ fn main() {
let r1 = vec!(box r { i: i1 }); let r1 = vec!(box r { i: i1 });
let r2 = vec!(box r { i: i2 }); let r2 = vec!(box r { i: i2 });
f(r1.clone(), r2.clone()); f(r1.clone(), r2.clone());
//~^ ERROR failed to find an implementation of //~^ ERROR the trait `core::clone::Clone` is not implemented
//~^^ ERROR failed to find an implementation of //~^^ ERROR the trait `core::clone::Clone` is not implemented
//~^^^ ERROR failed to find an implementation of
//~^^^^ ERROR failed to find an implementation of
println!("{:?}", (r2, i1.get())); println!("{:?}", (r2, i1.get()));
println!("{:?}", (r1, i2.get())); println!("{:?}", (r1, i2.get()));
} }

View file

@ -28,6 +28,6 @@ fn foo(i:int, j: Gc<String>) -> foo {
fn main() { fn main() {
let cat = "kitty".to_string(); let cat = "kitty".to_string();
let (tx, _) = channel(); //~ ERROR does not fulfill `Send` let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented
tx.send(foo(42, box(GC) (cat))); //~ ERROR does not fulfill `Send` tx.send(foo(42, box(GC) (cat))); //~ ERROR `core::kinds::Send` is not implemented
} }

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: instantiating a type parameter with an incompatible type
fn bar<T: Sized>() { } 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() { } fn main() { }

View file

@ -8,7 +8,14 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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 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() { } fn main() { }

View file

@ -8,10 +8,13 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: instantiating a type parameter with an incompatible type
struct Foo<T> { data: T } struct Foo<T> { data: T }
fn bar<T: Sized>() { } fn bar<T: Sized>() { }
fn foo<Sized? T>() { bar::<Foo<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 the T in Foo<T>, the other is for Foo<T> as a value
// for bar's type parameter.
fn main() { } fn main() { }

View file

@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// Test sized-ness checking in substitution. // Test sized-ness checking in substitution within fn bodies..
// Unbounded. // Unbounded.
fn f1<Sized? X>(x: &X) { 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) { fn f2<X>(x: &X) {
} }
@ -21,7 +22,8 @@ fn f2<X>(x: &X) {
// Bounded. // Bounded.
trait T for Sized? {} trait T for Sized? {}
fn f3<Sized? X: T>(x: &X) { 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) { fn f4<X: T>(x: &X) {
} }
@ -34,7 +36,8 @@ enum E<Sized? X> {
fn f5<Y>(x: &Y) {} fn f5<Y>(x: &Y) {}
fn f6<Sized? X>(x: &X) {} fn f6<Sized? X>(x: &X) {}
fn f7<Sized? X>(x1: &E<X>, x2: &E<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 f6(x2); // ok
} }
@ -45,40 +48,18 @@ struct S<Sized? X> {
} }
fn f8<Sized? X>(x1: &S<X>, x2: &S<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 f6(x2); // ok
} }
// Test some tuples. // Test some tuples.
fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) { fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
f5(&(*x1, 34i)); //~ERROR E0161 f5(&(*x1, 34i));
//~^ ERROR instantiating a type parameter with an incompatible type //~^ ERROR the trait `core::kinds::Sized` is not implemented
f5(&(32i, *x2)); //~ERROR E0161 f5(&(32i, *x2));
//~^ ERROR instantiating a type parameter with an incompatible type //~^ 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() { pub fn main() {
} }

View file

@ -14,33 +14,29 @@
trait T for Sized? {} trait T for Sized? {}
fn f1<Sized? X>(x: &X) { fn f1<Sized? X>(x: &X) {
let _: X; //~ERROR variable `_` has dynamically sized type `X` let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))` let _: (int, (X, int)); // same
let y: X; //~ERROR variable `y` has dynamically sized type `X` let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))` let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
} }
fn f2<Sized? X: T>(x: &X) { fn f2<Sized? X: T>(x: &X) {
let _: X; //~ERROR variable `_` has dynamically sized type `X` let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))` let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
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))`
} }
fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { 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: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
//~^ ERROR E0161
} }
fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { 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: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
//~^ ERROR E0161
} }
fn g1<Sized? X>(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 variable `x` has dynamically sized type `X` fn g2<Sized? X: T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
pub fn main() { pub fn main() {
} }

View file

@ -0,0 +1,43 @@
// 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() { }

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: failed to find an implementation
struct r { struct r {
i:int i:int
} }
@ -25,5 +23,7 @@ fn main() {
let i = vec!(r(0)); let i = vec!(r(0));
let j = vec!(r(1)); let j = vec!(r(1));
let k = i + j; let k = i + j;
//~^ ERROR not implemented
println!("{}", j); println!("{}", j);
//~^ ERROR not implemented
} }

View file

@ -24,8 +24,7 @@ impl TraitB for int {
fn call_it<B:TraitB>(b: B) -> int { fn call_it<B:TraitB>(b: B) -> int {
let y = 4u; let y = 4u;
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait TraitA b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented
//~^ ERROR failed to find an implementation of trait TraitA
} }
fn main() { fn main() {

View file

@ -15,9 +15,6 @@ struct Struct;
fn main() { fn main() {
drop(equal(&Struct, &Struct)) drop(equal(&Struct, &Struct))
//~^ ERROR failed to find an implementation of trait core::cmp::Eq //~^ ERROR the trait `core::cmp::Eq` is not implemented
//~^^ 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
} }

View file

@ -0,0 +1,42 @@
// 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);
}
}

View file

@ -0,0 +1,39 @@
// 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();
}