Address review commets
I think I didn't run tests properly - my second call to select_all_obligations_or_error has made 3 tests fail. However, this is just an error message change - integer fallback never worked with casts.
This commit is contained in:
parent
de4b0e9961
commit
32fe2e3ad4
14 changed files with 123 additions and 103 deletions
|
|
@ -28,15 +28,15 @@ impl Foo for isize {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let a = &42 as &Foo<A=usize, B=char>;
|
||||
let a = &42isize as &Foo<A=usize, B=char>;
|
||||
|
||||
let b = &42 as &Foo<A=usize>;
|
||||
let b = &42isize as &Foo<A=usize>;
|
||||
//~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
|
||||
|
||||
let c = &42 as &Foo<B=char>;
|
||||
let c = &42isize as &Foo<B=char>;
|
||||
//~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
|
||||
|
||||
let d = &42 as &Foo;
|
||||
let d = &42isize as &Foo;
|
||||
//~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
|
||||
//~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ fn main()
|
|||
let _ = &f as *const f64; //~ ERROR illegal cast
|
||||
let _ = fat_v as usize; //~ ERROR through a raw pointer first
|
||||
|
||||
let a : *const str = "hello";
|
||||
let _ = a as *const Foo;
|
||||
//~^ ERROR `core::marker::Sized` is not implemented for the type `str`
|
||||
|
||||
// check no error cascade
|
||||
let _ = main.f as *const u32; //~ ERROR attempted access of field
|
||||
|
||||
|
|
|
|||
|
|
@ -28,29 +28,29 @@ fn main() {
|
|||
// if n > m, it's a type mismatch error.
|
||||
|
||||
// n < m
|
||||
let &x = &(&1 as &T);
|
||||
let &x = &&(&1 as &T);
|
||||
let &&x = &&(&1 as &T);
|
||||
let &x = &(&1isize as &T);
|
||||
let &x = &&(&1isize as &T);
|
||||
let &&x = &&(&1isize as &T);
|
||||
|
||||
// n == m
|
||||
let &x = &1 as &T; //~ ERROR type `&T` cannot be dereferenced
|
||||
let &&x = &(&1 as &T); //~ ERROR type `&T` cannot be dereferenced
|
||||
let box x = box 1 as Box<T>; //~ ERROR the trait `core::marker::Sized` is not implemented
|
||||
let &x = &1isize as &T; //~ ERROR type `&T` cannot be dereferenced
|
||||
let &&x = &(&1isize as &T); //~ ERROR type `&T` cannot be dereferenced
|
||||
let box x = box 1isize as Box<T>; //~ ERROR the trait `core::marker::Sized` is not implemented
|
||||
|
||||
// n > m
|
||||
let &&x = &1 as &T;
|
||||
let &&x = &1isize as &T;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected `T`
|
||||
//~| found `&_`
|
||||
//~| expected trait T
|
||||
//~| found &-ptr
|
||||
let &&&x = &(&1 as &T);
|
||||
let &&&x = &(&1isize as &T);
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected `T`
|
||||
//~| found `&_`
|
||||
//~| expected trait T
|
||||
//~| found &-ptr
|
||||
let box box x = box 1 as Box<T>;
|
||||
let box box x = box 1isize as Box<T>;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected `T`
|
||||
//~| found `Box<_>`
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
static X: usize = 0 as *const usize as usize;
|
||||
//~^ ERROR: can not cast a pointer to an integer in statics
|
||||
//~^ ERROR: can't cast a pointer to an integer in statics
|
||||
|
||||
fn main() {
|
||||
assert_eq!(X, 0);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ impl Foo for isize {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
(&5 as &Foo).foo();
|
||||
(&5isize as &Foo).foo();
|
||||
//~^ ERROR: no method named `foo` found for type `&Foo` in the current scope
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ fn f<T>(val: T) {
|
|||
let a = &t as &Gettable<T>;
|
||||
//~^ ERROR the trait `core::marker::Send` is not implemented
|
||||
//~^^ ERROR the trait `core::marker::Copy` is not implemented
|
||||
//~^^^ ERROR the parameter type `T` may not live long enough
|
||||
}
|
||||
|
||||
fn g<T>(val: T) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Check that you can cast between different pointers to trait objects
|
||||
// whose vtable have the same kind (both lengths, or both trait pointers).
|
||||
|
||||
trait Foo<T> {
|
||||
fn foo(&self, _: T) -> u32 { 42 }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue