Skip to content

Commit 9683745

Browse files
author
Alfie John
committed
Omit integer suffix when unnecessary
See PR # 21378 for context
1 parent ca4b967 commit 9683745

File tree

15 files changed

+142
-142
lines changed

15 files changed

+142
-142
lines changed

src/libsyntax/ast_util.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,21 +322,21 @@ pub fn struct_field_visibility(field: ast::StructField) -> Visibility {
322322
pub fn operator_prec(op: ast::BinOp_) -> usize {
323323
match op {
324324
// 'as' sits here with 12
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
325+
BiMul | BiDiv | BiRem => 11,
326+
BiAdd | BiSub => 10,
327+
BiShl | BiShr => 9,
328+
BiBitAnd => 8,
329+
BiBitXor => 7,
330+
BiBitOr => 6,
331+
BiLt | BiLe | BiGe | BiGt | BiEq | BiNe => 3,
332+
BiAnd => 2,
333+
BiOr => 1
334334
}
335335
}
336336

337337
/// Precedence of the `as` operator, which is a binary operator
338338
/// not appearing in the prior table.
339-
pub const AS_PREC: usize = 12us;
339+
pub const AS_PREC: usize = 12;
340340

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

src/libsyntax/codemap.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl CodeMap {
431431
let lo = self.lookup_char_pos(sp.lo);
432432
let hi = self.lookup_char_pos(sp.hi);
433433
let mut lines = Vec::new();
434-
for i in lo.line - 1us..hi.line as usize {
434+
for i in lo.line - 1..hi.line as usize {
435435
lines.push(i);
436436
};
437437
FileLines {file: lo.file, lines: lines}
@@ -499,10 +499,10 @@ impl CodeMap {
499499
let files = self.files.borrow();
500500
let files = &*files;
501501
let len = files.len();
502-
let mut a = 0us;
502+
let mut a = 0;
503503
let mut b = len;
504-
while b - a > 1us {
505-
let m = (a + b) / 2us;
504+
while b - a > 1 {
505+
let m = (a + b) / 2;
506506
if files[m].start_pos > pos {
507507
b = m;
508508
} else {
@@ -538,12 +538,12 @@ impl CodeMap {
538538

539539
let files = self.files.borrow();
540540
let f = (*files)[idx].clone();
541-
let mut a = 0us;
541+
let mut a = 0;
542542
{
543543
let lines = f.lines.borrow();
544544
let mut b = lines.len();
545-
while b - a > 1us {
546-
let m = (a + b) / 2us;
545+
while b - a > 1 {
546+
let m = (a + b) / 2;
547547
if (*lines)[m] > pos { b = m; } else { a = m; }
548548
}
549549
}
@@ -552,7 +552,7 @@ impl CodeMap {
552552

553553
fn lookup_pos(&self, pos: BytePos) -> Loc {
554554
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
555-
let line = a + 1us; // Line numbers start at 1
555+
let line = a + 1; // Line numbers start at 1
556556
let chpos = self.bytepos_to_file_charpos(pos);
557557
let linebpos = (*f.lines.borrow())[a];
558558
let linechpos = self.bytepos_to_file_charpos(linebpos);
@@ -763,7 +763,7 @@ mod test {
763763

764764
assert_eq!(file_lines.file.name, "blork.rs");
765765
assert_eq!(file_lines.lines.len(), 1);
766-
assert_eq!(file_lines.lines[0], 1us);
766+
assert_eq!(file_lines.lines[0], 1);
767767
}
768768

769769
#[test]

src/libsyntax/diagnostic.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use term::WriterWrapper;
2525
use term;
2626

2727
/// maximum number of lines we will print for each error; arbitrary.
28-
static MAX_LINES: usize = 6us;
28+
static MAX_LINES: usize = 6;
2929

3030
#[derive(Clone, Copy)]
3131
pub enum RenderSpan {
@@ -155,19 +155,19 @@ impl Handler {
155155
self.bump_err_count();
156156
}
157157
pub fn bump_err_count(&self) {
158-
self.err_count.set(self.err_count.get() + 1us);
158+
self.err_count.set(self.err_count.get() + 1);
159159
}
160160
pub fn err_count(&self) -> usize {
161161
self.err_count.get()
162162
}
163163
pub fn has_errors(&self) -> bool {
164-
self.err_count.get() > 0us
164+
self.err_count.get() > 0
165165
}
166166
pub fn abort_if_errors(&self) {
167167
let s;
168168
match self.err_count.get() {
169-
0us => return,
170-
1us => s = "aborting due to previous error".to_string(),
169+
0 => return,
170+
1 => s = "aborting due to previous error".to_string(),
171171
_ => {
172172
s = format!("aborting due to {} previous errors",
173173
self.err_count.get());
@@ -457,7 +457,7 @@ fn highlight_lines(err: &mut EmitterWriter,
457457
let mut elided = false;
458458
let mut display_lines = &lines.lines[];
459459
if display_lines.len() > MAX_LINES {
460-
display_lines = &display_lines[0us..MAX_LINES];
460+
display_lines = &display_lines[0..MAX_LINES];
461461
elided = true;
462462
}
463463
// Print the offending lines
@@ -468,32 +468,32 @@ fn highlight_lines(err: &mut EmitterWriter,
468468
}
469469
}
470470
if elided {
471-
let last_line = display_lines[display_lines.len() - 1us];
472-
let s = format!("{}:{} ", fm.name, last_line + 1us);
471+
let last_line = display_lines[display_lines.len() - 1];
472+
let s = format!("{}:{} ", fm.name, last_line + 1);
473473
try!(write!(&mut err.dst, "{0:1$}...\n", "", s.len()));
474474
}
475475

476476
// FIXME (#3260)
477477
// If there's one line at fault we can easily point to the problem
478-
if lines.lines.len() == 1us {
478+
if lines.lines.len() == 1 {
479479
let lo = cm.lookup_char_pos(sp.lo);
480-
let mut digits = 0us;
481-
let mut num = (lines.lines[0] + 1us) / 10us;
480+
let mut digits = 0;
481+
let mut num = (lines.lines[0] + 1) / 10;
482482

483483
// how many digits must be indent past?
484-
while num > 0us { num /= 10us; digits += 1us; }
484+
while num > 0 { num /= 10; digits += 1; }
485485

486486
// indent past |name:## | and the 0-offset column location
487-
let left = fm.name.len() + digits + lo.col.to_usize() + 3us;
487+
let left = fm.name.len() + digits + lo.col.to_usize() + 3;
488488
let mut s = String::new();
489489
// Skip is the number of characters we need to skip because they are
490490
// part of the 'filename:line ' part of the previous line.
491-
let skip = fm.name.len() + digits + 3us;
491+
let skip = fm.name.len() + digits + 3;
492492
for _ in 0..skip {
493493
s.push(' ');
494494
}
495495
if let Some(orig) = fm.get_line(lines.lines[0]) {
496-
for pos in 0us..left - skip {
496+
for pos in 0..left - skip {
497497
let cur_char = orig.as_bytes()[pos] as char;
498498
// Whenever a tab occurs on the previous line, we insert one on
499499
// the error-point-squiggly-line as well (instead of a space).
@@ -511,7 +511,7 @@ fn highlight_lines(err: &mut EmitterWriter,
511511
let hi = cm.lookup_char_pos(sp.hi);
512512
if hi.col != lo.col {
513513
// the ^ already takes up one space
514-
let num_squigglies = hi.col.to_usize() - lo.col.to_usize() - 1us;
514+
let num_squigglies = hi.col.to_usize() - lo.col.to_usize() - 1;
515515
for _ in 0..num_squigglies {
516516
s.push('~');
517517
}

src/libsyntax/ext/deriving/generic/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl<'a> MethodDef<'a> {
770770
let mut raw_fields = Vec::new(); // ~[[fields of self],
771771
// [fields of next Self arg], [etc]]
772772
let mut patterns = Vec::new();
773-
for i in 0us..self_args.len() {
773+
for i in 0..self_args.len() {
774774
let struct_path= cx.path(DUMMY_SP, vec!( type_ident ));
775775
let (pat, ident_expr) =
776776
trait_.create_struct_pattern(cx,
@@ -859,8 +859,8 @@ impl<'a> MethodDef<'a> {
859859
/// (&A2(ref __self_0),
860860
/// &A2(ref __arg_1_0)) => (*__self_0).eq(&(*__arg_1_0)),
861861
/// _ => {
862-
/// let __self_vi = match *self { A1(..) => 0us, A2(..) => 1us };
863-
/// let __arg_1_vi = match *__arg_1 { A1(..) => 0us, A2(..) => 1us };
862+
/// let __self_vi = match *self { A1(..) => 0, A2(..) => 1 };
863+
/// let __arg_1_vi = match *__arg_1 { A1(..) => 0, A2(..) => 1 };
864864
/// false
865865
/// }
866866
/// }
@@ -904,8 +904,8 @@ impl<'a> MethodDef<'a> {
904904
/// (Variant2, Variant2, Variant2) => ... // delegate Matching on Variant2
905905
/// ...
906906
/// _ => {
907-
/// let __this_vi = match this { Variant1 => 0us, Variant2 => 1us, ... };
908-
/// let __that_vi = match that { Variant1 => 0us, Variant2 => 1us, ... };
907+
/// let __this_vi = match this { Variant1 => 0, Variant2 => 1, ... };
908+
/// let __that_vi = match that { Variant1 => 0, Variant2 => 1, ... };
909909
/// ... // catch-all remainder can inspect above variant index values.
910910
/// }
911911
/// }
@@ -1067,13 +1067,13 @@ impl<'a> MethodDef<'a> {
10671067
//
10681068
// ```
10691069
// let __self0_vi = match self {
1070-
// A => 0us, B(..) => 1us, C(..) => 2us
1070+
// A => 0, B(..) => 1, C(..) => 2
10711071
// };
10721072
// let __self1_vi = match __arg1 {
1073-
// A => 0us, B(..) => 1us, C(..) => 2us
1073+
// A => 0, B(..) => 1, C(..) => 2
10741074
// };
10751075
// let __self2_vi = match __arg2 {
1076-
// A => 0us, B(..) => 1us, C(..) => 2us
1076+
// A => 0, B(..) => 1, C(..) => 2
10771077
// };
10781078
// ```
10791079
let mut index_let_stmts: Vec<P<ast::Stmt>> = Vec::new();

src/libsyntax/ext/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
362362
// in this file.
363363
// Token-tree macros:
364364
MacInvocTT(pth, tts, _) => {
365-
if pth.segments.len() > 1us {
365+
if pth.segments.len() > 1 {
366366
fld.cx.span_err(pth.span,
367367
"expected macro name without module \
368368
separators");
@@ -931,7 +931,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
931931
},
932932
_ => unreachable!()
933933
};
934-
if pth.segments.len() > 1us {
934+
if pth.segments.len() > 1 {
935935
fld.cx.span_err(pth.span, "expected macro name without module separators");
936936
return DummyResult::raw_pat(span);
937937
}

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
709709
// try removing it when enough of them are gone.
710710

711711
let mut p = cx.new_parser_from_tts(tts);
712-
p.quote_depth += 1us;
712+
p.quote_depth += 1;
713713

714714
let cx_expr = p.parse_expr();
715715
if !p.eat(&token::Comma) {

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
171171
stack: vec![],
172172
top_elts: TtSeq(ms),
173173
sep: sep,
174-
idx: 0us,
174+
idx: 0,
175175
up: None,
176176
matches: matches,
177-
match_lo: 0us,
178-
match_cur: 0us,
177+
match_lo: 0,
178+
match_cur: 0,
179179
match_hi: match_idx_hi,
180180
sp_lo: lo
181181
}
@@ -238,7 +238,7 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
238238
}
239239
}
240240
let mut ret_val = HashMap::new();
241-
let mut idx = 0us;
241+
let mut idx = 0;
242242
for m in ms.iter() { n_rec(p_s, m, res, &mut ret_val, &mut idx) }
243243
ret_val
244244
}
@@ -383,7 +383,7 @@ pub fn parse(sess: &ParseSess,
383383
if seq.op == ast::ZeroOrMore {
384384
let mut new_ei = ei.clone();
385385
new_ei.match_cur += seq.num_captures;
386-
new_ei.idx += 1us;
386+
new_ei.idx += 1;
387387
//we specifically matched zero repeats.
388388
for idx in ei.match_cur..ei.match_cur + seq.num_captures {
389389
(&mut new_ei.matches[idx]).push(Rc::new(MatchedSeq(vec![], sp)));
@@ -398,7 +398,7 @@ pub fn parse(sess: &ParseSess,
398398
cur_eis.push(box MatcherPos {
399399
stack: vec![],
400400
sep: seq.separator.clone(),
401-
idx: 0us,
401+
idx: 0,
402402
matches: matches,
403403
match_lo: ei_t.match_cur,
404404
match_cur: ei_t.match_cur,
@@ -442,20 +442,20 @@ pub fn parse(sess: &ParseSess,
442442

443443
/* error messages here could be improved with links to orig. rules */
444444
if token_name_eq(&tok, &token::Eof) {
445-
if eof_eis.len() == 1us {
445+
if eof_eis.len() == 1 {
446446
let mut v = Vec::new();
447447
for dv in (&mut eof_eis[0]).matches.iter_mut() {
448448
v.push(dv.pop().unwrap());
449449
}
450450
return Success(nameize(sess, ms, &v[]));
451-
} else if eof_eis.len() > 1us {
451+
} else if eof_eis.len() > 1 {
452452
return Error(sp, "ambiguity: multiple successful parses".to_string());
453453
} else {
454454
return Failure(sp, "unexpected end of macro invocation".to_string());
455455
}
456456
} else {
457-
if (bb_eis.len() > 0us && next_eis.len() > 0us)
458-
|| bb_eis.len() > 1us {
457+
if (bb_eis.len() > 0 && next_eis.len() > 0)
458+
|| bb_eis.len() > 1 {
459459
let nts = bb_eis.iter().map(|ei| {
460460
match ei.top_elts.get_tt(ei.idx) {
461461
TtToken(_, MatchNt(bind, name, _, _)) => {
@@ -469,12 +469,12 @@ pub fn parse(sess: &ParseSess,
469469
"local ambiguity: multiple parsing options: \
470470
built-in NTs {} or {} other options.",
471471
nts, next_eis.len()).to_string());
472-
} else if bb_eis.len() == 0us && next_eis.len() == 0us {
472+
} else if bb_eis.len() == 0 && next_eis.len() == 0 {
473473
return Failure(sp, format!("no rules expected the token `{}`",
474474
pprust::token_to_string(&tok)).to_string());
475-
} else if next_eis.len() > 0us {
475+
} else if next_eis.len() > 0 {
476476
/* Now process the next token */
477-
while next_eis.len() > 0us {
477+
while next_eis.len() > 0 {
478478
cur_eis.push(next_eis.pop().unwrap());
479479
}
480480
rdr.next_token();
@@ -488,7 +488,7 @@ pub fn parse(sess: &ParseSess,
488488
let match_cur = ei.match_cur;
489489
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
490490
parse_nt(&mut rust_parser, span, name_string.get()))));
491-
ei.idx += 1us;
491+
ei.idx += 1;
492492
ei.match_cur += 1;
493493
}
494494
_ => panic!()
@@ -501,16 +501,16 @@ pub fn parse(sess: &ParseSess,
501501
}
502502
}
503503

504-
assert!(cur_eis.len() > 0us);
504+
assert!(cur_eis.len() > 0);
505505
}
506506
}
507507

508508
pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal {
509509
match name {
510510
"tt" => {
511-
p.quote_depth += 1us; //but in theory, non-quoted tts might be useful
511+
p.quote_depth += 1; //but in theory, non-quoted tts might be useful
512512
let res = token::NtTT(P(p.parse_token_tree()));
513-
p.quote_depth -= 1us;
513+
p.quote_depth -= 1;
514514
return res;
515515
}
516516
_ => {}

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
223223
r.repeat_len.pop();
224224
}
225225
} else { /* repeat */
226-
*r.repeat_idx.last_mut().unwrap() += 1us;
226+
*r.repeat_idx.last_mut().unwrap() += 1;
227227
r.stack.last_mut().unwrap().idx = 0;
228228
match r.stack.last().unwrap().sep.clone() {
229229
Some(tk) => {

0 commit comments

Comments
 (0)