diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/mtwt.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 8 | 
14 files changed, 30 insertions, 30 deletions
| diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 40390765dde..26463df1871 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -429,14 +429,14 @@ pub struct Generics { } impl Generics { - pub fn is_parameterized(&self) -> bool { - self.lifetimes.len() + self.ty_params.len() > 0 - } pub fn is_lt_parameterized(&self) -> bool { - self.lifetimes.len() > 0 + !self.lifetimes.is_empty() } pub fn is_type_parameterized(&self) -> bool { - self.ty_params.len() > 0 + !self.ty_params.is_empty() + } + pub fn is_parameterized(&self) -> bool { + self.is_lt_parameterized() || self.is_type_parameterized() } } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index f024a3139a6..a0bde8f6c52 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -360,7 +360,7 @@ impl Encodable for FileMap { // store the length try! { s.emit_u32(lines.len() as u32) }; - if lines.len() > 0 { + if !lines.is_empty() { // In order to preserve some space, we exploit the fact that // the lines list is sorted and individual lines are // probably not that long. Because of that we can store lines @@ -569,7 +569,7 @@ impl CodeMap { // accidentally overflowing into the next filemap in case the last byte // of span is also the last byte of filemap, which leads to incorrect // results from CodeMap.span_to_*. - if src.len() > 0 && !src.ends_with("\n") { + if !src.is_empty() && !src.ends_with("\n") { src.push('\n'); } @@ -808,7 +808,7 @@ impl CodeMap { loop { let lines = files[a].lines.borrow(); let lines = lines; - if lines.len() > 0 { + if !lines.is_empty() { break; } if a == 0 { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index f2b45d89f73..69159690328 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -90,7 +90,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) p.token != token::Colon && p.token != token::ModSep { - if outputs.len() != 0 { + if !outputs.is_empty() { panictry!(p.eat(&token::Comma)); } @@ -130,7 +130,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) p.token != token::Colon && p.token != token::ModSep { - if inputs.len() != 0 { + if !inputs.is_empty() { panictry!(p.eat(&token::Comma)); } @@ -154,7 +154,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) p.token != token::Colon && p.token != token::ModSep { - if clobs.len() != 0 { + if !clobs.is_empty() { panictry!(p.eat(&token::Comma)); } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 9994fad3e31..9e36c75dda4 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -774,7 +774,7 @@ pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree], name: &str) { - if tts.len() != 0 { + if !tts.is_empty() { cx.span_err(sp, &format!("{} takes no arguments", name)); } } diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index f89f3ab55f3..95eb68ca0d3 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -89,7 +89,7 @@ fn cs_clone( } } - if all_fields.len() >= 1 && all_fields[0].name.is_none() { + if !all_fields.is_empty() && all_fields[0].name.is_none() { // enum-like let subcalls = all_fields.iter().map(subcall).collect(); let path = cx.expr_path(ctor_path); diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 06255f46779..6425e6a28ec 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -240,7 +240,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, let encoder = cx.expr_ident(trait_span, blkarg); let emit_variant_arg = cx.ident_of("emit_enum_variant_arg"); let mut stmts = Vec::new(); - if fields.len() > 0 { + if !fields.is_empty() { let last = fields.len() - 1; for (i, &FieldInfo { ref self_, span, .. }) in fields.iter().enumerate() { let enc = cx.expr_method_call(span, self_.clone(), diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index dcfc6b675e3..7f6f29df530 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -912,7 +912,7 @@ impl<'a> MethodDef<'a> { } // transpose raw_fields - let fields = if raw_fields.len() > 0 { + let fields = if !raw_fields.is_empty() { let mut raw_fields = raw_fields.into_iter().map(|v| v.into_iter()); let first_field = raw_fields.next().unwrap(); let mut other_fields: Vec<vec::IntoIter<(Span, Option<Ident>, P<Expr>)>> diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 374f6fa5040..4fe5ab15545 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -688,7 +688,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, loop { match parser.next() { Some(piece) => { - if parser.errors.len() > 0 { break } + if !parser.errors.is_empty() { break } cx.verify_piece(&piece); match cx.trans_piece(&piece) { Some(piece) => { diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index f514f72d565..ce83b84efee 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -266,7 +266,7 @@ pub fn outer_mark(ctxt: SyntaxContext) -> Mrk { /// Push a name... unless it matches the one on top, in which /// case pop and discard (so two of the same marks cancel) fn xor_push(marks: &mut Vec<Mrk>, mark: Mrk) { - if (marks.len() > 0) && (*marks.last().unwrap() == mark) { + if (!marks.is_empty()) && (*marks.last().unwrap() == mark) { marks.pop().unwrap(); } else { marks.push(mark); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index dcbf3c2c892..9c3a556b210 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -457,7 +457,7 @@ pub fn parse(sess: &ParseSess, return Failure(sp, "unexpected end of macro invocation".to_string()); } } else { - if (bb_eis.len() > 0 && next_eis.len() > 0) + if (!bb_eis.is_empty() && !next_eis.is_empty()) || bb_eis.len() > 1 { let nts = bb_eis.iter().map(|ei| { match ei.top_elts.get_tt(ei.idx) { @@ -475,9 +475,9 @@ pub fn parse(sess: &ParseSess, } else if bb_eis.is_empty() && next_eis.is_empty() { return Failure(sp, format!("no rules expected the token `{}`", pprust::token_to_string(&tok)).to_string()); - } else if next_eis.len() > 0 { + } else if !next_eis.is_empty() { /* Now process the next token */ - while next_eis.len() > 0 { + while !next_eis.is_empty() { cur_eis.push(next_eis.pop().unwrap()); } rdr.next_token(); @@ -504,7 +504,7 @@ pub fn parse(sess: &ParseSess, } } - assert!(cur_eis.len() > 0); + assert!(!cur_eis.is_empty()); } } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 277f5365db3..bda01d5a654 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -63,7 +63,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { let mut i = 0; let mut j = lines.len(); // first line of all-stars should be omitted - if lines.len() > 0 && + if !lines.is_empty() && lines[0].chars().all(|c| c == '*') { i += 1; } @@ -294,7 +294,7 @@ fn read_block_comment(rdr: &mut StringReader, } } } - if curr_line.len() != 0 { + if !curr_line.is_empty() { trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fe5fbdccf61..071e5a69240 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2254,7 +2254,7 @@ impl<'a> Parser<'a> { (Vec::new(), Vec::new(), Vec::new()) }; - if bindings.len() > 0 { + if !bindings.is_empty() { let last_span = self.last_span; self.span_err(last_span, "type bindings are only permitted on trait paths"); } @@ -3024,7 +3024,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::Comma)); if self.token == token::CloseDelim(token::Bracket) - && (before_slice || after.len() != 0) { + && (before_slice || !after.is_empty()) { break } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index ebfd970f3db..3fd4e31b477 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -565,7 +565,7 @@ impl<'a> Printer<'a> { Token::End => { debug!("print End -> pop End"); let print_stack = &mut self.print_stack; - assert!((print_stack.len() != 0)); + assert!((!print_stack.is_empty())); print_stack.pop().unwrap(); Ok(()) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0e9b471393b..c51b5d03978 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1656,7 +1656,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() > 0 { + if !tys.is_empty() { try!(word(&mut self.s, "::<")); try!(self.commasep(Inconsistent, tys, |s, ty| s.print_type(&**ty))); @@ -1956,7 +1956,7 @@ impl<'a> State<'a> { options.push("intel"); } - if options.len() > 0 { + if !options.is_empty() { try!(space(&mut self.s)); try!(self.word_space(":")); try!(self.commasep(Inconsistent, &*options, @@ -2214,7 +2214,7 @@ impl<'a> State<'a> { }, |f| f.node.pat.span)); if etc { - if fields.len() != 0 { try!(self.word_space(",")); } + if !fields.is_empty() { try!(self.word_space(",")); } try!(word(&mut self.s, "..")); } try!(space(&mut self.s)); @@ -2727,7 +2727,7 @@ impl<'a> State<'a> { opt_explicit_self: Option<&ast::ExplicitSelf_>) -> io::Result<()> { try!(self.ibox(indent_unit)); - if generics.lifetimes.len() > 0 || generics.ty_params.len() > 0 { + if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() { try!(word(&mut self.s, "for")); try!(self.print_generics(generics)); } | 
