@@ -198,13 +198,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
0 as libc::size_t);
if err != 0 { return Err(io::Error::last_os_error()); }
if sz == 0 { return Err(io::Error::last_os_error()); }
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
let mut v: Vec<u8> = Vec::with_capacity(sz);
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
v.as_mut_ptr() as *mut libc::c_void, &mut sz,
ptr::null_mut(), 0 as libc::size_t);
if err != 0 { return Err(io::Error::last_os_error()); }
if sz == 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as usize - 1); // chop off trailing NUL
v.set_len(sz - 1); // chop off trailing NUL
Ok(PathBuf::from(OsString::from_vec(v)))
}
}
@@ -248,10 +248,10 @@ pub fn current_exe() -> io::Result<PathBuf> {
let mut sz: u32 = 0;
_NSGetExecutablePath(ptr::null_mut(), &mut sz);
if sz == 0 { return Err(io::Error::last_os_error()); }
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
let mut v: Vec<u8> = Vec::with_capacity(sz);
let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
if err != 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as usize - 1); // chop off trailing NUL
v.set_len(sz - 1); // chop off trailing NUL
Ok(PathBuf::from(OsString::from_vec(v)))
}
}
@@ -448,7 +448,7 @@ pub fn unsetenv(n: &OsStr) {

pub fn page_size() -> usize {
unsafe {
libc::sysconf(libc::_SC_PAGESIZE) as usize
libc::sysconf(libc::_SC_PAGESIZE).as_unsigned().widen()
}
}

@@ -474,12 +474,12 @@ pub fn home_dir() -> Option<PathBuf> {
target_os = "ios")))]
unsafe fn fallback() -> Option<OsString> {
let amt = match libc::sysconf(c::_SC_GETPW_R_SIZE_MAX) {
n if n < 0 => 512 as usize,
n => n as usize,
n if n < 0 => 512,
n => n,
};
let me = libc::getuid();
loop {
let mut buf = Vec::with_capacity(amt);
let mut buf = Vec::with_capacity(amt.as_unsigned().widen());
let mut passwd: c::passwd = mem::zeroed();
let mut result = 0 as *mut _;
match c::getpwuid_r(me, &mut passwd, buf.as_mut_ptr(),
@@ -57,7 +57,7 @@ mod imp {
MAP_FAILED};

use sys_common::thread_info;

use core::num::{ConvertSign, Widen};

// This is initialized in init() and only read from after
static mut PAGE_SIZE: usize = 0;
@@ -101,7 +101,7 @@ mod imp {
panic!("failed to get page size");
}

PAGE_SIZE = psize as usize;
PAGE_SIZE = psize.as_unsigned().widen();

let mut action: sigaction = mem::zeroed();
action.sa_flags = SA_SIGINFO | SA_ONSTACK;
@@ -55,7 +55,7 @@ impl Thread {
// Round up to the nearest page and try again.
let page_size = os::page_size();
let stack_size = (stack_size + page_size - 1) &
(-(page_size as isize - 1) as usize - 1);
((-(page_size as isize - 1)).as_unsigned() - 1);
let stack_size = stack_size as libc::size_t;
assert_eq!(pthread_attr_setstacksize(&mut attr, stack_size), 0);
}
@@ -187,6 +187,7 @@ pub mod guard {
use ptr;
use super::{pthread_self, pthread_attr_destroy};
use sys::os;
use core::num::Widen;

// These are initialized in init() and only read from after
static mut GUARD_PAGE: usize = 0;
@@ -255,7 +256,7 @@ pub mod guard {
fn pthread_get_stacksize_np(thread: pthread_t) -> libc::size_t;
}
(pthread_get_stackaddr_np(pthread_self()) as libc::size_t -
pthread_get_stacksize_np(pthread_self())) as usize
pthread_get_stacksize_np(pthread_self()))
}

#[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
@@ -278,10 +279,10 @@ pub mod guard {
let extra = if cfg!(target_os = "bitrig") {3} else {1} * os::page_size();
if pthread_main_np() == 1 {
// main thread
current_stack.ss_sp as usize - current_stack.ss_size as usize + extra
current_stack.ss_sp - current_stack.ss_size + extra
} else {
// new thread
current_stack.ss_sp as usize - current_stack.ss_size as usize
current_stack.ss_sp - current_stack.ss_size
}
}

@@ -299,7 +300,7 @@ pub mod guard {
assert_eq!(pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0);
assert_eq!(pthread_attr_destroy(&mut attr), 0);

stackaddr as usize + guardsize as usize
stackaddr as usize + guardsize.widen_(0usize)
}

#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -349,16 +350,16 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
});

match unsafe { __pthread_get_minstack } {
None => PTHREAD_STACK_MIN as usize,
Some(f) => unsafe { f(attr) as usize },
None => PTHREAD_STACK_MIN.widen(),
Some(f) => unsafe { f(attr).widen() },
}
}

// No point in looking up __pthread_get_minstack() on non-glibc
// platforms.
#[cfg(not(target_os = "linux"))]
fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
PTHREAD_STACK_MIN as usize
PTHREAD_STACK_MIN.widen()
}

extern {
@@ -13,6 +13,7 @@
#![allow(bad_style, dead_code, overflowing_literals)]

use libc;
use core::num::Widen;

pub use self::GET_FILEEX_INFO_LEVELS::*;
pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
@@ -129,7 +130,7 @@ pub struct fd_set {
}

pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {
set.fd_array[set.fd_count as usize] = s;
set.fd_array[set.fd_count.widen_(0usize)] = s;
set.fd_count += 1;
}

@@ -43,7 +43,7 @@ impl Condvar {
0);
if r == 0 {
const ERROR_TIMEOUT: DWORD = 0x5B4;
debug_assert_eq!(os::errno() as usize, ERROR_TIMEOUT as usize);
debug_assert_eq!(os::errno(), ERROR_TIMEOUT.as_signed());
false
} else {
true
@@ -12,6 +12,7 @@ use core::prelude::*;
use io::prelude::*;
use os::windows::prelude::*;

use core::num::Widen;
use ffi::OsString;
use fmt;
use io::{self, Error, SeekFrom};
@@ -343,7 +344,7 @@ impl File {
let subst_off = (*info).SubstituteNameOffset / 2;
let subst_ptr = path_buffer.offset(subst_off as isize);
let subst_len = (*info).SubstituteNameLength / 2;
let subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
let subst = slice::from_raw_parts(subst_ptr, subst_len.widen());

Ok(PathBuf::from(OsString::from_wide(subst)))
}
@@ -74,7 +74,7 @@ impl RawHandle {
});

match res {
Ok(_) => Ok(read as usize),
Ok(_) => Ok(read.widen()),

// The special treatment of BrokenPipe is to deal with Windows
// pipe semantics, which yields this error when *reading* from
@@ -93,7 +93,7 @@ impl RawHandle {
buf.len() as libc::DWORD, &mut amt,
ptr::null_mut())
}));
Ok(amt as usize)
Ok(amt.widen())
}

pub fn duplicate(&self, access: libc::DWORD, inherit: bool,
@@ -120,7 +120,7 @@ fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> io::Result<T>
0 if libc::GetLastError() == 0 => 0,
0 => return Err(io::Error::last_os_error()),
n => n,
} as usize;
}.widen();
if k == n && libc::GetLastError() ==
libc::ERROR_INSUFFICIENT_BUFFER as libc::DWORD {
n *= 2;
@@ -126,7 +126,7 @@ impl Socket {
buf.len() as i32, 0) {
-1 if c::WSAGetLastError() == c::WSAESHUTDOWN => Ok(0),
-1 => Err(last_error()),
n => Ok(n as usize)
n => Ok(n.as_unsigned().widen())
}
}
}
@@ -110,7 +110,7 @@ impl Iterator for Env {
len += 1;
}
let p = p as *const u16;
let s = slice::from_raw_parts(p, len as usize);
let s = slice::from_raw_parts(p, len.as_unsigned());
self.cur = self.cur.offset(len + 1);

