libsyntax: rename functions from uint to usize
This commit is contained in:
parent
a32249d447
commit
d5c83652b3
30 changed files with 97 additions and 97 deletions
|
@ -1329,7 +1329,7 @@ impl UnusedMut {
|
|||
let ident = path1.node;
|
||||
if let ast::BindByValue(ast::MutMutable) = mode {
|
||||
if !token::get_ident(ident).get().starts_with("_") {
|
||||
match mutables.entry(ident.name.uint()) {
|
||||
match mutables.entry(ident.name.usize()) {
|
||||
Vacant(entry) => { entry.insert(vec![id]); },
|
||||
Occupied(mut entry) => { entry.get_mut().push(id); },
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
|||
fn explain_span(cx: &ctxt, heading: &str, span: Span)
|
||||
-> (String, Option<Span>) {
|
||||
let lo = cx.sess.codemap().lookup_char_pos_adj(span.lo);
|
||||
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_uint()),
|
||||
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
|
||||
Some(span))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1962,7 +1962,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let module_name = self.module_to_string(&*search_module);
|
||||
let mut span = span;
|
||||
let msg = if "???" == &module_name[] {
|
||||
span.hi = span.lo + Pos::from_uint(segment_name.get().len());
|
||||
span.hi = span.lo + Pos::from_usize(segment_name.get().len());
|
||||
|
||||
match search_parent_externals(name,
|
||||
&self.current_module) {
|
||||
|
|
|
@ -40,8 +40,8 @@ impl<'a> SpanUtils<'a> {
|
|||
format!("file_name,{},file_line,{},file_col,{},extent_start,{},extent_start_bytes,{},\
|
||||
file_line_end,{},file_col_end,{},extent_end,{},extent_end_bytes,{}",
|
||||
lo_loc.file.name,
|
||||
lo_loc.line, lo_loc.col.to_uint(), lo_pos.to_uint(), lo_pos_byte.to_uint(),
|
||||
hi_loc.line, hi_loc.col.to_uint(), hi_pos.to_uint(), hi_pos_byte.to_uint())
|
||||
lo_loc.line, lo_loc.col.to_usize(), lo_pos.to_usize(), lo_pos_byte.to_usize(),
|
||||
hi_loc.line, hi_loc.col.to_usize(), hi_pos.to_usize(), hi_pos_byte.to_usize())
|
||||
}
|
||||
|
||||
// sub_span starts at span.lo, so we need to adjust the positions etc.
|
||||
|
|
|
@ -275,7 +275,7 @@ pub fn return_type_is_void(ccx: &CrateContext, ty: Ty) -> bool {
|
|||
/// Generates a unique symbol based off the name given. This is used to create
|
||||
/// unique symbols for things like closures.
|
||||
pub fn gensym_name(name: &str) -> PathElem {
|
||||
let num = token::gensym(name).uint();
|
||||
let num = token::gensym(name).usize();
|
||||
// use one colon which will get translated to a period by the mangler, and
|
||||
// we're guaranteed that `num` is globally unique for this crate.
|
||||
PathName(token::gensym(&format!("{}:{}", name, num)[]))
|
||||
|
@ -848,7 +848,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
|
|||
!null_terminated as Bool);
|
||||
|
||||
let gsym = token::gensym("str");
|
||||
let buf = CString::from_vec(format!("str{}", gsym.uint()).into_bytes());
|
||||
let buf = CString::from_vec(format!("str{}", gsym.usize()).into_bytes());
|
||||
let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(sc).to_ref(), buf.as_ptr());
|
||||
llvm::LLVMSetInitializer(g, sc);
|
||||
llvm::LLVMSetGlobalConstant(g, True);
|
||||
|
@ -873,7 +873,7 @@ pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef {
|
|||
let lldata = C_bytes(cx, data);
|
||||
|
||||
let gsym = token::gensym("binary");
|
||||
let name = format!("binary{}", gsym.uint());
|
||||
let name = format!("binary{}", gsym.usize());
|
||||
let name = CString::from_vec(name.into_bytes());
|
||||
let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(lldata).to_ref(),
|
||||
name.as_ptr());
|
||||
|
|
|
@ -1204,7 +1204,7 @@ pub fn set_source_location(fcx: &FunctionContext,
|
|||
|
||||
set_debug_location(cx, DebugLocation::new(scope,
|
||||
loc.line,
|
||||
loc.col.to_uint()));
|
||||
loc.col.to_usize()));
|
||||
} else {
|
||||
set_debug_location(cx, UnknownLocation);
|
||||
}
|
||||
|
@ -1719,7 +1719,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
set_debug_location(cx, DebugLocation::new(scope_metadata,
|
||||
loc.line,
|
||||
loc.col.to_uint()));
|
||||
loc.col.to_usize()));
|
||||
unsafe {
|
||||
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
|
||||
DIB(cx),
|
||||
|
@ -3282,7 +3282,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||
parent_scope,
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
loc.col.to_uint() as c_uint)
|
||||
loc.col.to_usize() as c_uint)
|
||||
};
|
||||
|
||||
scope_stack.push(ScopeStackEntry { scope_metadata: scope_metadata,
|
||||
|
@ -3404,7 +3404,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||
parent_scope,
|
||||
file_metadata,
|
||||
loc.line as c_uint,
|
||||
loc.col.to_uint() as c_uint)
|
||||
loc.col.to_usize() as c_uint)
|
||||
};
|
||||
|
||||
scope_stack.push(ScopeStackEntry {
|
||||
|
|
|
@ -785,7 +785,7 @@ pub fn make_vtable<I: Iterator<Item=ValueRef>>(ccx: &CrateContext,
|
|||
unsafe {
|
||||
let tbl = C_struct(ccx, &components[], false);
|
||||
let sym = token::gensym("vtable");
|
||||
let buf = CString::from_vec(format!("vtable{}", sym.uint()).into_bytes());
|
||||
let buf = CString::from_vec(format!("vtable{}", sym.usize()).into_bytes());
|
||||
let vt_gvar = llvm::LLVMAddGlobal(ccx.llmod(), val_ty(tbl).to_ref(),
|
||||
buf.as_ptr());
|
||||
llvm::LLVMSetInitializer(vt_gvar, tbl);
|
||||
|
|
|
@ -1870,9 +1870,9 @@ impl Clean<Span> for syntax::codemap::Span {
|
|||
Span {
|
||||
filename: filename.to_string(),
|
||||
loline: lo.line,
|
||||
locol: lo.col.to_uint(),
|
||||
locol: lo.col.to_usize(),
|
||||
hiline: hi.line,
|
||||
hicol: hi.col.to_uint(),
|
||||
hicol: hi.col.to_usize(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ impl Ident {
|
|||
|
||||
pub fn encode_with_hygiene(&self) -> String {
|
||||
format!("\x00name_{},ctxt_{}\x00",
|
||||
self.name.uint(),
|
||||
self.name.usize(),
|
||||
self.ctxt)
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ impl Name {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uint(&self) -> usize {
|
||||
pub fn usize(&self) -> usize {
|
||||
let Name(nm) = *self;
|
||||
nm as usize
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ use libc::c_uint;
|
|||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
pub trait Pos {
|
||||
fn from_uint(n: usize) -> Self;
|
||||
fn to_uint(&self) -> usize;
|
||||
fn from_usize(n: usize) -> Self;
|
||||
fn to_usize(&self) -> usize;
|
||||
}
|
||||
|
||||
/// A byte offset. Keep this small (currently 32-bits), as AST contains
|
||||
|
@ -49,15 +49,15 @@ pub struct CharPos(pub usize);
|
|||
// have been unsuccessful
|
||||
|
||||
impl Pos for BytePos {
|
||||
fn from_uint(n: usize) -> BytePos { BytePos(n as u32) }
|
||||
fn to_uint(&self) -> usize { let BytePos(n) = *self; n as usize }
|
||||
fn from_usize(n: usize) -> BytePos { BytePos(n as u32) }
|
||||
fn to_usize(&self) -> usize { let BytePos(n) = *self; n as usize }
|
||||
}
|
||||
|
||||
impl Add for BytePos {
|
||||
type Output = BytePos;
|
||||
|
||||
fn add(self, rhs: BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() + rhs.to_uint()) as u32)
|
||||
BytePos((self.to_usize() + rhs.to_usize()) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,20 +65,20 @@ impl Sub for BytePos {
|
|||
type Output = BytePos;
|
||||
|
||||
fn sub(self, rhs: BytePos) -> BytePos {
|
||||
BytePos((self.to_uint() - rhs.to_uint()) as u32)
|
||||
BytePos((self.to_usize() - rhs.to_usize()) as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl Pos for CharPos {
|
||||
fn from_uint(n: usize) -> CharPos { CharPos(n) }
|
||||
fn to_uint(&self) -> usize { let CharPos(n) = *self; n }
|
||||
fn from_usize(n: usize) -> CharPos { CharPos(n) }
|
||||
fn to_usize(&self) -> usize { let CharPos(n) = *self; n }
|
||||
}
|
||||
|
||||
impl Add for CharPos {
|
||||
type Output = CharPos;
|
||||
|
||||
fn add(self, rhs: CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() + rhs.to_uint())
|
||||
CharPos(self.to_usize() + rhs.to_usize())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl Sub for CharPos {
|
|||
type Output = CharPos;
|
||||
|
||||
fn sub(self, rhs: CharPos) -> CharPos {
|
||||
CharPos(self.to_uint() - rhs.to_uint())
|
||||
CharPos(self.to_usize() - rhs.to_usize())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ impl FileMap {
|
|||
let lines = self.lines.borrow();
|
||||
lines.get(line_number).map(|&line| {
|
||||
let begin: BytePos = line - self.start_pos;
|
||||
let begin = begin.to_uint();
|
||||
let begin = begin.to_usize();
|
||||
let slice = &self.src[begin..];
|
||||
match slice.find('\n') {
|
||||
Some(e) => &slice[..e],
|
||||
|
@ -351,7 +351,7 @@ impl CodeMap {
|
|||
let mut files = self.files.borrow_mut();
|
||||
let start_pos = match files.last() {
|
||||
None => 0,
|
||||
Some(last) => last.start_pos.to_uint() + last.src.len(),
|
||||
Some(last) => last.start_pos.to_usize() + last.src.len(),
|
||||
};
|
||||
|
||||
// Remove utf-8 BOM if any.
|
||||
|
@ -374,7 +374,7 @@ impl CodeMap {
|
|||
let filemap = Rc::new(FileMap {
|
||||
name: filename,
|
||||
src: src.to_string(),
|
||||
start_pos: Pos::from_uint(start_pos),
|
||||
start_pos: Pos::from_usize(start_pos),
|
||||
lines: RefCell::new(Vec::new()),
|
||||
multibyte_chars: RefCell::new(Vec::new()),
|
||||
});
|
||||
|
@ -389,7 +389,7 @@ impl CodeMap {
|
|||
(format!("<{}:{}:{}>",
|
||||
pos.file.name,
|
||||
pos.line,
|
||||
pos.col.to_uint() + 1)).to_string()
|
||||
pos.col.to_usize() + 1)).to_string()
|
||||
}
|
||||
|
||||
/// Lookup source information about a BytePos
|
||||
|
@ -417,9 +417,9 @@ impl CodeMap {
|
|||
return (format!("{}:{}:{}: {}:{}",
|
||||
lo.filename,
|
||||
lo.line,
|
||||
lo.col.to_uint() + 1,
|
||||
lo.col.to_usize() + 1,
|
||||
hi.line,
|
||||
hi.col.to_uint() + 1)).to_string()
|
||||
hi.col.to_usize() + 1)).to_string()
|
||||
}
|
||||
|
||||
pub fn span_to_filename(&self, sp: Span) -> FileName {
|
||||
|
@ -447,7 +447,7 @@ impl CodeMap {
|
|||
if begin.fm.start_pos != end.fm.start_pos {
|
||||
None
|
||||
} else {
|
||||
Some((&begin.fm.src[begin.pos.to_uint()..end.pos.to_uint()]).to_string())
|
||||
Some((&begin.fm.src[begin.pos.to_usize()..end.pos.to_usize()]).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,14 +484,14 @@ impl CodeMap {
|
|||
total_extra_bytes += mbc.bytes - 1;
|
||||
// We should never see a byte position in the middle of a
|
||||
// character
|
||||
assert!(bpos.to_uint() >= mbc.pos.to_uint() + mbc.bytes);
|
||||
assert!(bpos.to_usize() >= mbc.pos.to_usize() + mbc.bytes);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert!(map.start_pos.to_uint() + total_extra_bytes <= bpos.to_uint());
|
||||
CharPos(bpos.to_uint() - map.start_pos.to_uint() - total_extra_bytes)
|
||||
assert!(map.start_pos.to_usize() + total_extra_bytes <= bpos.to_usize());
|
||||
CharPos(bpos.to_usize() - map.start_pos.to_usize() - total_extra_bytes)
|
||||
}
|
||||
|
||||
fn lookup_filemap_idx(&self, pos: BytePos) -> usize {
|
||||
|
@ -520,13 +520,13 @@ impl CodeMap {
|
|||
}
|
||||
if a == 0 {
|
||||
panic!("position {} does not resolve to a source location",
|
||||
pos.to_uint());
|
||||
pos.to_usize());
|
||||
}
|
||||
a -= 1;
|
||||
}
|
||||
if a >= len {
|
||||
panic!("position {} does not resolve to a source location",
|
||||
pos.to_uint())
|
||||
pos.to_usize())
|
||||
}
|
||||
|
||||
return a;
|
||||
|
|
|
@ -475,7 +475,7 @@ fn highlight_lines(err: &mut EmitterWriter,
|
|||
while num > 0u { num /= 10u; digits += 1u; }
|
||||
|
||||
// indent past |name:## | and the 0-offset column location
|
||||
let left = fm.name.len() + digits + lo.col.to_uint() + 3u;
|
||||
let left = fm.name.len() + digits + lo.col.to_usize() + 3u;
|
||||
let mut s = String::new();
|
||||
// Skip is the number of characters we need to skip because they are
|
||||
// part of the 'filename:line ' part of the previous line.
|
||||
|
@ -502,7 +502,7 @@ fn highlight_lines(err: &mut EmitterWriter,
|
|||
let hi = cm.lookup_char_pos(sp.hi);
|
||||
if hi.col != lo.col {
|
||||
// the ^ already takes up one space
|
||||
let num_squigglies = hi.col.to_uint() - lo.col.to_uint() - 1u;
|
||||
let num_squigglies = hi.col.to_usize() - lo.col.to_usize() - 1us;
|
||||
for _ in range(0, num_squigglies) {
|
||||
s.push('~');
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
|
|||
let last_line_start = format!("{}:{} ", fm.name, lines[lines.len()-1]+1);
|
||||
let hi = cm.lookup_char_pos(sp.hi);
|
||||
// Span seems to use half-opened interval, so subtract 1
|
||||
let skip = last_line_start.len() + hi.col.to_uint() - 1;
|
||||
let skip = last_line_start.len() + hi.col.to_usize() - 1;
|
||||
let mut s = String::new();
|
||||
for _ in range(0, skip) {
|
||||
s.push(' ');
|
||||
|
|
|
@ -134,7 +134,7 @@ pub trait AstBuilder {
|
|||
|
||||
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr>;
|
||||
|
||||
fn expr_uint(&self, span: Span, i: usize) -> P<ast::Expr>;
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
|
||||
fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr>;
|
||||
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
|
||||
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
|
||||
|
@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
|
||||
let field_name = token::get_ident(ident);
|
||||
let field_span = Span {
|
||||
lo: sp.lo - Pos::from_uint(field_name.get().len()),
|
||||
lo: sp.lo - Pos::from_usize(field_name.get().len()),
|
||||
hi: sp.hi,
|
||||
expn_id: sp.expn_id,
|
||||
};
|
||||
|
@ -589,7 +589,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
}
|
||||
fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: usize) -> P<ast::Expr> {
|
||||
let field_span = Span {
|
||||
lo: sp.lo - Pos::from_uint(idx.to_string().len()),
|
||||
lo: sp.lo - Pos::from_usize(idx.to_string().len()),
|
||||
hi: sp.hi,
|
||||
expn_id: sp.expn_id,
|
||||
};
|
||||
|
@ -641,7 +641,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
|
||||
}
|
||||
fn expr_uint(&self, span: Span, i: usize) -> P<ast::Expr> {
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
|
||||
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs(false))))
|
||||
}
|
||||
fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
|
||||
|
@ -710,7 +710,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let loc = self.codemap().lookup_char_pos(span.lo);
|
||||
let expr_file = self.expr_str(span,
|
||||
token::intern_and_get_ident(&loc.file.name[]));
|
||||
let expr_line = self.expr_uint(span, loc.line);
|
||||
let expr_line = self.expr_usize(span, loc.line);
|
||||
let expr_file_line_tuple = self.expr_tuple(span, vec!(expr_file, expr_line));
|
||||
let expr_file_line_ptr = self.expr_addr_of(span, expr_file_line_tuple);
|
||||
self.expr_call_global(
|
||||
|
|
|
@ -114,7 +114,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.expr_try(span,
|
||||
cx.expr_method_call(span, blkdecoder.clone(), read_struct_field,
|
||||
vec!(cx.expr_str(span, name),
|
||||
cx.expr_uint(span, field),
|
||||
cx.expr_usize(span, field),
|
||||
exprdecode.clone())))
|
||||
});
|
||||
let result = cx.expr_ok(trait_span, result);
|
||||
|
@ -123,7 +123,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.ident_of("read_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_uint(trait_span, nfields),
|
||||
cx.expr_usize(trait_span, nfields),
|
||||
cx.lambda_expr_1(trait_span, result, blkarg)
|
||||
))
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
path,
|
||||
parts,
|
||||
|cx, span, _, field| {
|
||||
let idx = cx.expr_uint(span, field);
|
||||
let idx = cx.expr_usize(span, field);
|
||||
cx.expr_try(span,
|
||||
cx.expr_method_call(span, blkdecoder.clone(), rvariant_arg,
|
||||
vec!(idx, exprdecode.clone())))
|
||||
});
|
||||
|
||||
arms.push(cx.arm(v_span,
|
||||
vec!(cx.pat_lit(v_span, cx.expr_uint(v_span, i))),
|
||||
vec!(cx.pat_lit(v_span, cx.expr_usize(v_span, i))),
|
||||
decoded));
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
|
|||
StaticEnum(..) => {
|
||||
cx.span_err(trait_span, "`Default` cannot be derived for enums, only structs");
|
||||
// let compilation continue
|
||||
cx.expr_uint(trait_span, 0)
|
||||
cx.expr_usize(trait_span, 0)
|
||||
}
|
||||
_ => cx.span_bug(trait_span, "Non-static method in `deriving(Default)`")
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
//! s.emit_struct("Node", 1, |this| {
|
||||
//! this.emit_struct_field("id", 0, |this| {
|
||||
//! Encodable::encode(&self.id, this)
|
||||
//! /* this.emit_uint(self.id) can also be used */
|
||||
//! /* this.emit_usize(self.id) can also be used */
|
||||
//! })
|
||||
//! })
|
||||
//! }
|
||||
|
@ -192,7 +192,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let call = cx.expr_method_call(span, blkencoder.clone(),
|
||||
emit_struct_field,
|
||||
vec!(cx.expr_str(span, name),
|
||||
cx.expr_uint(span, i),
|
||||
cx.expr_usize(span, i),
|
||||
lambda));
|
||||
|
||||
// last call doesn't need a try!
|
||||
|
@ -218,7 +218,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.ident_of("emit_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_uint(trait_span, fields.len()),
|
||||
cx.expr_usize(trait_span, fields.len()),
|
||||
blk
|
||||
))
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let lambda = cx.lambda_expr_1(span, enc, blkarg);
|
||||
let call = cx.expr_method_call(span, blkencoder.clone(),
|
||||
emit_variant_arg,
|
||||
vec!(cx.expr_uint(span, i),
|
||||
vec!(cx.expr_usize(span, i),
|
||||
lambda));
|
||||
let call = if i != last {
|
||||
cx.expr_try(span, call)
|
||||
|
@ -262,8 +262,8 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let call = cx.expr_method_call(trait_span, blkencoder,
|
||||
cx.ident_of("emit_enum_variant"),
|
||||
vec!(name,
|
||||
cx.expr_uint(trait_span, idx),
|
||||
cx.expr_uint(trait_span, fields.len()),
|
||||
cx.expr_usize(trait_span, idx),
|
||||
cx.expr_usize(trait_span, fields.len()),
|
||||
blk));
|
||||
let blk = cx.lambda_expr_1(trait_span, call, blkarg);
|
||||
let ret = cx.expr_method_call(trait_span,
|
||||
|
|
|
@ -89,7 +89,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
// iteration function.
|
||||
let discriminant = match variant.node.disr_expr {
|
||||
Some(ref d) => d.clone(),
|
||||
None => cx.expr_uint(trait_span, index)
|
||||
None => cx.expr_usize(trait_span, index)
|
||||
};
|
||||
|
||||
stmts.push(call_hash(trait_span, discriminant));
|
||||
|
|
|
@ -80,10 +80,10 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
if variants.is_empty() {
|
||||
cx.span_err(trait_span, "`Rand` cannot be derived for enums with no variants");
|
||||
// let compilation continue
|
||||
return cx.expr_uint(trait_span, 0);
|
||||
return cx.expr_usize(trait_span, 0);
|
||||
}
|
||||
|
||||
let variant_count = cx.expr_uint(trait_span, variants.len());
|
||||
let variant_count = cx.expr_usize(trait_span, variants.len());
|
||||
|
||||
let rand_name = cx.path_all(trait_span,
|
||||
true,
|
||||
|
@ -115,7 +115,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
variant_count);
|
||||
|
||||
let mut arms = variants.iter().enumerate().map(|(i, &(ident, v_span, ref summary))| {
|
||||
let i_expr = cx.expr_uint(v_span, i);
|
||||
let i_expr = cx.expr_usize(v_span, i);
|
||||
let pat = cx.pat_lit(v_span, i_expr);
|
||||
|
||||
let path = cx.path(v_span, vec![substr.type_ident, ident]);
|
||||
|
|
|
@ -104,7 +104,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
let e = match os::getenv(var.get()) {
|
||||
None => {
|
||||
cx.span_err(sp, msg.get());
|
||||
cx.expr_uint(sp, 0)
|
||||
cx.expr_usize(sp, 0)
|
||||
}
|
||||
Some(s) => cx.expr_str(sp, token::intern_and_get_ident(&s[]))
|
||||
};
|
||||
|
|
|
@ -326,11 +326,11 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
match c {
|
||||
parse::CountIs(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
parse::CountIsParam(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
parse::CountImplied => {
|
||||
let path = self.ecx.path_global(sp, Context::rtpath(self.ecx,
|
||||
|
@ -349,7 +349,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
};
|
||||
let i = i + self.args.len();
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
}
|
||||
parse::ArgumentIs(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
// Named arguments are converted to positional arguments at
|
||||
// the end of the list of arguments
|
||||
|
@ -393,7 +393,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
};
|
||||
let i = i + self.args.len();
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -432,7 +432,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
}
|
||||
};
|
||||
let align = self.ecx.expr_path(align);
|
||||
let flags = self.ecx.expr_uint(sp, arg.format.flags);
|
||||
let flags = self.ecx.expr_usize(sp, arg.format.flags);
|
||||
let prec = self.trans_count(arg.format.precision);
|
||||
let width = self.trans_count(arg.format.width);
|
||||
let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "FormatSpec"));
|
||||
|
|
|
@ -398,7 +398,7 @@ mod tests {
|
|||
assert_eq! (marksof_internal (ans, stopname,&t), vec!(16));}
|
||||
// rename where stop doesn't match:
|
||||
{ let chain = vec!(M(9),
|
||||
R(id(name1.uint() as u32,
|
||||
R(id(name1.usize() as u32,
|
||||
apply_mark_internal (4, EMPTY_CTXT,&mut t)),
|
||||
Name(100101102)),
|
||||
M(14));
|
||||
|
@ -407,7 +407,7 @@ mod tests {
|
|||
// rename where stop does match
|
||||
{ let name1sc = apply_mark_internal(4, EMPTY_CTXT, &mut t);
|
||||
let chain = vec!(M(9),
|
||||
R(id(name1.uint() as u32, name1sc),
|
||||
R(id(name1.usize() as u32, name1sc),
|
||||
stopname),
|
||||
M(14));
|
||||
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
|
||||
|
|
|
@ -588,7 +588,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
|
|||
}
|
||||
|
||||
token::Literal(token::StrRaw(ident, n), suf) => {
|
||||
return mk_lit!("StrRaw", suf, mk_name(cx, sp, ident.ident()), cx.expr_uint(sp, n))
|
||||
return mk_lit!("StrRaw", suf, mk_name(cx, sp, ident.ident()), cx.expr_usize(sp, n))
|
||||
}
|
||||
|
||||
token::Ident(ident, style) => {
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
let topmost = cx.original_span_in_file();
|
||||
let loc = cx.codemap().lookup_char_pos(topmost.lo);
|
||||
|
||||
base::MacExpr::new(cx.expr_uint(topmost, loc.line))
|
||||
base::MacExpr::new(cx.expr_usize(topmost, loc.line))
|
||||
}
|
||||
|
||||
/* column!(): expands to the current column number */
|
||||
|
@ -45,7 +45,7 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
|
||||
let topmost = cx.original_span_in_file();
|
||||
let loc = cx.codemap().lookup_char_pos(topmost.lo);
|
||||
base::MacExpr::new(cx.expr_uint(topmost, loc.col.to_uint()))
|
||||
base::MacExpr::new(cx.expr_usize(topmost, loc.col.to_usize()))
|
||||
}
|
||||
|
||||
/// file!(): expands to the current filename */
|
||||
|
|
|
@ -174,8 +174,8 @@ pub trait Folder : Sized {
|
|||
noop_fold_ident(i, self)
|
||||
}
|
||||
|
||||
fn fold_uint(&mut self, i: usize) -> usize {
|
||||
noop_fold_uint(i, self)
|
||||
fn fold_usize(&mut self, i: usize) -> usize {
|
||||
noop_fold_usize(i, self)
|
||||
}
|
||||
|
||||
fn fold_path(&mut self, p: Path) -> Path {
|
||||
|
@ -505,7 +505,7 @@ pub fn noop_fold_ident<T: Folder>(i: Ident, _: &mut T) -> Ident {
|
|||
i
|
||||
}
|
||||
|
||||
pub fn noop_fold_uint<T: Folder>(i: usize, _: &mut T) -> usize {
|
||||
pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
|
||||
i
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
|
|||
}
|
||||
ExprTupField(el, ident) => {
|
||||
ExprTupField(folder.fold_expr(el),
|
||||
respan(ident.span, folder.fold_uint(ident.node)))
|
||||
respan(ident.span, folder.fold_usize(ident.node)))
|
||||
}
|
||||
ExprIndex(el, er) => {
|
||||
ExprIndex(folder.fold_expr(el), folder.fold_expr(er))
|
||||
|
|
|
@ -208,7 +208,7 @@ fn read_line_comments(rdr: &mut StringReader, code_to_the_left: bool,
|
|||
/// whitespace. Note k may be outside bounds of s.
|
||||
fn all_whitespace(s: &str, col: CharPos) -> Option<usize> {
|
||||
let len = s.len();
|
||||
let mut col = col.to_uint();
|
||||
let mut col = col.to_usize();
|
||||
let mut cursor: usize = 0;
|
||||
while col > 0 && cursor < len {
|
||||
let r: str::CharRange = s.char_range_at(cursor);
|
||||
|
|
|
@ -212,8 +212,8 @@ impl<'a> StringReader<'a> {
|
|||
/// offending string to the error message
|
||||
fn fatal_span_verbose(&self, from_pos: BytePos, to_pos: BytePos, mut m: String) -> ! {
|
||||
m.push_str(": ");
|
||||
let from = self.byte_offset(from_pos).to_uint();
|
||||
let to = self.byte_offset(to_pos).to_uint();
|
||||
let from = self.byte_offset(from_pos).to_usize();
|
||||
let to = self.byte_offset(to_pos).to_usize();
|
||||
m.push_str(&self.filemap.src[from..to]);
|
||||
self.fatal_span_(from_pos, to_pos, &m[]);
|
||||
}
|
||||
|
@ -272,8 +272,8 @@ impl<'a> StringReader<'a> {
|
|||
F: FnOnce(&str) -> T,
|
||||
{
|
||||
f(self.filemap.src.slice(
|
||||
self.byte_offset(start).to_uint(),
|
||||
self.byte_offset(end).to_uint()))
|
||||
self.byte_offset(start).to_usize(),
|
||||
self.byte_offset(end).to_usize()))
|
||||
}
|
||||
|
||||
/// Converts CRLF to LF in the given string, raising an error on bare CR.
|
||||
|
@ -321,7 +321,7 @@ impl<'a> StringReader<'a> {
|
|||
/// discovered, add it to the FileMap's list of line start offsets.
|
||||
pub fn bump(&mut self) {
|
||||
self.last_pos = self.pos;
|
||||
let current_byte_offset = self.byte_offset(self.pos).to_uint();
|
||||
let current_byte_offset = self.byte_offset(self.pos).to_usize();
|
||||
if current_byte_offset < self.filemap.src.len() {
|
||||
assert!(self.curr.is_some());
|
||||
let last_char = self.curr.unwrap();
|
||||
|
@ -329,7 +329,7 @@ impl<'a> StringReader<'a> {
|
|||
.src
|
||||
.char_range_at(current_byte_offset);
|
||||
let byte_offset_diff = next.next - current_byte_offset;
|
||||
self.pos = self.pos + Pos::from_uint(byte_offset_diff);
|
||||
self.pos = self.pos + Pos::from_usize(byte_offset_diff);
|
||||
self.curr = Some(next.ch);
|
||||
self.col = self.col + CharPos(1u);
|
||||
if last_char == '\n' {
|
||||
|
@ -346,7 +346,7 @@ impl<'a> StringReader<'a> {
|
|||
}
|
||||
|
||||
pub fn nextch(&self) -> Option<char> {
|
||||
let offset = self.byte_offset(self.pos).to_uint();
|
||||
let offset = self.byte_offset(self.pos).to_usize();
|
||||
if offset < self.filemap.src.len() {
|
||||
Some(self.filemap.src.char_at(offset))
|
||||
} else {
|
||||
|
@ -359,7 +359,7 @@ impl<'a> StringReader<'a> {
|
|||
}
|
||||
|
||||
pub fn nextnextch(&self) -> Option<char> {
|
||||
let offset = self.byte_offset(self.pos).to_uint();
|
||||
let offset = self.byte_offset(self.pos).to_usize();
|
||||
let s = self.filemap.src.as_slice();
|
||||
if offset >= s.len() { return None }
|
||||
let str::CharRange { next, .. } = s.char_range_at(offset);
|
||||
|
|
|
@ -1171,9 +1171,9 @@ mod test {
|
|||
for &src in srcs.iter() {
|
||||
let spans = get_spans_of_pat_idents(src);
|
||||
let Span{ lo, hi, .. } = spans[0];
|
||||
assert!("self" == &src[lo.to_uint()..hi.to_uint()],
|
||||
assert!("self" == &src[lo.to_usize()..hi.to_usize()],
|
||||
"\"{}\" != \"self\". src=\"{}\"",
|
||||
&src[lo.to_uint()..hi.to_uint()], src)
|
||||
&src[lo.to_usize()..hi.to_usize()], src)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -757,7 +757,7 @@ pub fn fresh_name(src: &ast::Ident) -> ast::Name {
|
|||
|
||||
// create a fresh mark.
|
||||
pub fn fresh_mark() -> ast::Mrk {
|
||||
gensym("mark").uint() as u32
|
||||
gensym("mark").usize() as u32
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1789,7 +1789,7 @@ impl<'a> State<'a> {
|
|||
ast::ExprTupField(ref expr, id) => {
|
||||
try!(self.print_expr(&**expr));
|
||||
try!(word(&mut self.s, "."));
|
||||
try!(self.print_uint(id.node));
|
||||
try!(self.print_usize(id.node));
|
||||
}
|
||||
ast::ExprIndex(ref expr, ref index) => {
|
||||
try!(self.print_expr(&**expr));
|
||||
|
@ -1951,7 +1951,7 @@ impl<'a> State<'a> {
|
|||
self.ann.post(self, NodeIdent(&ident))
|
||||
}
|
||||
|
||||
pub fn print_uint(&mut self, i: usize) -> IoResult<()> {
|
||||
pub fn print_usize(&mut self, i: usize) -> IoResult<()> {
|
||||
word(&mut self.s, &i.to_string()[])
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ impl<T: Eq + Hash<Hasher> + Clone + 'static> Interner<T> {
|
|||
|
||||
pub fn get(&self, idx: Name) -> T {
|
||||
let vect = self.vect.borrow();
|
||||
(*vect)[idx.uint()].clone()
|
||||
(*vect)[idx.usize()].clone()
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
|
@ -190,13 +190,13 @@ impl StrInterner {
|
|||
let new_idx = Name(self.len() as u32);
|
||||
// leave out of map to avoid colliding
|
||||
let mut vect = self.vect.borrow_mut();
|
||||
let existing = (*vect)[idx.uint()].clone();
|
||||
let existing = (*vect)[idx.usize()].clone();
|
||||
vect.push(existing);
|
||||
new_idx
|
||||
}
|
||||
|
||||
pub fn get(&self, idx: Name) -> RcStr {
|
||||
(*self.vect.borrow())[idx.uint()].clone()
|
||||
(*self.vect.borrow())[idx.usize()].clone()
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
|
|
|
@ -20,7 +20,7 @@ use syntax::codemap::Span;
|
|||
use syntax::parse::token;
|
||||
use syntax::ast::{TokenTree, TtToken};
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacExpr};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_uint
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
// WARNING WARNING WARNING WARNING WARNING
|
||||
|
@ -61,7 +61,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
|||
}
|
||||
}
|
||||
|
||||
MacExpr::new(cx.expr_uint(sp, total))
|
||||
MacExpr::new(cx.expr_usize(sp, total))
|
||||
}
|
||||
|
||||
#[plugin_registrar]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue