Skip to content

Commit a32249d

Browse files
committed
libsyntax: uint types to usize
1 parent 89c4e37 commit a32249d

29 files changed

+165
-165
lines changed

src/libsyntax/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ pub fn all_names() -> Vec<&'static str> {
105105

106106
impl Abi {
107107
#[inline]
108-
pub fn index(&self) -> uint {
109-
*self as uint
108+
pub fn index(&self) -> usize {
109+
*self as usize
110110
}
111111

112112
#[inline]

src/libsyntax/ast.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl PartialEq for Ident {
152152

153153
/// A SyntaxContext represents a chain of macro-expandings
154154
/// and renamings. Each macro expansion corresponds to
155-
/// a fresh uint
155+
/// a fresh usize
156156
157157
// I'm representing this syntax context as an index into
158158
// a table, in order to work around a compiler bug
@@ -181,9 +181,9 @@ impl Name {
181181
}
182182
}
183183

184-
pub fn uint(&self) -> uint {
184+
pub fn uint(&self) -> usize {
185185
let Name(nm) = *self;
186-
nm as uint
186+
nm as usize
187187
}
188188

189189
pub fn ident(&self) -> Ident {
@@ -740,7 +740,7 @@ pub enum Expr_ {
740740
ExprAssign(P<Expr>, P<Expr>),
741741
ExprAssignOp(BinOp, P<Expr>, P<Expr>),
742742
ExprField(P<Expr>, SpannedIdent),
743-
ExprTupField(P<Expr>, Spanned<uint>),
743+
ExprTupField(P<Expr>, Spanned<usize>),
744744
ExprIndex(P<Expr>, P<Expr>),
745745
ExprRange(Option<P<Expr>>, Option<P<Expr>>),
746746

@@ -839,7 +839,7 @@ pub struct SequenceRepetition {
839839
/// Whether the sequence can be repeated zero (*), or one or more times (+)
840840
pub op: KleeneOp,
841841
/// The number of `MatchNt`s that appear in the sequence (and subsequences)
842-
pub num_captures: uint,
842+
pub num_captures: usize,
843843
}
844844

845845
/// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star)
@@ -878,7 +878,7 @@ pub enum TokenTree {
878878
}
879879

880880
impl TokenTree {
881-
pub fn len(&self) -> uint {
881+
pub fn len(&self) -> usize {
882882
match *self {
883883
TtToken(_, token::DocComment(_)) => 2,
884884
TtToken(_, token::SpecialVarNt(..)) => 2,
@@ -893,7 +893,7 @@ impl TokenTree {
893893
}
894894
}
895895

896-
pub fn get_tt(&self, index: uint) -> TokenTree {
896+
pub fn get_tt(&self, index: usize) -> TokenTree {
897897
match (self, index) {
898898
(&TtToken(sp, token::DocComment(_)), 0) => {
899899
TtToken(sp, token::Pound)
@@ -963,7 +963,7 @@ pub enum Mac_ {
963963
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
964964
pub enum StrStyle {
965965
CookedStr,
966-
RawStr(uint)
966+
RawStr(usize)
967967
}
968968

969969
pub type Lit = Spanned<Lit_>;
@@ -992,7 +992,7 @@ pub enum LitIntType {
992992
}
993993

994994
impl LitIntType {
995-
pub fn suffix_len(&self) -> uint {
995+
pub fn suffix_len(&self) -> usize {
996996
match *self {
997997
UnsuffixedIntLit(_) => 0,
998998
SignedIntLit(s, _) => s.suffix_len(),
@@ -1113,7 +1113,7 @@ impl fmt::String for IntTy {
11131113
}
11141114

11151115
impl IntTy {
1116-
pub fn suffix_len(&self) -> uint {
1116+
pub fn suffix_len(&self) -> usize {
11171117
match *self {
11181118
TyIs(true) /* i */ => 1,
11191119
TyIs(false) /* is */ | TyI8 => 2,
@@ -1146,7 +1146,7 @@ impl PartialEq for UintTy {
11461146
}
11471147

11481148
impl UintTy {
1149-
pub fn suffix_len(&self) -> uint {
1149+
pub fn suffix_len(&self) -> usize {
11501150
match *self {
11511151
TyUs(true) /* u */ => 1,
11521152
TyUs(false) /* us */ | TyU8 => 2,
@@ -1186,7 +1186,7 @@ impl fmt::String for FloatTy {
11861186
}
11871187

11881188
impl FloatTy {
1189-
pub fn suffix_len(&self) -> uint {
1189+
pub fn suffix_len(&self) -> usize {
11901190
match *self {
11911191
TyF32 | TyF64 => 3, // add F128 handling here
11921192
}
@@ -1274,7 +1274,7 @@ pub enum Ty_ {
12741274
TyPtr(MutTy),
12751275
/// A reference (`&'a T` or `&'a mut T`)
12761276
TyRptr(Option<Lifetime>, MutTy),
1277-
/// A bare function (e.g. `fn(uint) -> bool`)
1277+
/// A bare function (e.g. `fn(usize) -> bool`)
12781278
TyBareFn(P<BareFnTy>),
12791279
/// A tuple (`(A, B, C, D,...)`)
12801280
TyTup(Vec<P<Ty>> ),
@@ -1566,7 +1566,7 @@ pub enum AttrStyle {
15661566
}
15671567

15681568
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
1569-
pub struct AttrId(pub uint);
1569+
pub struct AttrId(pub usize);
15701570

15711571
/// Doc-comments are promoted to attributes that have is_sugared_doc = true
15721572
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]

src/libsyntax/ast_map/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ pub struct Map<'ast> {
264264
}
265265

266266
impl<'ast> Map<'ast> {
267-
fn entry_count(&self) -> uint {
267+
fn entry_count(&self) -> usize {
268268
self.map.borrow().len()
269269
}
270270

271271
fn find_entry(&self, id: NodeId) -> Option<MapEntry<'ast>> {
272-
self.map.borrow().get(id as uint).map(|e| *e)
272+
self.map.borrow().get(id as usize).map(|e| *e)
273273
}
274274

275275
pub fn krate(&self) -> &'ast Crate {
@@ -652,7 +652,7 @@ impl<'a, 'ast> Iterator for NodesMatchingSuffix<'a, 'ast> {
652652
fn next(&mut self) -> Option<NodeId> {
653653
loop {
654654
let idx = self.idx;
655-
if idx as uint >= self.map.entry_count() {
655+
if idx as usize >= self.map.entry_count() {
656656
return None;
657657
}
658658
self.idx += 1;
@@ -744,10 +744,10 @@ impl<'ast> NodeCollector<'ast> {
744744
fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) {
745745
debug!("ast_map: {:?} => {:?}", id, entry);
746746
let len = self.map.len();
747-
if id as uint >= len {
748-
self.map.extend(repeat(NotPresent).take(id as uint - len + 1));
747+
if id as usize >= len {
748+
self.map.extend(repeat(NotPresent).take(id as usize - len + 1));
749749
}
750-
self.map[id as uint] = entry;
750+
self.map[id as usize] = entry;
751751
}
752752

753753
fn insert(&mut self, id: NodeId, node: Node<'ast>) {

src/libsyntax/ast_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
156156
}
157157

158158
/// Get a string representation of an unsigned int type, with its value.
159-
/// We want to avoid "42uint" in favor of "42u"
159+
/// We want to avoid "42u" in favor of "42us". "42uint" is right out.
160160
pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
161161
let s = match t {
162162
TyUs(true) if val.is_some() => "u",
@@ -319,7 +319,7 @@ pub fn struct_field_visibility(field: ast::StructField) -> Visibility {
319319
}
320320

321321
/// Maps a binary operator to its precedence
322-
pub fn operator_prec(op: ast::BinOp) -> uint {
322+
pub fn operator_prec(op: ast::BinOp) -> usize {
323323
match op {
324324
// 'as' sits here with 12
325325
BiMul | BiDiv | BiRem => 11u,
@@ -337,7 +337,7 @@ pub fn operator_prec(op: ast::BinOp) -> uint {
337337
/// Precedence of the `as` operator, which is a binary operator
338338
/// not appearing in the prior table.
339339
#[allow(non_upper_case_globals)]
340-
pub static as_prec: uint = 12u;
340+
pub static as_prec: usize = 12us;
341341

342342
pub fn empty_generics() -> Generics {
343343
Generics {

src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub fn mk_word_item(name: InternedString) -> P<MetaItem> {
170170
P(dummy_spanned(MetaWord(name)))
171171
}
172172

173-
thread_local! { static NEXT_ATTR_ID: Cell<uint> = Cell::new(0) }
173+
thread_local! { static NEXT_ATTR_ID: Cell<usize> = Cell::new(0) }
174174

175175
pub fn mk_attr_id() -> AttrId {
176176
let id = NEXT_ATTR_ID.with(|slot| {

src/libsyntax/codemap.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use libc::c_uint;
3030
use serialize::{Encodable, Decodable, Encoder, Decoder};
3131

3232
pub trait Pos {
33-
fn from_uint(n: uint) -> Self;
34-
fn to_uint(&self) -> uint;
33+
fn from_uint(n: usize) -> Self;
34+
fn to_uint(&self) -> usize;
3535
}
3636

3737
/// A byte offset. Keep this small (currently 32-bits), as AST contains
@@ -43,14 +43,14 @@ pub struct BytePos(pub u32);
4343
/// is not equivalent to a character offset. The CodeMap will convert BytePos
4444
/// values to CharPos values as necessary.
4545
#[derive(Copy, PartialEq, Hash, PartialOrd, Show)]
46-
pub struct CharPos(pub uint);
46+
pub struct CharPos(pub usize);
4747

4848
// FIXME: Lots of boilerplate in these impls, but so far my attempts to fix
4949
// have been unsuccessful
5050

5151
impl Pos for BytePos {
52-
fn from_uint(n: uint) -> BytePos { BytePos(n as u32) }
53-
fn to_uint(&self) -> uint { let BytePos(n) = *self; n as uint }
52+
fn from_uint(n: usize) -> BytePos { BytePos(n as u32) }
53+
fn to_uint(&self) -> usize { let BytePos(n) = *self; n as usize }
5454
}
5555

5656
impl Add for BytePos {
@@ -70,8 +70,8 @@ impl Sub for BytePos {
7070
}
7171

7272
impl Pos for CharPos {
73-
fn from_uint(n: uint) -> CharPos { CharPos(n) }
74-
fn to_uint(&self) -> uint { let CharPos(n) = *self; n }
73+
fn from_uint(n: usize) -> CharPos { CharPos(n) }
74+
fn to_uint(&self) -> usize { let CharPos(n) = *self; n }
7575
}
7676

7777
impl Add for CharPos {
@@ -173,7 +173,7 @@ pub struct Loc {
173173
/// Information about the original source
174174
pub file: Rc<FileMap>,
175175
/// The (1-based) line number
176-
pub line: uint,
176+
pub line: usize,
177177
/// The (0-based) column offset
178178
pub col: CharPos
179179
}
@@ -183,13 +183,13 @@ pub struct Loc {
183183
// perhaps they should just be removed.
184184
pub struct LocWithOpt {
185185
pub filename: FileName,
186-
pub line: uint,
186+
pub line: usize,
187187
pub col: CharPos,
188188
pub file: Option<Rc<FileMap>>,
189189
}
190190

191191
// used to be structural records. Better names, anyone?
192-
pub struct FileMapAndLine { pub fm: Rc<FileMap>, pub line: uint }
192+
pub struct FileMapAndLine { pub fm: Rc<FileMap>, pub line: usize }
193193
pub struct FileMapAndBytePos { pub fm: Rc<FileMap>, pub pos: BytePos }
194194

195195
/// The syntax with which a macro was invoked.
@@ -258,7 +258,7 @@ pub type FileName = String;
258258

259259
pub struct FileLines {
260260
pub file: Rc<FileMap>,
261-
pub lines: Vec<uint>
261+
pub lines: Vec<usize>
262262
}
263263

264264
/// Identifies an offset of a multi-byte character in a FileMap
@@ -267,7 +267,7 @@ pub struct MultiByteChar {
267267
/// The absolute offset of the character in the CodeMap
268268
pub pos: BytePos,
269269
/// The number of bytes, >=2
270-
pub bytes: uint,
270+
pub bytes: usize,
271271
}
272272

273273
/// A single source in the CodeMap
@@ -306,7 +306,7 @@ impl FileMap {
306306

307307
/// get a line from the list of pre-computed line-beginnings
308308
///
309-
pub fn get_line(&self, line_number: uint) -> Option<String> {
309+
pub fn get_line(&self, line_number: usize) -> Option<String> {
310310
let lines = self.lines.borrow();
311311
lines.get(line_number).map(|&line| {
312312
let begin: BytePos = line - self.start_pos;
@@ -319,7 +319,7 @@ impl FileMap {
319319
})
320320
}
321321

322-
pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) {
322+
pub fn record_multibyte_char(&self, pos: BytePos, bytes: usize) {
323323
assert!(bytes >=2 && bytes <= 4);
324324
let mbc = MultiByteChar {
325325
pos: pos,
@@ -430,7 +430,7 @@ impl CodeMap {
430430
let lo = self.lookup_char_pos(sp.lo);
431431
let hi = self.lookup_char_pos(sp.hi);
432432
let mut lines = Vec::new();
433-
for i in range(lo.line - 1u, hi.line as uint) {
433+
for i in range(lo.line - 1u, hi.line as usize) {
434434
lines.push(i);
435435
};
436436
FileLines {file: lo.file, lines: lines}
@@ -494,7 +494,7 @@ impl CodeMap {
494494
CharPos(bpos.to_uint() - map.start_pos.to_uint() - total_extra_bytes)
495495
}
496496

497-
fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
497+
fn lookup_filemap_idx(&self, pos: BytePos) -> usize {
498498
let files = self.files.borrow();
499499
let files = &*files;
500500
let len = files.len();
@@ -579,7 +579,7 @@ impl CodeMap {
579579
{
580580
match id {
581581
NO_EXPANSION => f(None),
582-
ExpnId(i) => f(Some(&(*self.expansions.borrow())[i as uint]))
582+
ExpnId(i) => f(Some(&(*self.expansions.borrow())[i as usize]))
583583
}
584584
}
585585

src/libsyntax/diagnostic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use term::WriterWrapper;
2626
use term;
2727

2828
/// maximum number of lines we will print for each error; arbitrary.
29-
static MAX_LINES: uint = 6u;
29+
static MAX_LINES: usize = 6u;
3030

3131
#[derive(Clone, Copy)]
3232
pub enum RenderSpan {
@@ -137,7 +137,7 @@ impl SpanHandler {
137137
/// (fatal, bug, unimpl) may cause immediate exit,
138138
/// others log errors for later reporting.
139139
pub struct Handler {
140-
err_count: Cell<uint>,
140+
err_count: Cell<usize>,
141141
emit: RefCell<Box<Emitter + Send>>,
142142
}
143143

@@ -153,7 +153,7 @@ impl Handler {
153153
pub fn bump_err_count(&self) {
154154
self.err_count.set(self.err_count.get() + 1u);
155155
}
156-
pub fn err_count(&self) -> uint {
156+
pub fn err_count(&self) -> usize {
157157
self.err_count.get()
158158
}
159159
pub fn has_errors(&self) -> bool {

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ pub struct ExtCtxt<'a> {
548548
pub exported_macros: Vec<ast::MacroDef>,
549549

550550
pub syntax_env: SyntaxEnv,
551-
pub recursion_count: uint,
551+
pub recursion_count: usize,
552552
}
553553

554554
impl<'a> ExtCtxt<'a> {

0 commit comments

Comments
 (0)