2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-06-14 23:04:53 -05:00
|
|
|
fn main() {
|
|
|
|
|
|
|
|
// the smallest positive values that need these types
|
|
|
|
let a8: i8 = 8;
|
|
|
|
let a16: i16 = 128;
|
|
|
|
let a32: i32 = 32_768;
|
|
|
|
let a64: i64 = 2_147_483_648;
|
|
|
|
|
|
|
|
// the smallest negative values that need these types
|
|
|
|
let c8: i8 = -9;
|
|
|
|
let c16: i16 = -129;
|
|
|
|
let c32: i32 = -32_769;
|
|
|
|
let c64: i64 = -2_147_483_649;
|
|
|
|
|
|
|
|
fn id_i8(n: i8) -> i8 { n }
|
|
|
|
fn id_i16(n: i16) -> i16 { n }
|
|
|
|
fn id_i32(n: i32) -> i32 { n }
|
|
|
|
fn id_i64(n: i64) -> i64 { n }
|
|
|
|
|
|
|
|
// the smallest values that need these types
|
|
|
|
let b8: u8 = 16;
|
|
|
|
let b16: u16 = 256;
|
|
|
|
let b32: u32 = 65_536;
|
|
|
|
let b64: u64 = 4_294_967_296;
|
|
|
|
|
|
|
|
fn id_u8(n: u8) -> u8 { n }
|
|
|
|
fn id_u16(n: u16) -> u16 { n }
|
|
|
|
fn id_u32(n: u32) -> u32 { n }
|
|
|
|
fn id_u64(n: u64) -> u64 { n }
|
|
|
|
|
|
|
|
id_i8(a8); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(a16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(a32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(a64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(a8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i8
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i16(a16); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(a32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(a64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(a8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(a16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i16
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i32(a32); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(a64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i32
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i64(a64); // ok
|
|
|
|
|
|
|
|
id_i8(c8); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(c16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(c32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i8(c64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i8, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(c8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i8
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i16(c16); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(c32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i16(c64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i16, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(c8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(c16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i16
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i32(c32); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i32(c64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i32, found i64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_i64(a32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected i64, found i32
|
2012-06-14 23:04:53 -05:00
|
|
|
id_i64(a64); // ok
|
|
|
|
|
|
|
|
id_u8(b8); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u8(b16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u8, found u16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u8(b32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u8, found u32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u8(b64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u8, found u64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u16(b8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u16, found u8
|
2012-06-14 23:04:53 -05:00
|
|
|
id_u16(b16); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u16(b32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u16, found u32
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u16(b64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u16, found u64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u32(b8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u32, found u8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u32(b16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u32, found u16
|
2012-06-14 23:04:53 -05:00
|
|
|
id_u32(b32); // ok
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u32(b64);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u32, found u64
|
2012-06-14 23:04:53 -05:00
|
|
|
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u64(b8);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u64, found u8
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u64(b16);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u64, found u16
|
2015-01-12 00:01:44 -06:00
|
|
|
id_u64(b32);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected u64, found u32
|
2012-06-14 23:04:53 -05:00
|
|
|
id_u64(b64); // ok
|
|
|
|
}
|