let (k, v) = match s.iter().position(|&b| b == '=' as u16) {
@@ -298,7 +298,7 @@ impl Iterator for Args {

// Push it onto the list.
let ptr = ptr as *const u16;
let buf = slice::from_raw_parts(ptr, len as usize);
let buf = slice::from_raw_parts(ptr, len.as_unsigned());
OsStringExt::from_wide(buf)
})
}
@@ -329,7 +329,7 @@ pub fn page_size() -> usize {
unsafe {
let mut info = mem::zeroed();
libc::GetSystemInfo(&mut info);
return info.dwPageSize as usize;
return info.dwPageSize.widen();
}
}

@@ -15,6 +15,7 @@ use mem;
use libc;
use libc::types::os::arch::extra::{LPVOID, DWORD, LONG, BOOL};
use sys_common::stack;
use core::num::Widen;

pub struct Handler {
_data: *mut libc::c_void
@@ -56,7 +57,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> L
pub unsafe fn init() {
let mut info = mem::zeroed();
libc::GetSystemInfo(&mut info);
PAGE_SIZE = info.dwPageSize as usize;
PAGE_SIZE = info.dwPageSize.widen();

if AddVectoredExceptionHandler(0, vectored_handler) == ptr::null_mut() {
panic!("failed to install exception handler");
@@ -72,7 +72,7 @@ fn write(out: &Output, data: &[u8]) -> io::Result<usize> {

// FIXME if this only partially writes the utf16 buffer then we need to
// figure out how many bytes of `data` were actually written
assert_eq!(written as usize, utf16.len());
assert_eq!(written.widen_(0usize), utf16.len());
Ok(data.len())
}

@@ -91,7 +91,7 @@ impl Stdin {
};
let mut utf8 = self.utf8.lock().unwrap();
// Read more if the buffer is empty
if utf8.position() as usize == utf8.get_ref().len() {
if utf8.position().widen_(0usize) == utf8.get_ref().len() {
let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect();
let mut num = 0;
try!(cvt(unsafe {
@@ -101,7 +101,7 @@ impl Stdin {
&mut num,
ptr::null_mut())
}));
utf16.truncate(num as usize);
utf16.truncate(num.widen());
// FIXME: what to do about this data that has already been read?
let data = match String::from_utf16(&utf16) {
Ok(utf8) => utf8.into_bytes(),
@@ -174,7 +174,7 @@ impl Name {

pub fn usize(&self) -> usize {
let Name(nm) = *self;
nm as usize
nm.widen()
}

pub fn ident(&self) -> Ident {
@@ -261,7 +261,7 @@ impl<'ast> Map<'ast> {
}

fn find_entry(&self, id: NodeId) -> Option<MapEntry<'ast>> {
self.map.borrow().get(id as usize).cloned()
self.map.borrow().get(id.widen()).cloned()
}

pub fn krate(&self) -> &'ast Crate {
@@ -586,7 +586,7 @@ impl<'a, 'ast> Iterator for NodesMatchingSuffix<'a, 'ast> {
fn next(&mut self) -> Option<NodeId> {
loop {
let idx = self.idx;
if idx as usize >= self.map.entry_count() {
if idx.widen_(0usize) >= self.map.entry_count() {
return None;
}
self.idx += 1;
@@ -655,10 +655,10 @@ impl<'ast> NodeCollector<'ast> {
fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) {
debug!("ast_map: {:?} => {:?}", id, entry);
let len = self.map.len();
if id as usize >= len {
self.map.extend(repeat(NotPresent).take(id as usize - len + 1));
if id.widen_(0usize) >= len {
self.map.extend(repeat(NotPresent).take(id.widen_(0usize) - len + 1));
}
self.map[id as usize] = entry;
self.map[id.widen_(0usize)] = entry;
}

fn insert(&mut self, id: NodeId, node: Node<'ast>) {
@@ -55,7 +55,7 @@ pub struct CharPos(pub usize);

impl Pos for BytePos {
fn from_usize(n: usize) -> BytePos { BytePos(n as u32) }
fn to_usize(&self) -> usize { let BytePos(n) = *self; n as usize }
fn to_usize(&self) -> usize { let BytePos(n) = *self; n.widen() }
}

impl Add for BytePos {
@@ -424,7 +424,7 @@ impl Decodable for FileMap {
let lines: Vec<BytePos> = try! {
d.read_struct_field("lines", 3, |d| {
let num_lines: u32 = try! { Decodable::decode(d) };
let mut lines = Vec::with_capacity(num_lines as usize);
let mut lines = Vec::with_capacity(num_lines.widen());

if num_lines > 0 {
// Read the number of bytes used per diff.
@@ -917,7 +917,7 @@ impl CodeMap {
let mut expansions = self.expansions.borrow_mut();
expansions.push(expn_info);
let len = expansions.len();
if len > u32::max_value() as usize {
if len > u32::max_value().widen() {
panic!("too many ExpnInfo's!");
}
ExpnId(len as u32 - 1)
@@ -928,7 +928,7 @@ impl CodeMap {
{
match id {
NO_EXPANSION | COMMAND_LINE_EXPN => f(None),
ExpnId(i) => f(Some(&(*self.expansions.borrow())[i as usize]))
ExpnId(i) => f(Some(&(*self.expansions.borrow())[i.widen_(0usize)]))
}
}

@@ -185,7 +185,7 @@ fn resolve_internal(id: Ident,
}

let resolved = {
let result = (*table.table.borrow())[id.ctxt as usize];
let result = (*table.table.borrow())[id.ctxt.widen_(0usize)];
match result {
EmptyCtxt => id.name,
// ignore marks here:
@@ -229,7 +229,7 @@ fn marksof_internal(ctxt: SyntaxContext,
let mut result = Vec::new();
let mut loopvar = ctxt;
loop {
let table_entry = (*table.table.borrow())[loopvar as usize];
let table_entry = (*table.table.borrow())[loopvar.widen_(0usize)];
match table_entry {
EmptyCtxt => {
return result;
@@ -256,7 +256,7 @@ fn marksof_internal(ctxt: SyntaxContext,
/// FAILS when outside is not a mark.
pub fn outer_mark(ctxt: SyntaxContext) -> Mrk {
with_sctable(|sctable| {
match (*sctable.table.borrow())[ctxt as usize] {
match (*sctable.table.borrow())[ctxt.widen_(0usize)] {
Mark(mrk, _) => mrk,
_ => panic!("can't retrieve outer mark when outside is not a mark")
}
@@ -328,7 +328,7 @@ mod tests {
let mut result = Vec::new();
loop {
let table = table.table.borrow();
match (*table)[sc as usize] {
match (*table)[sc.widen_(0usize)] {
EmptyCtxt => {return result;},
Mark(mrk,tail) => {
result.push(M(mrk));
@@ -912,15 +912,15 @@ impl<'a> Parser<'a> {
self.reader.real_token()
} else {
// Avoid token copies with `replace`.
let buffer_start = self.buffer_start as usize;
let buffer_start = self.buffer_start;
let next_index = (buffer_start + 1) & 3;
self.buffer_start = next_index as isize;

let placeholder = TokenAndSpan {
tok: token::Underscore,
sp: self.span,
};
mem::replace(&mut self.buffer[buffer_start], placeholder)
mem::replace(&mut self.buffer[buffer_start.as_unsigned()], placeholder)
};
self.span = next.sp;
self.token = next.tok;
@@ -957,10 +957,10 @@ impl<'a> Parser<'a> {
{
let dist = distance as isize;
while self.buffer_length() < dist {
self.buffer[self.buffer_end as usize] = self.reader.real_token();
self.buffer[self.buffer_end.as_unsigned()] = self.reader.real_token();
self.buffer_end = (self.buffer_end + 1) & 3;
}
f(&self.buffer[((self.buffer_start + dist - 1) & 3) as usize].tok)
f(&self.buffer[((self.buffer_start + dist - 1) & 3).as_unsigned()].tok)
}
pub fn fatal(&self, m: &str) -> diagnostic::FatalError {
self.sess.span_diagnostic.span_fatal(self.span, m)
@@ -2329,7 +2329,7 @@ impl<'a> Parser<'a> {
};
self.fileline_help(last_span,
&format!("try parenthesizing the first index; e.g., `(foo.{}){}`",
float.trunc() as usize,
float.trunc(),
&float.fract().to_string()[1..]));
}
self.abort_if_errors();
@@ -675,7 +675,7 @@ pub fn space(p: &mut Printer) -> io::Result<()> {
}

pub fn hardbreak(p: &mut Printer) -> io::Result<()> {
spaces(p, SIZE_INFINITY as usize)
spaces(p, SIZE_INFINITY.as_unsigned())
}

pub fn hardbreak_tok_offset(off: isize) -> Token {
@@ -297,20 +297,20 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
PushParam => {
// params are 1-indexed
stack.push(mparams[match cur.to_digit(10) {
Some(d) => d as usize - 1,
Some(d) => d.widen_(0usize) - 1,
None => return Err("bad param number".to_string())
}].clone());
},
SetVar => {
if cur >= 'A' && cur <= 'Z' {
if !stack.is_empty() {
let idx = (cur as u8) - b'A';
vars.sta[idx as usize] = stack.pop().unwrap();
vars.sta[idx.widen_(0usize)] = stack.pop().unwrap();
} else { return Err("stack is empty".to_string()) }
} else if cur >= 'a' && cur <= 'z' {
if !stack.is_empty() {
let idx = (cur as u8) - b'a';
vars.dyn[idx as usize] = stack.pop().unwrap();
vars.dyn[idx.widen_(0usize)] = stack.pop().unwrap();
} else { return Err("stack is empty".to_string()) }
} else {
return Err("bad variable name in %P".to_string());
@@ -319,10 +319,10 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
GetVar => {
if cur >= 'A' && cur <= 'Z' {
let idx = (cur as u8) - b'A';
stack.push(vars.sta[idx as usize].clone());
stack.push(vars.sta[idx.widen_(0usize)].clone());
} else if cur >= 'a' && cur <= 'z' {
let idx = (cur as u8) - b'a';
stack.push(vars.dyn[idx as usize].clone());
stack.push(vars.dyn[idx.widen_(0usize)].clone());
} else {
return Err("bad variable name in %g".to_string());
}
@@ -186,34 +186,34 @@ pub fn parse(file: &mut Read, longnames: bool)
let magic = try!(read_le_u16(file));
if magic != 0x011A {
return Err(format!("invalid magic number: expected {:x}, found {:x}",
0x011A_usize, magic as usize));
0x011A_usize, magic));
}

let names_bytes = try!(read_le_u16(file)) as isize;
let bools_bytes = try!(read_le_u16(file)) as isize;
let numbers_count = try!(read_le_u16(file)) as isize;
let string_offsets_count = try!(read_le_u16(file)) as isize;
let string_table_bytes = try!(read_le_u16(file)) as isize;
let names_bytes = try!(read_le_u16(file)) as usize;
let bools_bytes = try!(read_le_u16(file)) as usize;
let numbers_count = try!(read_le_u16(file)) as usize;
let string_offsets_count = try!(read_le_u16(file)) as usize;
let string_table_bytes = try!(read_le_u16(file)) as usize;

assert!(names_bytes > 0);

if (bools_bytes as usize) > boolnames.len() {
if (bools_bytes) > boolnames.len() {
return Err("incompatible file: more booleans than \
expected".to_string());
}

if (numbers_count as usize) > numnames.len() {
if (numbers_count) > numnames.len() {
return Err("incompatible file: more numbers than \
expected".to_string());
}

if (string_offsets_count as usize) > stringnames.len() {
if (string_offsets_count) > stringnames.len() {
return Err("incompatible file: more string offsets than \
expected".to_string());
}

// don't read NUL
let bytes = try!(read_exact(file, names_bytes as usize - 1));
let bytes = try!(read_exact(file, names_bytes - 1));
let names_str = match String::from_utf8(bytes) {
Ok(s) => s,
Err(_) => return Err("input not utf-8".to_string()),
@@ -230,7 +230,7 @@ pub fn parse(file: &mut Read, longnames: bool)
for i in 0..bools_bytes {
let b = try!(read_byte(file));
if b == 1 {
bools_map.insert(bnames[i as usize].to_string(), true);
bools_map.insert(bnames[i].to_string(), true);
}
}
}
@@ -244,7 +244,7 @@ pub fn parse(file: &mut Read, longnames: bool)
for i in 0..numbers_count {
let n = try!(read_le_u16(file));
if n != 0xFFFF {
numbers_map.insert(nnames[i as usize].to_string(), n);
numbers_map.insert(nnames[i].to_string(), n);
}
}
}
@@ -257,9 +257,9 @@ pub fn parse(file: &mut Read, longnames: bool)
string_offsets.push(try!(read_le_u16(file)));
}

let string_table = try!(read_exact(file, string_table_bytes as usize));
let string_table = try!(read_exact(file, string_table_bytes));

if string_table.len() != string_table_bytes as usize {
if string_table.len() != string_table_bytes {
return Err("error: hit EOF before end of string \
table".to_string());
}
@@ -285,13 +285,13 @@ pub fn parse(file: &mut Read, longnames: bool)


// Find the offset of the NUL we want to go to
let nulpos = string_table[offset as usize .. string_table_bytes as usize]
let nulpos = string_table[offset.widen() .. string_table_bytes]
.iter().position(|&b| b == 0);
match nulpos {
Some(len) => {
string_map.insert(name.to_string(),
string_table[offset as usize ..
(offset as usize + len)].to_vec())
string_table[offset.widen() ..
(offset.widen_(0usize) + len)].to_vec())
},
None => {
return Err("invalid file: missing NUL in \
@@ -628,13 +628,13 @@ impl<T: Write> ConsoleTestState<T> {
pub fn fmt_bench_samples(bs: &BenchSamples) -> String {
if bs.mb_s != 0 {
format!("{:>9} ns/iter (+/- {}) = {} MB/s",
bs.ns_iter_summ.median as usize,
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize,
bs.ns_iter_summ.median,
(bs.ns_iter_summ.max - bs.ns_iter_summ.min),
bs.mb_s)
} else {
format!("{:>9} ns/iter (+/- {})",
bs.ns_iter_summ.median as usize,
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize)
bs.ns_iter_summ.median,
(bs.ns_iter_summ.max - bs.ns_iter_summ.min))
}
}

@@ -858,7 +858,7 @@ fn get_concurrency() -> usize {
1
} else {
extern { fn rust_get_num_cpus() -> libc::uintptr_t; }
unsafe { rust_get_num_cpus() as usize }
unsafe { rust_get_num_cpus().widen() }
}
}
}
@@ -1180,7 +1180,7 @@ pub mod bench {

BenchSamples {
ns_iter_summ: ns_iter_summ,
mb_s: mb_s as usize
mb_s: mb_s.truncate()
}
}

@@ -297,9 +297,9 @@ fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 {
let rank = (pct / hundred) * length;
let lrank = rank.floor();
let d = rank - lrank;
let n = lrank as usize;
let lo = sorted_samples[n];
let hi = sorted_samples[n+1];
let n = lrank;
let lo = sorted_samples[n as usize];
let hi = sorted_samples[n as usize + 1];
lo + (hi - lo) * d
}

@@ -18,13 +18,13 @@ static global0: isize = 4;
pub static global2: &'static isize = &global0;

pub fn verify_same(a: &'static isize) {
let a = a as *const isize as usize;
let b = &global as *const isize as usize;
let a = a as *const isize;
let b = &global as *const isize;
assert_eq!(a, b);
}

pub fn verify_same2(a: &'static isize) {
let a = a as *const isize as usize;
let b = global2 as *const isize as usize;
let a = a as *const isize;
let b = global2 as *const isize;
assert_eq!(a, b);
}
@@ -59,9 +59,9 @@ impl Noise2DContext {
}

fn get_gradient(&self, x: i32, y: i32) -> Vec2 {
let idx = self.permutations[(x & 255) as usize] +
self.permutations[(y & 255) as usize];
self.rgradients[(idx & 255) as usize]
let idx = self.permutations[(x & 255)] +
self.permutations[(y & 255)];
self.rgradients[(idx & 255)]
}

fn get_gradients(&self, x: f32, y: f32) -> ([Vec2; 4], [Vec2; 4]) {
@@ -115,7 +115,7 @@ fn main() {

for y in 0..256 {
for x in 0..256 {
let idx = (pixels[y*256+x] / 0.2) as usize;
let idx = (pixels[y*256+x] / 0.2);
print!("{}", symbols[idx]);
}
print!("\n");
@@ -80,7 +80,7 @@ struct Perm {
impl Perm {
fn new(n: u32) -> Perm {
let mut fact = [1; 16];
for i in 1..n as usize + 1 {
for i in 1..n + 1 {
fact[i] = fact[i - 1] * i as u32;
}
Perm {
@@ -99,15 +99,15 @@ impl Perm {
*place = i as i32 + 1;
}

for i in (1..self.n as usize).rev() {
for i in (1..self.n).rev() {
let d = idx / self.fact[i] as i32;
self.cnt[i] = d;
idx %= self.fact[i] as i32;
for (place, val) in pp.iter_mut().zip(self.perm.p[..i+1].iter()) {
*place = (*val) as u8
}

let d = d as usize;
let d = d;
for j in 0..i + 1 {
self.perm.p[j] = if j + d <= i {pp[j + d]} else {pp[j+d-i-1]} as i32;
}
@@ -117,7 +117,7 @@ impl Perm {
}

fn count(&self) -> u32 { self.permcount }
fn max(&self) -> u32 { self.fact[self.n as usize] }
fn max(&self) -> u32 { self.fact[self.n] }

fn next(&mut self) -> P {
next_permutation(&mut self.perm.p, &mut self.cnt);
@@ -142,7 +142,7 @@ fn work(mut perm: Perm, n: usize, max: usize) -> (i32, i32) {
let mut flips = 0;

while p.p[0] != 1 {
let k = p.p[0] as usize;
let k = p.p[0];
reverse(&mut p.p, k);
flips += 1;
}
@@ -167,7 +167,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
let max = cmp::min(j+k, perm.max());

futures.push(thread::spawn(move|| {
work(perm, j as usize, max as usize)
work(perm, j, max)
}))
}

@@ -169,20 +169,20 @@ impl Table {
let index = key.hash() % (TABLE_SIZE as u64);

{
if self.items[index as usize].is_none() {
if self.items[index].is_none() {
let mut entry: Box<_> = box Entry {
code: key,
count: 0,
next: None,
};
c.f(&mut *entry);
self.items[index as usize] = Some(entry);
self.items[index] = Some(entry);
return;
}
}

{
let entry = self.items[index as usize].as_mut().unwrap();
let entry = self.items[index].as_mut().unwrap();
if entry.code == key {
c.f(&mut **entry);
return;
@@ -237,7 +237,7 @@ fn pack_symbol(c: u8) -> u8 {
}

fn unpack_symbol(c: u8) -> u8 {
TABLE[c as usize]
TABLE[c]
}

fn generate_frequencies(mut input: &[u8], frame: usize) -> Table {
@@ -142,7 +142,7 @@ fn mask(dy: i32, dx: i32, id: usize, p: &Vec<(i32, i32)>) -> Option<u64> {
if x < 0 || x > 4 {return None;}
let y = y + dy;
if y < 0 || y > 9 {return None;}
m |= 1 << (y * 5 + x) as usize;
m |= 1 << (y * 5 + x);
}
Some(m)
}
@@ -214,7 +214,7 @@ fn filter_masks(masks: &mut Vec<Vec<Vec<u64>>>) {
// Gets the identifier of a mask.
fn get_id(m: u64) -> u8 {
for id in 0..10 {
if m & (1 << (id + 50) as usize) != 0 {return id;}
if m & (1 << (id + 50)) != 0 {return id;}
}
panic!("{:016x} does not have a valid identifier", m);
}
@@ -92,12 +92,12 @@ impl Tables {

/// Retrieves the complement for `i`.
fn cpl8(&self, i: u8) -> u8 {
self.table8[i as usize]
self.table8[i]
}

/// Retrieves the complement for `i`.
fn cpl16(&self, i: u16) -> u16 {
self.table16[i as usize]
self.table16[i]
}
}

@@ -110,7 +110,7 @@ fn memchr(h: &[u8], n: u8) -> Option<usize> {
if res.is_null() {
None
} else {
Some(res as usize - h.as_ptr() as usize)
Some(res - h.as_ptr())
}
}

@@ -44,7 +44,7 @@ use std::thread;
fn start(n_tasks: i32, token: i32) {
let (tx, mut rx) = channel();
tx.send(token).unwrap();
let mut guards = Vec::with_capacity(n_tasks as usize);
let mut guards = Vec::with_capacity(n_tasks);
for i in 2 .. n_tasks + 1 {
let (tx, next_rx) = channel();
let cur_rx = std::mem::replace(&mut rx, next_rx);
@@ -71,7 +71,7 @@ impl Sudoku {
if comps.len() == 3 {
let row = comps[0].parse::<u8>().unwrap();
let col = comps[1].parse::<u8>().unwrap();
g[row as usize][col as usize] = comps[2].parse().unwrap();
g[row][col] = comps[2].parse().unwrap();
}
else {
panic!("Invalid sudoku file");
@@ -82,9 +82,9 @@ impl Sudoku {

pub fn write(&self, writer: &mut Write) {
for row in 0u8..9u8 {
write!(writer, "{}", self.grid[row as usize][0]);
write!(writer, "{}", self.grid[row][0]);
for col in 1u8..9u8 {
write!(writer, " {}", self.grid[row as usize][col as usize]);
write!(writer, " {}", self.grid[row][col]);
}
write!(writer, "\n");
}
@@ -95,7 +95,7 @@ impl Sudoku {
let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */
for row in 0..9 {
for col in 0..9 {
let color = self.grid[row as usize][col as usize];
let color = self.grid[row][col];
if color == 0 {
work.push((row, col));
}
@@ -107,7 +107,7 @@ impl Sudoku {
while ptr < end {
let (row, col) = work[ptr];
// is there another color to try?
let the_color = self.grid[row as usize][col as usize] +
let the_color = self.grid[row][col] +
(1 as u8);
if self.next_color(row, col, the_color) {
// yes: advance work list
@@ -130,28 +130,28 @@ impl Sudoku {

// find first remaining color that is available
let next = avail.next();
self.grid[row as usize][col as usize] = next;
self.grid[row][col] = next;
return 0 != next;
}
self.grid[row as usize][col as usize] = 0;
self.grid[row][col] = 0;
return false;
}

// find colors available in neighbourhood of (row, col)
fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
for idx in 0..9 {
/* check same column fields */
avail.remove(self.grid[idx as usize][col as usize]);
avail.remove(self.grid[idx][col]);
/* check same row fields */
avail.remove(self.grid[row as usize][idx as usize]);
avail.remove(self.grid[row][idx]);
}

// check same block fields
let row0 = (row / 3) * 3;
let col0 = (col / 3) * 3;
for alt_row in row0..row0 + 3 {
for alt_col in col0..col0 + 3 {
avail.remove(self.grid[alt_row as usize][alt_col as usize]);
avail.remove(self.grid[alt_row][alt_col]);
}
}
}
@@ -165,7 +165,7 @@ static HEADS: u16 = (1 << 10) - 1; /* bits 9..0 */
impl Colors {
fn new(start_color: u8) -> Colors {
// Sets bits 9..start_color
let tails = !0 << start_color as usize;
let tails = !0 << start_color;
return Colors(HEADS & tails);
}

@@ -182,7 +182,7 @@ impl Colors {
fn remove(&mut self, color: u8) {
if color != 0 {
let Colors(val) = *self;
let mask = !(1 << color as usize);
let mask = !(1 << color);
*self = Colors(val & mask);
}
}
@@ -40,7 +40,7 @@ fn main()

let _ = v as f32; //~ ERROR through a usize first
let _ = main as f64; //~ ERROR through a usize first
let _ = &v as usize; //~ ERROR through a raw pointer first
let _ = &v; //~ ERROR through a raw pointer first
let _ = f as *const u8; //~ ERROR through a usize first
let _ = 3 as bool; //~ ERROR compare with zero
let _ = E::A as bool; //~ ERROR compare with zero
@@ -63,7 +63,7 @@ fn main()
let _ = main as *mut str; //~ ERROR illegal cast
let _ = &f as *mut f32; //~ ERROR illegal cast
let _ = &f as *const f64; //~ ERROR illegal cast
let _ = fat_v as usize; //~ ERROR through a raw pointer first
let _ = fat_v; //~ ERROR through a raw pointer first

let a : *const str = "hello";
let _ = a as *const Foo;
@@ -26,8 +26,8 @@ use std::{i8, i16, i32, i64, isize};
use std::{u8, u16, u32, u64, usize};

const A_I8_I
: [u32; (i8::MAX as usize) + 1]
= [0; (i8::MAX + 1) as usize];
: [u32; (i8::MAX) + 1]
= [0; (i8::MAX + 1)];

fn main() {
foo(&A_I8_I[..]);
@@ -30,8 +30,8 @@ use std::{i8, i16, i32, i64, isize};
use std::{u8, u16, u32, u64, usize};

const A_I8_I
: [u32; (i8::MAX as usize) + 1]
= [0; (i8::MAX + 1u8) as usize];
: [u32; (i8::MAX) + 1]
= [0; (i8::MAX + 1u8)];

fn main() {
foo(&A_I8_I[..]);
@@ -22,9 +22,9 @@ use std::{i8, i16, i32, i64, isize};
use std::{u8, u16, u32, u64, usize};

const A_I8_T
: [u32; (i8::MAX as i8 + 1i8) as usize]
: [u32; (i8::MAX as i8 + 1i8)]
//~^ ERROR error evaluating count: attempted to add with overflow
= [0; (i8::MAX as usize) + 1];
= [0; (i8::MAX) + 1];

fn main() {
foo(&A_I8_T[..]);
@@ -20,11 +20,11 @@ use std::{i8, i16, i32, i64, isize};
use std::{u8, u16, u32, u64, usize};

const A_I8_T
: [u32; (i8::MAX as i8 + 1u8) as usize]
: [u32; (i8::MAX as i8 + 1u8)]
//~^ ERROR mismatched types
//~| the trait `core::ops::Add<u8>` is not implemented for the type `i8`
//~| the trait `core::ops::Add<u8>` is not implemented for the type `i8`
= [0; (i8::MAX as usize) + 1];
= [0; (i8::MAX) + 1];

fn main() {
foo(&A_I8_T[..]);
@@ -17,9 +17,9 @@ fn main() {
let p = a as *const [i32];
let q = a.as_ptr();

a as usize; //~ ERROR illegal cast
b as usize; //~ ERROR non-scalar cast
p as usize; //~ ERROR illegal cast; cast through a raw pointer
a; //~ ERROR illegal cast
b; //~ ERROR non-scalar cast
p; //~ ERROR illegal cast; cast through a raw pointer

// #22955
q as *const [i32]; //~ ERROR illegal cast
@@ -17,5 +17,5 @@

fn main() {
let _fat : [u8; (1<<61)+(1<<31)] =
[0; (1u64<<61) as usize +(1u64<<31) as usize];
[0; (1u64<<61) +(1u64<<31)];
}
@@ -10,5 +10,5 @@

fn main() {
let nil = ();
let _t = nil as usize; //~ ERROR: non-scalar cast: `()` as `usize`
let _t = nil; //~ ERROR: non-scalar cast: `()` as `usize`
}
@@ -20,7 +20,7 @@ fn main() {
//~| expected i16
//~| found isize

bar(1*(1 as usize));
bar(1*(1));
//~^ ERROR mismatched types
//~| expected `u32`
//~| found `usize`
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

static X: usize = 0 as *const usize as usize;
static X: usize = 0 as *const usize;
//~^ ERROR: raw pointers cannot be cast to integers in statics

fn main() {
@@ -10,6 +10,6 @@

fn main() {
const X: u32 = 1;
const Y: usize = &X as *const u32 as usize; //~ ERROR E0018
const Y: usize = &X as *const u32; //~ ERROR E0018
println!("{}", Y);
}
@@ -14,6 +14,6 @@
enum State { ST_NULL, ST_WHITESPACE }

fn main() {
[State::ST_NULL; (State::ST_WHITESPACE as usize)];
[State::ST_NULL; (State::ST_WHITESPACE)];
//~^ ERROR expected constant integer for repeat count, but non-constant path
}
@@ -502,7 +502,7 @@ fn main() {
zzz(); // #break
sentinel();

val as usize
val
}];

zzz(); // #break
@@ -37,7 +37,7 @@ fn test6() -> bool { { } (true || false) && true }
fn test7() -> usize {
let regs = &0;
match true { true => { } _ => { } }
(*regs < 2) as usize
(*regs < 2)
}

fn test8() -> isize {
@@ -20,18 +20,18 @@

// #4264 fixed-length vector types

pub fn foo(_: [i32; (3 as usize)]) { }
pub fn foo(_: [i32; (3)]) { }

pub fn bar() {
const FOO: usize = ((5 as usize) - (4 as usize) as usize);
let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
const FOO: usize = ((5) - (4));
let _: [(); (FOO)] = ([(() as ())] as [(); 1]);
let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
let _: [(); (1)] = ([(() as ())] as [(); 1]);
let _ =
(((&((([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3])
as &[i32; 3]) as *const _ as *const [i32; 3]) as
*const [i32; (3 as usize)] as *const [i32; 3]);
*const [i32; (3)] as *const [i32; 3]);
@@ -79,16 +79,16 @@
core::fmt::Arguments<'_>))
as collections::string::String);
}
pub type Foo = [i32; (3 as usize)];
pub type Foo = [i32; (3)];
pub struct Bar {
pub x: [i32; (3 as usize)],
pub x: [i32; (3)],
}
pub struct TupleBar([i32; (4 as usize)]);
pub enum Baz { BazVariant([i32; (5 as usize)]), }
pub struct TupleBar([i32; (4)]);
pub enum Baz { BazVariant([i32; (5)]), }
pub fn id<T>(x: T) -> T { (x as T) }
pub fn use_id() {
let _ =
((id::<[i32; (3 as usize)]> as
((id::<[i32; (3)]> as
fn([i32; 3]) -> [i32; 3] {id})(([(1 as i32), (2 as i32),
(3 as i32)] as [i32; 3])) as
[i32; 3]);
@@ -25,8 +25,8 @@ fn main() {

let idx = u64::MAX & !(u64::MAX >> 1_usize);
println!("ov3 idx = 0x%8.8x%8.8x",
(idx >> 32) as usize,
idx as usize);
(idx >> 32),
idx);

// This should panic.
println!("ov3 0x%x", x[idx]);
@@ -22,7 +22,7 @@ fn main() {

let x = vec!(1_usize,2_usize,3_usize);

let base = x.as_ptr() as usize;
let base = x.as_ptr();
let idx = base / mem::size_of::<usize>();
println!("ov1 base = 0x{:x}", base);
println!("ov1 idx = 0x{:x}", idx);
@@ -13,7 +13,7 @@ extern crate b;
extern crate c;
#[cfg(after)] extern crate a;

fn t(a: &'static usize) -> usize { a as *const _ as usize }
fn t(a: &'static usize) -> usize { a as *const _ }

fn main() {
assert!(t(a::token()) == t(b::a_token()));
@@ -22,7 +22,7 @@ fn main() {
let data = [1,2,3,4,5];

unsafe {
assert_eq!(data.len(), slice_len(&data) as usize);
assert_eq!(data.len(), slice_len(&data));
assert_eq!(data[0], slice_elem(&data, 0));
assert_eq!(data[1], slice_elem(&data, 1));
assert_eq!(data[2], slice_elem(&data, 2));
@@ -22,7 +22,7 @@ pub fn main() {
assert_eq!(i32_a * i32_a * i32_a, 1000);
assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000);
assert_eq!(i32_a * i32_a / i32_a * i32_a, 100);
assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as usize), 368640);
assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a), 368640);
let i32_b: isize = 0x10101010;
assert_eq!(i32_b + 1 - 1, i32_b);
assert_eq!(i32_b << 1, i32_b << 1);
@@ -10,9 +10,9 @@


fn main() {
assert_eq!(3 as usize * 3, 9);
assert_eq!(3 * 3, 9);
assert_eq!(3 as (usize) * 3, 9);
assert_eq!(3 as (usize) / 3, 1);
assert_eq!(3 as usize + 3, 6);
assert_eq!(3 + 3, 6);
assert_eq!(3 as (usize) + 3, 6);
}
@@ -43,7 +43,7 @@ fn length<A, T: iterable<A>>(x: T) -> usize {
pub fn main() {
let x: Vec<isize> = vec!(0,1,2,3);
// Call a method
x.iterate(|y| { assert!(x[*y as usize] == *y); true });
x.iterate(|y| { assert!(x[y.as_unsigned()] == *y); true });
// Call a parameterized function
assert_eq!(length(x.clone()), x.len());
// Call a parameterized function, with type arguments that require
@@ -18,7 +18,7 @@ impl SignedUnsigned for isize {
type Opposite = usize;

fn convert(self) -> usize {
self as usize
self.as_unsigned()
}
}

@@ -12,12 +12,12 @@

#[cfg(any(target_arch = "x86", target_arch = "arm"))]
fn target() {
assert_eq!(-1000 as usize >> 3_usize, 536870787_usize);
assert_eq!(-1000 >> 3_usize, 536870787_usize);
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
fn target() {
assert_eq!(-1000 as usize >> 3_usize, 2305843009213693827_usize);
assert_eq!(-1000 >> 3_usize, 2305843009213693827_usize);
}

fn general() {
@@ -19,7 +19,7 @@ fn borrow<F>(x: &isize, f: F) where F: FnOnce(&isize) {
fn test1(x: &Box<isize>) {
borrow(&*(*x).clone(), |p| {
let x_a = &**x as *const isize;
assert!((x_a as usize) != (p as *const isize as usize));
assert!((x_a) != (p as *const isize));
assert_eq!(unsafe{*x_a}, *p);
})
}
@@ -24,7 +24,7 @@ impl Drop for D {
fn drop(&mut self) {
println!("Dropping {}", self.0);
let old = LOG.load(Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0.widen_(0usize), Ordering::SeqCst);
}
}

@@ -24,7 +24,7 @@ impl Drop for D {
fn drop(&mut self) {
println!("Dropping {}", self.0);
let old = LOG.load(Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0.widen_(0usize), Ordering::SeqCst);
}
}

@@ -15,7 +15,7 @@
const SIZE: isize = 25;

fn main() {
let _a: [bool; 1 as usize];
let _a: [bool; 1];
let _b: [isize; SIZE as usize] = [1; SIZE as usize];
let _c: [bool; '\n' as usize] = [true; '\n' as usize];
let _d: [bool; true as usize] = [true; true as usize];
@@ -77,7 +77,7 @@ fn main()

// addr-ptr-cast/ptr-addr-cast (thin ptr)
let p: *const [u8; 1] = lsz as *const [u8; 1];
assert_eq!(p as usize, lsz);
assert_eq!(p, lsz);

// ptr-ptr-cast (thin ptr)
let w: *const () = p as *const ();
@@ -16,7 +16,7 @@ enum cat_type { tuxedo, tabby, tortoiseshell }

impl cmp::PartialEq for cat_type {
fn eq(&self, other: &cat_type) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &cat_type) -> bool { !(*self).eq(other) }
}
@@ -46,7 +46,7 @@ impl<T> cat<T> {
return false;
}
}
fn len(&self) -> usize { self.meows as usize }
fn len(&self) -> usize { self.meows.as_unsigned() }
fn is_empty(&self) -> bool { self.meows == 0 }
fn clear(&mut self) {}
fn contains_key(&self, k: &isize) -> bool { *k <= self.meows }
@@ -59,6 +59,6 @@ pub fn main() {
assert_eq!(BLOCK_FN(300), 300);
assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
// FIXME #13972
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef);
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef);
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize, 0xdeadbeef);
// assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize, 0xdeadbeef);
}
@@ -13,7 +13,7 @@ enum chan { chan_t, }

impl PartialEq for chan {
fn eq(&self, other: &chan) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &chan) -> bool { !(*self).eq(other) }
}
@@ -27,7 +27,7 @@ enum mood { happy, sad, }

impl PartialEq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
}
@@ -26,7 +26,7 @@ enum mood { happy, sad, }

impl PartialEq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
}
@@ -37,13 +37,13 @@ fn main() {
// And conversion to a void pointer/address for trait objects too.
let a: *mut Foo = &mut Bar;
let b = a as *mut ();
let c = a as *const () as usize;
let c = a as *const ();
let d = unsafe {
let r: raw::TraitObject = mem::transmute(a);
r.data
};

assert!(b == d);
assert!(c == d as usize);
assert!(c == d);

}
@@ -14,9 +14,9 @@ fn two<F>(mut it: F) where F: FnMut(isize) { it(0); it(1); }

pub fn main() {
let mut a: Vec<isize> = vec!(-1, -1, -1, -1);
let mut p: isize = 0;
let mut p: usize = 0;
two(|i| {
two(|j| { a[p as usize] = 10 * i + j; p += 1; })
two(|j| { a[p] = 10 * i + j; p += 1; })
});
assert_eq!(a[0], 0);
assert_eq!(a[1], 1);
@@ -38,6 +38,6 @@ fn f(result: &mut usize) -> Point {
fn main() {
let mut intrinsic_reported_address = 0;
let pt = f(&mut intrinsic_reported_address);
let actual_address = &pt as *const Point as usize;
let actual_address = &pt as *const Point;
assert_eq!(intrinsic_reported_address, actual_address);
}
@@ -15,11 +15,11 @@
pub fn main() {
let one = || {
enum r { a };
r::a as usize
r::a
};
let two = || {
enum r { a };
r::a as usize
r::a
};
one(); two();
}
@@ -82,6 +82,6 @@ fn event_log() -> usize {

fn event(tag: u8) {
let old_log = LOG.load(Ordering::SeqCst);
let new_log = (old_log << 8) + tag as usize;
let new_log = (old_log << 8) + tag.widen_(0usize);
LOG.store(new_log, Ordering::SeqCst);
}
@@ -25,12 +25,12 @@ impl Drop for Kitty {

#[cfg(any(target_arch = "x86_64", target_arch="aarch64"))]
pub fn main() {
assert_eq!(mem::size_of::<Cat>(), 8 as usize);
assert_eq!(mem::size_of::<Kitty>(), 16 as usize);
assert_eq!(mem::size_of::<Cat>(), 8);
assert_eq!(mem::size_of::<Kitty>(), 16);
}

#[cfg(any(target_arch = "x86", target_arch = "arm"))]
pub fn main() {
assert_eq!(mem::size_of::<Cat>(), 4 as usize);
assert_eq!(mem::size_of::<Kitty>(), 8 as usize);
assert_eq!(mem::size_of::<Cat>(), 4);
assert_eq!(mem::size_of::<Kitty>(), 8);
}
@@ -86,16 +86,16 @@ impl AsciiArt {
if x >= 0 && x < self.width as isize {
if y >= 0 && y < self.height as isize {
// Note that numeric types don't implicitly convert to each other.
let v = y as usize;
let h = x as usize;
let v = y;
let h = x;

// Vector subscripting will normally copy the element, but &v[i]
// will return a reference which is what we need because the
// element is:
// 1) potentially large
// 2) needs to be modified
let row = &mut self.lines[v];
row[h] = self.fill;
let row = &mut self.lines[v.as_unsigned()];
row[h.as_unsigned()] = self.fill;
}
}
}
@@ -31,7 +31,7 @@ enum Result {
fn parse_data(len: usize, io: @io::Reader) -> Result {
let res =
if (len > 0) {
let bytes = io.read_bytes(len as usize);
let bytes = io.read_bytes(len);
assert_eq!(bytes.len(), len);
Data(bytes)
} else {
@@ -63,7 +63,7 @@ fn parse_bulk(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(-1) => Nil,
Some(len) if len >= 0 => parse_data(len as usize, io),
Some(len) if len >= 0 => parse_data(len, io),
Some(_) => panic!()
}
}
@@ -73,7 +73,7 @@ fn parse_multi(io: @io::Reader) -> Result {
None => panic!(),
Some(-1) => Nil,
Some(0) => List(vec![]),
Some(len) if len >= 0 => parse_list(len as usize, io),
Some(len) if len >= 0 => parse_list(len, io),
Some(_) => panic!()
}
}
@@ -11,5 +11,5 @@
// pretty-expanded FIXME #23616

pub fn main() {
const S: usize = 23 as usize; [0; S]; ()
const S: usize = 23; [0; S]; ()
}
@@ -19,5 +19,5 @@ pub fn main() {
grow(&mut v);
let len = v.len();
println!("{}", len);
assert_eq!(len, 3 as usize);
assert_eq!(len, 3);
}
@@ -25,7 +25,7 @@ impl Drop for D {
fn drop(&mut self) {
println!("Dropping {}", self.0);
let old = LOG.load(Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst);
LOG.compare_and_swap(old, old << 4 | self.0.widen_(0usize), Ordering::SeqCst);
}
}

@@ -32,7 +32,7 @@ fn start(argc: isize, argv: *const *const u8) -> isize {
}

let args = unsafe {
(0..argc as usize).map(|i| {
(0..argc).map(|i| {
let ptr = *argv.offset(i as isize) as *const _;
CStr::from_ptr(ptr).to_bytes().to_vec()
}).collect::<Vec<_>>()
@@ -15,6 +15,7 @@
// compile-flags: -C lto
// no-prefer-dynamic
// ignore-android FIXME #18800
// ignore-windows

extern crate sepcomp_lib;
use sepcomp_lib::a::one;
@@ -23,42 +23,42 @@ fn test_misc() {
}

fn test_expr() {
let v10 = 10 as usize;
let v10 = 10;
let v4 = 4 as u8;
let v2 = 2 as u8;
assert_eq!(v10 >> v2 as usize, v2 as usize);
assert_eq!(v10 << v4 as usize, 160 as usize);
assert_eq!(v10 >> v2, v2);
assert_eq!(v10 << v4, 160);

let v10 = 10 as u8;
let v4 = 4 as usize;
let v2 = 2 as usize;
assert_eq!(v10 >> v2 as usize, v2 as u8);
assert_eq!(v10 << v4 as usize, 160 as u8);
let v4 = 4;
let v2 = 2;
assert_eq!(v10 >> v2, v2 as u8);
assert_eq!(v10 << v4, 160 as u8);

let v10 = 10 as isize;
let v4 = 4 as i8;
let v2 = 2 as i8;
assert_eq!(v10 >> v2 as usize, v2 as isize);
assert_eq!(v10 << v4 as usize, 160 as isize);
assert_eq!(v10 >> v2, v2 as isize);
assert_eq!(v10 << v4, 160 as isize);

let v10 = 10 as i8;
let v4 = 4 as isize;
let v2 = 2 as isize;
assert_eq!(v10 >> v2 as usize, v2 as i8);
assert_eq!(v10 << v4 as usize, 160 as i8);
assert_eq!(v10 >> v2, v2 as i8);
assert_eq!(v10 << v4, 160 as i8);

let v10 = 10 as usize;
let v10 = 10;
let v4 = 4 as isize;
let v2 = 2 as isize;
assert_eq!(v10 >> v2 as usize, v2 as usize);
assert_eq!(v10 << v4 as usize, 160 as usize);
assert_eq!(v10 >> v2, v2);
assert_eq!(v10 << v4, 160);
}

fn test_const() {
static r1_1: usize = 10_usize >> 2_usize;
static r2_1: usize = 10_usize << 4_usize;
assert_eq!(r1_1, 2 as usize);
assert_eq!(r2_1, 160 as usize);
assert_eq!(r1_1, 2);
assert_eq!(r2_1, 160);

static r1_2: u8 = 10u8 >> 2_usize;
static r2_2: u8 = 10u8 << 4_usize;
@@ -77,6 +77,6 @@ fn test_const() {

static r1_5: usize = 10_usize >> 2_usize;
static r2_5: usize = 10_usize << 4_usize;
assert_eq!(r1_5, 2 as usize);
assert_eq!(r2_5, 160 as usize);
assert_eq!(r1_5, 2);
assert_eq!(r2_5, 160);
}
@@ -65,7 +65,7 @@ pub fn main() {
assert_eq!((vec!(1)).length_().str(), "1".to_string());
let vect = vec!(3, 4).map_(|a| *a + 4);
assert_eq!(vect[0], 7);
let vect = (vec!(3, 4)).map_::<usize, _>(|a| *a as usize + 4_usize);
let vect = (vec!(3, 4)).map_::<usize, _>(|a| *a + 4_usize);
assert_eq!(vect[0], 7_usize);
let mut x = 0_usize;
10_usize.multi(|_n| x += 2_usize );
@@ -43,6 +43,6 @@ fn event_log() -> usize {

fn event(tag: u8) {
let old_log = LOG.load(Ordering::SeqCst);
let new_log = (old_log << 8) + tag as usize;
let new_log = (old_log << 8) + tag.widen_(0usize);
LOG.store(new_log, Ordering::SeqCst);
}
@@ -40,6 +40,6 @@ fn event_log() -> usize {

fn event(tag: u8) {
let old_log = LOG.load(Ordering::SeqCst);
let new_log = (old_log << 8) + tag as usize;
let new_log = (old_log << 8) + tag.widen_(0usize);
LOG.store(new_log, Ordering::SeqCst);
}
@@ -32,10 +32,10 @@ fn test1() {
c: 0xcccc_cccc_cccc_cccc,
d: 0xdddd_dddd_dddd_dddd };
let qq = rustrt::rust_dbg_abi_1(q);
println!("a: {:x}", qq.a as usize);
println!("b: {:x}", qq.b as usize);
println!("c: {:x}", qq.c as usize);
println!("d: {:x}", qq.d as usize);
println!("a: {:x}", qq.a);
println!("b: {:x}", qq.b);
println!("c: {:x}", qq.c);
println!("d: {:x}", qq.d);
assert_eq!(qq.a, q.c + 1);
assert_eq!(qq.b, q.d - 1);
assert_eq!(qq.c, q.a + 1);
@@ -51,7 +51,7 @@ fn test2() {
c: 1.0987654321e-15_f64 };
let ff = rustrt::rust_dbg_abi_2(f);
println!("a: {}", ff.a as f64);
println!("b: {}", ff.b as usize);
println!("b: {}", ff.b);
println!("c: {}", ff.c as f64);
assert_eq!(ff.a, f.c + 1.0f64);
assert_eq!(ff.b, 0xff);
@@ -15,7 +15,7 @@ enum foo { large, small, }

impl PartialEq for foo {
fn eq(&self, other: &foo) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
}
@@ -15,7 +15,7 @@ extern crate libc;
pub fn main() {
let f = 1_usize as *const libc::FILE;
println!("{:?}", f as isize);
println!("{:?}", f as usize);
println!("{:?}", f);
println!("{:?}", f as i8);
println!("{:?}", f as i16);
println!("{:?}", f as i32);
@@ -26,7 +26,7 @@ pub fn main() {
println!("{:?}", f as u64);

println!("{:?}", 1 as isize);
println!("{:?}", 1 as usize);
println!("{:?}", 1);
println!("{:?}", 1 as *const libc::FILE);
println!("{:?}", 1 as i8);
println!("{:?}", 1 as i16);
@@ -40,7 +40,7 @@ pub fn main() {
println!("{:?}", 1 as f64);

println!("{:?}", 1_usize as isize);
println!("{:?}", 1_usize as usize);
println!("{:?}", 1_usize);
println!("{:?}", 1_usize as *const libc::FILE);
println!("{:?}", 1_usize as i8);
println!("{:?}", 1_usize as i16);
@@ -54,7 +54,7 @@ pub fn main() {
println!("{:?}", 1_usize as f64);

println!("{:?}", 1i8 as isize);
println!("{:?}", 1i8 as usize);
println!("{:?}", 1i8);
println!("{:?}", 1i8 as *const libc::FILE);
println!("{:?}", 1i8 as i8);
println!("{:?}", 1i8 as i16);
@@ -68,7 +68,7 @@ pub fn main() {
println!("{:?}", 1i8 as f64);

println!("{:?}", 1u8 as isize);
println!("{:?}", 1u8 as usize);
println!("{:?}", 1u8);
println!("{:?}", 1u8 as *const libc::FILE);
println!("{:?}", 1u8 as i8);
println!("{:?}", 1u8 as i16);
@@ -82,7 +82,7 @@ pub fn main() {
println!("{:?}", 1u8 as f64);

println!("{:?}", 1i16 as isize);
println!("{:?}", 1i16 as usize);
println!("{:?}", 1i16);
println!("{:?}", 1i16 as *const libc::FILE);
println!("{:?}", 1i16 as i8);
println!("{:?}", 1i16 as i16);
@@ -96,7 +96,7 @@ pub fn main() {
println!("{:?}", 1i16 as f64);

println!("{:?}", 1u16 as isize);
println!("{:?}", 1u16 as usize);
println!("{:?}", 1u16);
println!("{:?}", 1u16 as *const libc::FILE);
println!("{:?}", 1u16 as i8);
println!("{:?}", 1u16 as i16);
@@ -110,7 +110,7 @@ pub fn main() {
println!("{:?}", 1u16 as f64);

println!("{:?}", 1i32 as isize);
println!("{:?}", 1i32 as usize);
println!("{:?}", 1i32);
println!("{:?}", 1i32 as *const libc::FILE);
println!("{:?}", 1i32 as i8);
println!("{:?}", 1i32 as i16);
@@ -124,7 +124,7 @@ pub fn main() {
println!("{:?}", 1i32 as f64);

println!("{:?}", 1u32 as isize);
println!("{:?}", 1u32 as usize);
println!("{:?}", 1u32);
println!("{:?}", 1u32 as *const libc::FILE);
println!("{:?}", 1u32 as i8);
println!("{:?}", 1u32 as i16);
@@ -138,7 +138,7 @@ pub fn main() {
println!("{:?}", 1u32 as f64);

println!("{:?}", 1i64 as isize);
println!("{:?}", 1i64 as usize);
println!("{:?}", 1i64);
println!("{:?}", 1i64 as *const libc::FILE);
println!("{:?}", 1i64 as i8);
println!("{:?}", 1i64 as i16);
@@ -152,7 +152,7 @@ pub fn main() {
println!("{:?}", 1i64 as f64);

println!("{:?}", 1u64 as isize);
println!("{:?}", 1u64 as usize);
println!("{:?}", 1u64);
println!("{:?}", 1u64 as *const libc::FILE);
println!("{:?}", 1u64 as i8);
println!("{:?}", 1u64 as i16);
@@ -166,7 +166,7 @@ pub fn main() {
println!("{:?}", 1u64 as f64);

println!("{:?}", 1u64 as isize);
println!("{:?}", 1u64 as usize);
println!("{:?}", 1u64);
println!("{:?}", 1u64 as *const libc::FILE);
println!("{:?}", 1u64 as i8);
println!("{:?}", 1u64 as i16);
@@ -180,7 +180,7 @@ pub fn main() {
println!("{:?}", 1u64 as f64);

println!("{:?}", true as isize);
println!("{:?}", true as usize);
println!("{:?}", true);
println!("{:?}", true as i8);
println!("{:?}", true as i16);
println!("{:?}", true as i32);
@@ -191,7 +191,7 @@ pub fn main() {
println!("{:?}", true as u64);

println!("{:?}", 1f32 as isize);
println!("{:?}", 1f32 as usize);
println!("{:?}", 1f32);
println!("{:?}", 1f32 as i8);
println!("{:?}", 1f32 as i16);
println!("{:?}", 1f32 as i32);
@@ -204,7 +204,7 @@ pub fn main() {
println!("{:?}", 1f32 as f64);

println!("{:?}", 1f64 as isize);
println!("{:?}", 1f64 as usize);
println!("{:?}", 1f64);
println!("{:?}", 1f64 as i8);
println!("{:?}", 1f64 as i16);
println!("{:?}", 1f64 as i32);
@@ -24,7 +24,7 @@ enum color {

impl PartialEq for color {
fn eq(&self, other: &color) -> bool {
((*self) as usize) == ((*other) as usize)
((*self)) == ((*other))
}
fn ne(&self, other: &color) -> bool { !(*self).eq(other) }
}
@@ -31,17 +31,17 @@ enum e3 {
}

pub fn main() {
assert_eq!(size_of::<u8>(), 1 as usize);
assert_eq!(size_of::<u32>(), 4 as usize);
assert_eq!(size_of::<char>(), 4 as usize);
assert_eq!(size_of::<i8>(), 1 as usize);
assert_eq!(size_of::<i32>(), 4 as usize);
assert_eq!(size_of::<t>(), 2 as usize);
assert_eq!(size_of::<u>(), 3 as usize);
assert_eq!(size_of::<u8>(), 1);
assert_eq!(size_of::<u32>(), 4);
assert_eq!(size_of::<char>(), 4);
assert_eq!(size_of::<i8>(), 1);
assert_eq!(size_of::<i32>(), 4);
assert_eq!(size_of::<t>(), 2);
assert_eq!(size_of::<u>(), 3);
// Alignment causes padding before the char and the u32.

assert!(size_of::<v>() ==
16 as usize);
16);
assert_eq!(size_of::<isize>(), size_of::<usize>());
assert_eq!(size_of::<w>(), size_of::<isize>());
assert_eq!(size_of::<x>(), size_of::<isize>());
@@ -50,7 +50,7 @@ pub fn main() {
// Make sure enum types are the appropriate size, mostly
// around ensuring alignment is handled properly

assert_eq!(size_of::<e1>(), 8 as usize);
assert_eq!(size_of::<e2>(), 8 as usize);
assert_eq!(size_of::<e3>(), 4 as usize);
assert_eq!(size_of::<e1>(), 8);
assert_eq!(size_of::<e2>(), 8);
assert_eq!(size_of::<e3>(), 4);
}
@@ -35,5 +35,5 @@ pub fn main() {
let ptr: &usize = &5;
let ptr2 = ptr as *const _;

assert_eq!(ptr as *const usize as usize, ptr2 as usize);
assert_eq!(ptr as *const usize, ptr2);
}
@@ -13,4 +13,4 @@

// pretty-expanded FIXME #23616

pub fn main() { let _x: usize = 10 as usize; }
pub fn main() { let _x: usize = 10; }
@@ -40,11 +40,11 @@ pub fn main() {
assert_eq!(oo as isize, 0xd6);

fn check_str_eq(a: String, b: String) {
let mut i: isize = 0;
let mut i: usize = 0;
for ab in a.bytes() {
println!("{}", i);
println!("{}", ab);
let bb: u8 = b.as_bytes()[i as usize];
let bb: u8 = b.as_bytes()[i];
println!("{}", bb);
assert_eq!(ab, bb);
i += 1;
@@ -10,4 +10,4 @@

// pretty-expanded FIXME #23616

pub fn main() { let _a = [0; 1 as usize]; }
pub fn main() { let _a = [0; 1]; }