From 9683745fed09daf7f8acc55d679b41d3bc660ec4 Mon Sep 17 00:00:00 2001 From: Alfie John Date: Wed, 28 Jan 2015 01:01:48 +0000 Subject: Omit integer suffix when unnecessary See PR # 21378 for context --- src/libsyntax/print/pp.rs | 32 +++++++++++----------- src/libsyntax/print/pprust.rs | 62 +++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 47 deletions(-) (limited to 'src/libsyntax/print') diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 70d6a5f695a..707b3c72ecd 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -132,15 +132,15 @@ pub fn buf_str(toks: &[Token], let mut i = left; let mut l = lim; let mut s = string::String::from_str("["); - while i != right && l != 0us { - l -= 1us; + while i != right && l != 0 { + l -= 1; if i != left { s.push_str(", "); } s.push_str(&format!("{}={}", szs[i], tok_str(&toks[i]))[]); - i += 1us; + i += 1; i %= n; } s.push(']'); @@ -326,8 +326,8 @@ impl Printer { if self.scan_stack_empty { self.left_total = 1; self.right_total = 1; - self.left = 0us; - self.right = 0us; + self.left = 0; + self.right = 0; } else { self.advance_right(); } debug!("pp Begin({})/buffer ~[{},{}]", b.offset, self.left, self.right); @@ -355,8 +355,8 @@ impl Printer { if self.scan_stack_empty { self.left_total = 1; self.right_total = 1; - self.left = 0us; - self.right = 0us; + self.left = 0; + self.right = 0; } else { self.advance_right(); } debug!("pp Break({})/buffer ~[{},{}]", b.offset, self.left, self.right); @@ -410,7 +410,7 @@ impl Printer { if self.scan_stack_empty { self.scan_stack_empty = false; } else { - self.top += 1us; + self.top += 1; self.top %= self.buf_len; assert!((self.top != self.bottom)); } @@ -422,7 +422,7 @@ impl Printer { if self.top == self.bottom { self.scan_stack_empty = true; } else { - self.top += self.buf_len - 1us; self.top %= self.buf_len; + self.top += self.buf_len - 1; self.top %= self.buf_len; } return x; } @@ -436,12 +436,12 @@ impl Printer { if self.top == self.bottom { self.scan_stack_empty = true; } else { - self.bottom += 1us; self.bottom %= self.buf_len; + self.bottom += 1; self.bottom %= self.buf_len; } return x; } pub fn advance_right(&mut self) { - self.right += 1us; + self.right += 1; self.right %= self.buf_len; assert!((self.right != self.left)); } @@ -471,7 +471,7 @@ impl Printer { break; } - self.left += 1us; + self.left += 1; self.left %= self.buf_len; left_size = self.size[self.left]; @@ -520,7 +520,7 @@ impl Printer { pub fn get_top(&mut self) -> PrintStackElem { let print_stack = &mut self.print_stack; let n = print_stack.len(); - if n != 0us { + if n != 0 { (*print_stack)[n - 1] } else { PrintStackElem { @@ -565,7 +565,7 @@ impl Printer { Token::End => { debug!("print End -> pop End"); let print_stack = &mut self.print_stack; - assert!((print_stack.len() != 0us)); + assert!((print_stack.len() != 0)); print_stack.pop().unwrap(); Ok(()) } @@ -667,11 +667,11 @@ pub fn spaces(p: &mut Printer, n: usize) -> old_io::IoResult<()> { } pub fn zerobreak(p: &mut Printer) -> old_io::IoResult<()> { - spaces(p, 0us) + spaces(p, 0) } pub fn space(p: &mut Printer) -> old_io::IoResult<()> { - spaces(p, 1us) + spaces(p, 1) } pub fn hardbreak(p: &mut Printer) -> old_io::IoResult<()> { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5367ccc1357..a7ff486c634 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -92,10 +92,10 @@ pub fn rust_printer_annotated<'a>(writer: Box, } #[allow(non_upper_case_globals)] -pub const indent_unit: usize = 4us; +pub const indent_unit: usize = 4; #[allow(non_upper_case_globals)] -pub const default_columns: usize = 78us; +pub const default_columns: usize = 78; /// Requires you to pass an input filename and reader so that /// it can scan the input text for comments and literals to @@ -377,7 +377,7 @@ pub fn block_to_string(blk: &ast::Block) -> String { // containing cbox, will be closed by print-block at } try!(s.cbox(indent_unit)); // head-ibox, will be closed by print-block after { - try!(s.ibox(0us)); + try!(s.ibox(0)); s.print_block(blk) }) } @@ -516,7 +516,7 @@ impl<'a> State<'a> { pub fn bclose_maybe_open (&mut self, span: codemap::Span, indented: usize, close_box: bool) -> IoResult<()> { try!(self.maybe_print_comment(span.hi)); - try!(self.break_offset_if_not_bol(1us, -(indented as isize))); + try!(self.break_offset_if_not_bol(1, -(indented as isize))); try!(word(&mut self.s, "}")); if close_box { try!(self.end()); // close the outer-box @@ -591,7 +591,7 @@ impl<'a> State<'a> { pub fn commasep(&mut self, b: Breaks, elts: &[T], mut op: F) -> IoResult<()> where F: FnMut(&mut State, &T) -> IoResult<()>, { - try!(self.rbox(0us, b)); + try!(self.rbox(0, b)); let mut first = true; for elt in elts.iter() { if first { first = false; } else { try!(self.word_space(",")); } @@ -609,13 +609,13 @@ impl<'a> State<'a> { F: FnMut(&mut State, &T) -> IoResult<()>, G: FnMut(&T) -> codemap::Span, { - try!(self.rbox(0us, b)); + try!(self.rbox(0, b)); let len = elts.len(); - let mut i = 0us; + let mut i = 0; for elt in elts.iter() { try!(self.maybe_print_comment(get_span(elt).hi)); try!(op(self, elt)); - i += 1us; + i += 1; if i < len { try!(word(&mut self.s, ",")); try!(self.maybe_print_trailing_comment(get_span(elt), @@ -660,7 +660,7 @@ impl<'a> State<'a> { pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> { try!(self.maybe_print_comment(ty.span.lo)); - try!(self.ibox(0us)); + try!(self.ibox(0)); match ty.node { ast::TyVec(ref ty) => { try!(word(&mut self.s, "[")); @@ -880,7 +880,7 @@ impl<'a> State<'a> { } ast::ItemTy(ref ty, ref params) => { try!(self.ibox(indent_unit)); - try!(self.ibox(0us)); + try!(self.ibox(0)); try!(self.word_nbsp(&visibility_qualified(item.vis, "type")[])); try!(self.print_ident(item.ident)); try!(self.print_generics(params)); @@ -1277,7 +1277,7 @@ impl<'a> State<'a> { pub fn print_outer_attributes(&mut self, attrs: &[ast::Attribute]) -> IoResult<()> { - let mut count = 0us; + let mut count = 0; for attr in attrs.iter() { match attr.node.style { ast::AttrOuter => { @@ -1295,7 +1295,7 @@ impl<'a> State<'a> { pub fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) -> IoResult<()> { - let mut count = 0us; + let mut count = 0; for attr in attrs.iter() { match attr.node.style { ast::AttrInner => { @@ -1416,8 +1416,8 @@ impl<'a> State<'a> { match _else.node { // "another else-if" ast::ExprIf(ref i, ref then, ref e) => { - try!(self.cbox(indent_unit - 1us)); - try!(self.ibox(0us)); + try!(self.cbox(indent_unit - 1)); + try!(self.ibox(0)); try!(word(&mut self.s, " else if ")); try!(self.print_expr(&**i)); try!(space(&mut self.s)); @@ -1426,8 +1426,8 @@ impl<'a> State<'a> { } // "another else-if-let" ast::ExprIfLet(ref pat, ref expr, ref then, ref e) => { - try!(self.cbox(indent_unit - 1us)); - try!(self.ibox(0us)); + try!(self.cbox(indent_unit - 1)); + try!(self.ibox(0)); try!(word(&mut self.s, " else if let ")); try!(self.print_pat(&**pat)); try!(space(&mut self.s)); @@ -1439,8 +1439,8 @@ impl<'a> State<'a> { } // "final else" ast::ExprBlock(ref b) => { - try!(self.cbox(indent_unit - 1us)); - try!(self.ibox(0us)); + try!(self.cbox(indent_unit - 1)); + try!(self.ibox(0)); try!(word(&mut self.s, " else ")); self.print_block(&**b) } @@ -1606,7 +1606,7 @@ impl<'a> State<'a> { try!(self.print_expr(&*args[0])); try!(word(&mut self.s, ".")); try!(self.print_ident(ident.node)); - if tys.len() > 0us { + if tys.len() > 0 { try!(word(&mut self.s, "::<")); try!(self.commasep(Inconsistent, tys, |s, ty| s.print_type(&**ty))); @@ -1777,7 +1777,7 @@ impl<'a> State<'a> { // containing cbox, will be closed by print-block at } try!(self.cbox(indent_unit)); // head-box, will be closed by print-block after { - try!(self.ibox(0us)); + try!(self.ibox(0)); try!(self.print_block(&**blk)); } ast::ExprAssign(ref lhs, ref rhs) => { @@ -2154,7 +2154,7 @@ impl<'a> State<'a> { }, |f| f.node.pat.span)); if etc { - if fields.len() != 0us { try!(self.word_space(",")); } + if fields.len() != 0 { try!(self.word_space(",")); } try!(word(&mut self.s, "..")); } try!(space(&mut self.s)); @@ -2221,7 +2221,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); } try!(self.cbox(indent_unit)); - try!(self.ibox(0us)); + try!(self.ibox(0)); try!(self.print_outer_attributes(&arm.attrs[])); let mut first = true; for p in arm.pats.iter() { @@ -2307,7 +2307,7 @@ impl<'a> State<'a> { -> IoResult<()> { // It is unfortunate to duplicate the commasep logic, but we want the // self type and the args all in the same box. - try!(self.rbox(0us, Inconsistent)); + try!(self.rbox(0, Inconsistent)); let mut first = true; for &explicit_self in opt_explicit_self.iter() { let m = match explicit_self { @@ -2457,7 +2457,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, "<")); let mut ints = Vec::new(); - for i in 0us..total { + for i in 0..total { ints.push(i); } @@ -2707,7 +2707,7 @@ impl<'a> State<'a> { if span.hi < (*cmnt).pos && (*cmnt).pos < next && span_line.line == comment_line.line { try!(self.print_comment(cmnt)); - self.cur_cmnt_and_lit.cur_cmnt += 1us; + self.cur_cmnt_and_lit.cur_cmnt += 1; } } _ => () @@ -2725,7 +2725,7 @@ impl<'a> State<'a> { match self.next_comment() { Some(ref cmnt) => { try!(self.print_comment(cmnt)); - self.cur_cmnt_and_lit.cur_cmnt += 1us; + self.cur_cmnt_and_lit.cur_cmnt += 1; } _ => break } @@ -2807,7 +2807,7 @@ impl<'a> State<'a> { while self.cur_cmnt_and_lit.cur_lit < lits.len() { let ltrl = (*lits)[self.cur_cmnt_and_lit.cur_lit].clone(); if ltrl.pos > pos { return None; } - self.cur_cmnt_and_lit.cur_lit += 1us; + self.cur_cmnt_and_lit.cur_lit += 1; if ltrl.pos == pos { return Some(ltrl); } } None @@ -2822,7 +2822,7 @@ impl<'a> State<'a> { Some(ref cmnt) => { if (*cmnt).pos < pos { try!(self.print_comment(cmnt)); - self.cur_cmnt_and_lit.cur_cmnt += 1us; + self.cur_cmnt_and_lit.cur_cmnt += 1; } else { break; } } _ => break @@ -2835,7 +2835,7 @@ impl<'a> State<'a> { cmnt: &comments::Comment) -> IoResult<()> { match cmnt.style { comments::Mixed => { - assert_eq!(cmnt.lines.len(), 1us); + assert_eq!(cmnt.lines.len(), 1); try!(zerobreak(&mut self.s)); try!(word(&mut self.s, &cmnt.lines[0][])); zerobreak(&mut self.s) @@ -2854,11 +2854,11 @@ impl<'a> State<'a> { } comments::Trailing => { try!(word(&mut self.s, " ")); - if cmnt.lines.len() == 1us { + if cmnt.lines.len() == 1 { try!(word(&mut self.s, &cmnt.lines[0][])); hardbreak(&mut self.s) } else { - try!(self.ibox(0us)); + try!(self.ibox(0)); for line in cmnt.lines.iter() { if !line.is_empty() { try!(word(&mut self.s, &line[])); -- cgit 1.4.1-3-g733a5