Skip to content

Commit

Permalink
test fallout from isize/usize
Browse files Browse the repository at this point in the history
  • Loading branch information
emberian committed Jan 6, 2015
1 parent abcbe27 commit 5a4ca31
Show file tree
Hide file tree
Showing 86 changed files with 644 additions and 642 deletions.
4 changes: 2 additions & 2 deletions src/librustc_resolve/lib.rs
Expand Up @@ -834,14 +834,14 @@ impl PrimitiveTypeTable {
table.intern("f32", TyFloat(TyF32));
table.intern("f64", TyFloat(TyF64));
table.intern("int", TyInt(TyIs));
table.intern("isize", TyInt(TyIs));
table.intern("isize", TyInt(TyIs));
table.intern("i8", TyInt(TyI8));
table.intern("i16", TyInt(TyI16));
table.intern("i32", TyInt(TyI32));
table.intern("i64", TyInt(TyI64));
table.intern("str", TyStr);
table.intern("uint", TyUint(TyUs));
table.intern("usize", TyUint(TyUs));
table.intern("usize", TyUint(TyUs));
table.intern("u8", TyUint(TyU8));
table.intern("u16", TyUint(TyU16));
table.intern("u32", TyUint(TyU32));
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ast_util.rs
Expand Up @@ -141,7 +141,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
match t {
TyI8 => 0x80u64,
TyI16 => 0x8000u64,
TyIs | TyI32 => 0x80000000u64, // actually ni about TyIm
TyIs | TyI32 => 0x80000000u64, // actually ni about TyIs
TyI64 => 0x8000000000000000u64
}
}
Expand All @@ -168,7 +168,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 {
match t {
TyU8 => 0xffu64,
TyU16 => 0xffffu64,
TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUm
TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUs
TyU64 => 0xffffffffffffffffu64
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/array-not-vector.rs
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

fn main() {
let _x: int = [1i, 2, 3]; //~ ERROR expected int, found array of 3 elements
let _x: isize = [1is, 2, 3]; //~ ERROR expected isize, found array of 3 elements

let x: &[int] = &[1, 2, 3];
let _y: &int = x; //~ ERROR expected int, found slice
let x: &[isize] = &[1, 2, 3];
let _y: &isize = x; //~ ERROR expected isize, found slice
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/associated-types-eq-3.rs
Expand Up @@ -41,6 +41,6 @@ pub fn baz(x: &Foo<A=Bar>) {

pub fn main() {
let a = 42i;
foo1(a); //~ERROR expected uint, found struct Bar
baz(&a); //~ERROR expected uint, found struct Bar
foo1(a); //~ERROR expected usize, found struct Bar
baz(&a); //~ERROR expected usize, found struct Bar
}
Expand Up @@ -17,8 +17,8 @@ trait Foo<T> {
}

fn f<T:Foo<int>>(t: &T) {
let u: <T as Foo<uint>>::Bar = t.get_bar();
//~^ ERROR the trait `Foo<uint>` is not implemented for the type `T`
let u: <T as Foo<usize>>::Bar = t.get_bar();
//~^ ERROR the trait `Foo<usize>` is not implemented for the type `T`
}

fn main() { }
14 changes: 7 additions & 7 deletions src/test/compile-fail/associated-types-path-2.rs
Expand Up @@ -24,29 +24,29 @@ pub fn f2<T: Foo>(a: T) -> T::A {
}

pub fn f1_int_int() {
f1(2i, 4i);
//~^ ERROR expected uint, found int
f1(2is, 4is);
//~^ ERROR expected usize, found isize
}

pub fn f1_int_uint() {
f1(2i, 4u);
f1(2is, 4us);
}

pub fn f1_uint_uint() {
f1(2u, 4u);
f1(2us, 4us);
//~^ ERROR the trait `Foo` is not implemented
//~| ERROR the trait `Foo` is not implemented
}

pub fn f1_uint_int() {
f1(2u, 4i);
f1(2us, 4is);
//~^ ERROR the trait `Foo` is not implemented
//~| ERROR the trait `Foo` is not implemented
}

pub fn f2_int() {
let _: int = f2(2i);
//~^ ERROR expected `int`, found `uint`
let _: int = f2(2is);
//~^ ERROR expected `isize`, found `usize`
}

pub fn main() { }
10 changes: 5 additions & 5 deletions src/test/compile-fail/autoderef-full-lval.rs
Expand Up @@ -9,24 +9,24 @@
// except according to those terms.

struct clam {
x: Box<int>,
y: Box<int>,
x: Box<isize>,
y: Box<isize>,
}

struct fish {
a: Box<int>,
a: Box<isize>,
}

fn main() {
let a: clam = clam{x: box 1, y: box 2};
let b: clam = clam{x: box 10, y: box 20};
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
let z: isize = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<isize>`
println!("{}", z);
assert_eq!(z, 21);
let forty: fish = fish{a: box 40};
let two: fish = fish{a: box 2};
let answer: int = forty.a + two.a;
//~^ ERROR binary operation `+` cannot be applied to type `Box<int>`
//~^ ERROR binary operation `+` cannot be applied to type `Box<isize>`
println!("{}", answer);
assert_eq!(answer, 42);
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/bad-const-type.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:expected `collections::string::String`, found `int`
// error-pattern:expected `collections::string::String`, found `isize`

static i: String = 10i;
static i: String = 10is;
fn main() { println!("{}", i); }
4 changes: 2 additions & 2 deletions src/test/compile-fail/binop-logic-int.rs
Expand Up @@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:`&&` cannot be applied to type `int`
// error-pattern:`&&` cannot be applied to type `isize`

fn main() { let x = 1i && 2i; }
fn main() { let x = 1is && 2is; }
2 changes: 1 addition & 1 deletion src/test/compile-fail/coercion-slice.rs
Expand Up @@ -11,5 +11,5 @@
// Tests that we forbid coercion from `[T; n]` to `&[T]`

fn main() {
let _: &[int] = [0i]; //~ERROR: mismatched types: expected `&[int]`, found `[int; 1]`
let _: &[isize] = [0is]; //~ERROR: mismatched types: expected `&[isize]`, found `[isize; 1]`
}
8 changes: 4 additions & 4 deletions src/test/compile-fail/dst-bad-coerce1.rs
Expand Up @@ -18,11 +18,11 @@ struct Foo;
trait Bar {}

pub fn main() {
// With a vec of ints.
// With a vec of isize.
let f1 = Fat { ptr: [1, 2, 3] };
let f2: &Fat<[int; 3]> = &f1;
let f3: &Fat<[uint]> = f2;
//~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int; 3]>`
let f2: &Fat<[isize; 3]> = &f1;
let f3: &Fat<[usize]> = f2;
//~^ ERROR mismatched types: expected `&Fat<[usize]>`, found `&Fat<[isize; 3]>`

// With a trait.
let f1 = Fat { ptr: Foo };
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/dst-bad-coerce4.rs
Expand Up @@ -15,8 +15,8 @@ struct Fat<T: ?Sized> {
}

pub fn main() {
// With a vec of ints.
let f1: &Fat<[int]> = &Fat { ptr: [1, 2, 3] };
let f2: &Fat<[int; 3]> = f1;
//~^ ERROR mismatched types: expected `&Fat<[int; 3]>`, found `&Fat<[int]>`
// With a vec of isizes.
let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
let f2: &Fat<[isize; 3]> = f1;
//~^ ERROR mismatched types: expected `&Fat<[isize; 3]>`, found `&Fat<[isize]>`
}
8 changes: 4 additions & 4 deletions src/test/compile-fail/dst-sized-trait-param.rs
Expand Up @@ -14,10 +14,10 @@

trait Foo<T> : Sized { 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<[isize]> for uint { }
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[isize]`

impl Foo<int> for [uint] { }
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[uint]`
impl Foo<isize> for [usize] { }
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[usize]`

pub fn main() { }
16 changes: 8 additions & 8 deletions src/test/compile-fail/fn-trait-formatting.rs
Expand Up @@ -10,15 +10,15 @@

#![feature(unboxed_closures)]

fn needs_fn<F>(x: F) where F: Fn(int) -> int {}
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}

fn main() {
let _: () = (box |:_: int| {}) as Box<FnOnce(int)>; //~ ERROR object-safe
//~^ ERROR Box<core::ops::FnOnce(int)>
let _: () = (box |&:_: int, int| {}) as Box<Fn(int, int)>;
//~^ ERROR Box<core::ops::Fn(int, int)>
let _: () = (box |&mut:| -> int unimplemented!()) as Box<FnMut() -> int>;
//~^ ERROR Box<core::ops::FnMut() -> int>
let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>; //~ ERROR object-safe
//~^ ERROR Box<core::ops::FnOnce(isize)>
let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>;
//~^ ERROR Box<core::ops::Fn(isize, isize)>
let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>;
//~^ ERROR Box<core::ops::FnMut() -> isize>

needs_fn(1i); //~ ERROR `core::ops::Fn(int) -> int`
needs_fn(1i); //~ ERROR `core::ops::Fn(isize) -> isize`
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/fully-qualified-type-name1.rs
Expand Up @@ -11,7 +11,7 @@
// Test that we use fully-qualified type names in error messages.

fn main() {
let x: Option<uint>;
let x: Option<usize>;
x = 5;
//~^ ERROR mismatched types: expected `core::option::Option<uint>`
//~^ ERROR mismatched types: expected `core::option::Option<usize>`
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/fully-qualified-type-name4.rs
Expand Up @@ -12,9 +12,9 @@

use std::option::Option;

fn bar(x: uint) -> Option<uint> {
fn bar(x: usize) -> Option<usize> {
return x;
//~^ ERROR mismatched types: expected `core::option::Option<uint>`
//~^ ERROR mismatched types: expected `core::option::Option<usize>`
}

fn main() {
Expand Down
20 changes: 10 additions & 10 deletions src/test/compile-fail/generic-type-params-name-repr.rs
Expand Up @@ -18,22 +18,22 @@ struct HashMap<K, V, H = Hash<K>>;

fn main() {
// Ensure that the printed type doesn't include the default type params...
let _: Foo<int> = ();
//~^ ERROR mismatched types: expected `Foo<int>`, found `()`
let _: Foo<isize> = ();
//~^ ERROR mismatched types: expected `Foo<isize>`, found `()`

// ...even when they're present, but the same types as the defaults.
let _: Foo<int, B, C> = ();
//~^ ERROR mismatched types: expected `Foo<int>`, found `()`
let _: Foo<isize, B, C> = ();
//~^ ERROR mismatched types: expected `Foo<isize>`, found `()`

// Including cases where the default is using previous type params.
let _: HashMap<String, int> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, int>`, found `()`
let _: HashMap<String, int, Hash<String>> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, int>`, found `()`
let _: HashMap<String, isize> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()`
let _: HashMap<String, isize, Hash<String>> = ();
//~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()`

// But not when there's a different type in between.
let _: Foo<A, int, C> = ();
//~^ ERROR mismatched types: expected `Foo<A, int>`, found `()`
let _: Foo<A, isize, C> = ();
//~^ ERROR mismatched types: expected `Foo<A, isize>`, found `()`

// And don't print <> at all when there's just defaults.
let _: Foo<A, B, C> = ();
Expand Down
12 changes: 6 additions & 6 deletions src/test/compile-fail/hrtb-just-for-static.rs
Expand Up @@ -16,22 +16,22 @@ trait Foo<X> {
}

fn want_hrtb<T>()
where T : for<'a> Foo<&'a int>
where T : for<'a> Foo<&'a isize>
{
}

// AnyInt implements Foo<&'a int> for any 'a, so it is a match.
// AnyInt implements Foo<&'a isize> for any 'a, so it is a match.
struct AnyInt;
impl<'a> Foo<&'a int> for AnyInt { }
impl<'a> Foo<&'a isize> for AnyInt { }
fn give_any() {
want_hrtb::<AnyInt>()
}

// StaticInt only implements Foo<&'static int>, so it is an error.
// StaticInt only implements Foo<&'static isize>, so it is an error.
struct StaticInt;
impl Foo<&'static int> for StaticInt { }
impl Foo<&'static isize> for StaticInt { }
fn give_static() {
want_hrtb::<StaticInt>() //~ ERROR `for<'a> Foo<&'a int>` is not implemented
want_hrtb::<StaticInt>() //~ ERROR `for<'a> Foo<&'a isize>` is not implemented
}

fn main() { }
24 changes: 12 additions & 12 deletions src/test/compile-fail/hrtb-perfect-forwarding.rs
Expand Up @@ -30,36 +30,36 @@ impl<'a,X,F> Bar<X> for &'a mut F
}

fn no_hrtb<'b,T>(mut t: T)
where T : Bar<&'b int>
where T : Bar<&'b isize>
{
// OK -- `T : Bar<&'b int>`, and thus the impl above ensures that
// `&mut T : Bar<&'b int>`.
// OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that
// `&mut T : Bar<&'b isize>`.
no_hrtb(&mut t);
}

fn bar_hrtb<T>(mut t: T)
where T : for<'b> Bar<&'b int>
where T : for<'b> Bar<&'b isize>
{
// OK -- `T : for<'b> Bar<&'b int>`, and thus the impl above
// ensures that `&mut T : for<'b> Bar<&'b int>`. This is an
// OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above
// ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an
// example of a "perfect forwarding" impl.
bar_hrtb(&mut t);
}

fn foo_hrtb_bar_not<'b,T>(mut t: T)
where T : for<'a> Foo<&'a int> + Bar<&'b int>
where T : for<'a> Foo<&'a isize> + Bar<&'b isize>
{
// Not OK -- The forwarding impl for `Foo` requires that `Bar` also
// be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a
// int>`, we require `T : for<'a> Bar<&'a int>`, but the where
// clause only specifies `T : Bar<&'b int>`.
foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> Bar<&'a int>` is not implemented for the type `T`
// isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where
// clause only specifies `T : Bar<&'b isize>`.
foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> Bar<&'a isize>` is not implemented for the type `T`
}

fn foo_hrtb_bar_hrtb<T>(mut t: T)
where T : for<'a> Foo<&'a int> + for<'b> Bar<&'b int>
where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>
{
// OK -- now we have `T : for<'b> Bar&'b int>`.
// OK -- now we have `T : for<'b> Bar&'b isize>`.
foo_hrtb_bar_hrtb(&mut t);
}

Expand Down

0 comments on commit 5a4ca31

Please sign in to comment.