diff options
| author | Tamir Duberstein <tamird@gmail.com> | 2015-03-24 16:53:34 -0700 |
|---|---|---|
| committer | Tamir Duberstein <tamird@gmail.com> | 2015-04-14 20:26:03 -0700 |
| commit | 29ac04402d53d358a1f6200bea45a301ff05b2d1 (patch) | |
| tree | b54ff9c5f2b99a0197147875cf3c5377d8a09cf4 /src/libsyntax | |
| parent | 16e1fcead14628701e1b10b9d00c898d748db2ed (diff) | |
| download | rust-29ac04402d53d358a1f6200bea45a301ff05b2d1.tar.gz rust-29ac04402d53d358a1f6200bea45a301ff05b2d1.zip | |
Positive case of `len()` -> `is_empty()`
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/env.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 |
7 files changed, 14 insertions, 14 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 5bbf79d0477..f024a3139a6 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -652,7 +652,7 @@ impl CodeMap { } pub fn span_to_string(&self, sp: Span) -> String { - if self.files.borrow().len() == 0 && sp == DUMMY_SP { + if self.files.borrow().is_empty() && sp == DUMMY_SP { return "no-location".to_string(); } diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index ac96375095e..dcfc6b675e3 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -1248,7 +1248,7 @@ impl<'a> MethodDef<'a> { match_arms.push(catch_all_match_arm); - } else if variants.len() == 0 { + } else if variants.is_empty() { // As an additional wrinkle, For a zero-variant enum A, // currently the compiler // will accept `fn (a: &Self) { match *a { } }` diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index f72303985e7..2ca74644b3b 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -65,7 +65,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult+'cx> { let mut exprs = match get_exprs_from_tts(cx, sp, tts) { - Some(ref exprs) if exprs.len() == 0 => { + Some(ref exprs) if exprs.is_empty() => { cx.span_err(sp, "env! takes 1 or 2 arguments"); return DummyResult::expr(sp); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b65798b8a49..74ec219af15 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -841,7 +841,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm { // expand pats... they might contain macro uses: let expanded_pats = arm.pats.move_map(|pat| fld.fold_pat(pat)); - if expanded_pats.len() == 0 { + if expanded_pats.is_empty() { panic!("encountered match arm with 0 patterns"); } // all of the pats must have the same set of bindings, so use the @@ -1887,7 +1887,7 @@ mod test { let binding_name = mtwt::resolve(bindings[binding_idx]); let binding_marks = mtwt::marksof(bindings[binding_idx].ctxt, invalid_name); // shouldmatch can't name varrefs that don't exist: - assert!((shouldmatch.len() == 0) || + assert!((shouldmatch.is_empty()) || (varrefs.len() > *shouldmatch.iter().max().unwrap())); for (idx,varref) in varrefs.iter().enumerate() { let print_hygiene_debug_info = || { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 4e0b74401a2..dcbf3c2c892 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -472,7 +472,7 @@ pub fn parse(sess: &ParseSess, "local ambiguity: multiple parsing options: \ built-in NTs {} or {} other options.", nts, next_eis.len()).to_string()); - } else if bb_eis.len() == 0 && next_eis.len() == 0 { + } 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 { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e45b7c1df91..fe5fbdccf61 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -449,7 +449,7 @@ impl<'a> Parser<'a> { (format!("expected one of {}, found `{}`", expect, actual)) - } else if expected.len() == 0 { + } else if expected.is_empty() { (format!("unexpected token: `{}`", actual)) } else { @@ -1244,7 +1244,7 @@ impl<'a> Parser<'a> { // In type grammar, `+` is treated like a binary operator, // and hence both L and R side are required. - if bounds.len() == 0 { + if bounds.is_empty() { let last_span = self.last_span; self.span_err(last_span, "at least one type parameter bound \ @@ -2191,7 +2191,7 @@ impl<'a> Parser<'a> { &[token::CloseDelim(token::Brace)])); } - if fields.len() == 0 && base.is_none() { + if fields.is_empty() && base.is_none() { let last_span = self.last_span; self.span_err(last_span, "structure literal must either \ @@ -3914,7 +3914,7 @@ impl<'a> Parser<'a> { let hi = self.span.hi; let span = mk_sp(lo, hi); - if bounds.len() == 0 { + if bounds.is_empty() { self.span_err(span, "each predicate in a `where` clause must have \ at least one bound in it"); @@ -4572,7 +4572,7 @@ impl<'a> Parser<'a> { fields.push(try!(self.parse_struct_decl_field(true))); } - if fields.len() == 0 { + if fields.is_empty() { return Err(self.fatal(&format!("unit-like struct definition should be \ written as `struct {};`", token::get_ident(class_name.clone())))); @@ -4611,7 +4611,7 @@ impl<'a> Parser<'a> { Ok(spanned(lo, p.span.hi, struct_field_)) })); - if fields.len() == 0 { + if fields.is_empty() { return Err(self.fatal(&format!("unit-like struct definition should be \ written as `struct {};`", token::get_ident(class_name.clone())))); @@ -5023,7 +5023,7 @@ impl<'a> Parser<'a> { all_nullary = false; let start_span = self.span; let struct_def = try!(self.parse_struct_def()); - if struct_def.fields.len() == 0 { + if struct_def.fields.is_empty() { self.span_err(start_span, &format!("unit-like struct variant should be written \ without braces, as `{},`", diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3f883fb1172..0e9b471393b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2546,7 +2546,7 @@ impl<'a> State<'a> { pub fn print_where_clause(&mut self, where_clause: &ast::WhereClause) -> io::Result<()> { - if where_clause.predicates.len() == 0 { + if where_clause.predicates.is_empty() { return Ok(()) } |
