Skip to content

Commit 0c98187

Browse files
committed
rollup merge of rust-lang#21340: pshc/libsyntax-no-more-ints
Collaboration with @rylev! I didn't change `int` in the [quasi-quoter](https://github.com/pshc/rust/blob/99ae1a30f3ca28c0f7e431620560d30e44627124/src/libsyntax/ext/quote.rs#L328), because I'm not sure if there will be adverse effects. Addresses rust-lang#21095.
2 parents 5da2538 + 3c32cd1 commit 0c98187

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+488
-488
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ impl UnusedMut {
13291329
let ident = path1.node;
13301330
if let ast::BindByValue(ast::MutMutable) = mode {
13311331
if !token::get_ident(ident).get().starts_with("_") {
1332-
match mutables.entry(ident.name.uint()) {
1332+
match mutables.entry(ident.name.usize()) {
13331333
Vacant(entry) => { entry.insert(vec![id]); },
13341334
Occupied(mut entry) => { entry.get_mut().push(id); },
13351335
}

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
164164
fn explain_span(cx: &ctxt, heading: &str, span: Span)
165165
-> (String, Option<Span>) {
166166
let lo = cx.sess.codemap().lookup_char_pos_adj(span.lo);
167-
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_uint()),
167+
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
168168
Some(span))
169169
}
170170
}

src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19671967
let module_name = self.module_to_string(&*search_module);
19681968
let mut span = span;
19691969
let msg = if "???" == &module_name[] {
1970-
span.hi = span.lo + Pos::from_uint(segment_name.get().len());
1970+
span.hi = span.lo + Pos::from_usize(segment_name.get().len());
19711971

19721972
match search_parent_externals(name,
19731973
&self.current_module) {

src/librustc_trans/save/span_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl<'a> SpanUtils<'a> {
4040
format!("file_name,{},file_line,{},file_col,{},extent_start,{},extent_start_bytes,{},\
4141
file_line_end,{},file_col_end,{},extent_end,{},extent_end_bytes,{}",
4242
lo_loc.file.name,
43-
lo_loc.line, lo_loc.col.to_uint(), lo_pos.to_uint(), lo_pos_byte.to_uint(),
44-
hi_loc.line, hi_loc.col.to_uint(), hi_pos.to_uint(), hi_pos_byte.to_uint())
43+
lo_loc.line, lo_loc.col.to_usize(), lo_pos.to_usize(), lo_pos_byte.to_usize(),
44+
hi_loc.line, hi_loc.col.to_usize(), hi_pos.to_usize(), hi_pos_byte.to_usize())
4545
}
4646

4747
// sub_span starts at span.lo, so we need to adjust the positions etc.

src/librustc_trans/trans/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn return_type_is_void(ccx: &CrateContext, ty: Ty) -> bool {
275275
/// Generates a unique symbol based off the name given. This is used to create
276276
/// unique symbols for things like closures.
277277
pub fn gensym_name(name: &str) -> PathElem {
278-
let num = token::gensym(name).uint();
278+
let num = token::gensym(name).usize();
279279
// use one colon which will get translated to a period by the mangler, and
280280
// we're guaranteed that `num` is globally unique for this crate.
281281
PathName(token::gensym(&format!("{}:{}", name, num)[]))
@@ -848,7 +848,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
848848
!null_terminated as Bool);
849849

850850
let gsym = token::gensym("str");
851-
let buf = CString::from_vec(format!("str{}", gsym.uint()).into_bytes());
851+
let buf = CString::from_vec(format!("str{}", gsym.usize()).into_bytes());
852852
let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(sc).to_ref(), buf.as_ptr());
853853
llvm::LLVMSetInitializer(g, sc);
854854
llvm::LLVMSetGlobalConstant(g, True);
@@ -873,7 +873,7 @@ pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef {
873873
let lldata = C_bytes(cx, data);
874874

875875
let gsym = token::gensym("binary");
876-
let name = format!("binary{}", gsym.uint());
876+
let name = format!("binary{}", gsym.usize());
877877
let name = CString::from_vec(name.into_bytes());
878878
let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(lldata).to_ref(),
879879
name.as_ptr());

src/librustc_trans/trans/debuginfo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ pub fn set_source_location(fcx: &FunctionContext,
12041204

12051205
set_debug_location(cx, DebugLocation::new(scope,
12061206
loc.line,
1207-
loc.col.to_uint()));
1207+
loc.col.to_usize()));
12081208
} else {
12091209
set_debug_location(cx, UnknownLocation);
12101210
}
@@ -1716,7 +1716,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17161716

17171717
set_debug_location(cx, DebugLocation::new(scope_metadata,
17181718
loc.line,
1719-
loc.col.to_uint()));
1719+
loc.col.to_usize()));
17201720
unsafe {
17211721
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
17221722
DIB(cx),
@@ -3279,7 +3279,7 @@ fn create_scope_map(cx: &CrateContext,
32793279
parent_scope,
32803280
file_metadata,
32813281
loc.line as c_uint,
3282-
loc.col.to_uint() as c_uint)
3282+
loc.col.to_usize() as c_uint)
32833283
};
32843284

32853285
scope_stack.push(ScopeStackEntry { scope_metadata: scope_metadata,
@@ -3401,7 +3401,7 @@ fn create_scope_map(cx: &CrateContext,
34013401
parent_scope,
34023402
file_metadata,
34033403
loc.line as c_uint,
3404-
loc.col.to_uint() as c_uint)
3404+
loc.col.to_usize() as c_uint)
34053405
};
34063406

34073407
scope_stack.push(ScopeStackEntry {

src/librustc_trans/trans/meth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pub fn make_vtable<I: Iterator<Item=ValueRef>>(ccx: &CrateContext,
785785
unsafe {
786786
let tbl = C_struct(ccx, &components[], false);
787787
let sym = token::gensym("vtable");
788-
let buf = CString::from_vec(format!("vtable{}", sym.uint()).into_bytes());
788+
let buf = CString::from_vec(format!("vtable{}", sym.usize()).into_bytes());
789789
let vt_gvar = llvm::LLVMAddGlobal(ccx.llmod(), val_ty(tbl).to_ref(),
790790
buf.as_ptr());
791791
llvm::LLVMSetInitializer(vt_gvar, tbl);

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,9 +1872,9 @@ impl Clean<Span> for syntax::codemap::Span {
18721872
Span {
18731873
filename: filename.to_string(),
18741874
loline: lo.line,
1875-
locol: lo.col.to_uint(),
1875+
locol: lo.col.to_usize(),
18761876
hiline: hi.line,
1877-
hicol: hi.col.to_uint(),
1877+
hicol: hi.col.to_usize(),
18781878
}
18791879
}
18801880
}

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: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Ident {
9595

9696
pub fn encode_with_hygiene(&self) -> String {
9797
format!("\x00name_{},ctxt_{}\x00",
98-
self.name.uint(),
98+
self.name.usize(),
9999
self.ctxt)
100100
}
101101
}
@@ -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 usize(&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>> ),
@@ -1571,7 +1571,7 @@ pub enum AttrStyle {
15711571
}
15721572

15731573
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
1574-
pub struct AttrId(pub uint);
1574+
pub struct AttrId(pub usize);
15751575

15761576
/// Doc-comments are promoted to attributes that have is_sugared_doc = true
15771577
#[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: 12 additions & 12 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,25 +319,25 @@ 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
325-
BiMul | BiDiv | BiRem => 11u,
326-
BiAdd | BiSub => 10u,
327-
BiShl | BiShr => 9u,
328-
BiBitAnd => 8u,
329-
BiBitXor => 7u,
330-
BiBitOr => 6u,
331-
BiLt | BiLe | BiGe | BiGt | BiEq | BiNe => 3u,
332-
BiAnd => 2u,
333-
BiOr => 1u
325+
BiMul | BiDiv | BiRem => 11us,
326+
BiAdd | BiSub => 10us,
327+
BiShl | BiShr => 9us,
328+
BiBitAnd => 8us,
329+
BiBitXor => 7us,
330+
BiBitOr => 6us,
331+
BiLt | BiLe | BiGe | BiGt | BiEq | BiNe => 3us,
332+
BiAnd => 2us,
333+
BiOr => 1us
334334
}
335335
}
336336

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| {

0 commit comments

Comments
 (0)