Skip to content

Commit 0a2ce4b

Browse files
committed
s/([^\(\s]+\.)len\(\) != 0/!$1is_empty()/g
1 parent 74590be commit 0a2ce4b

File tree

14 files changed

+19
-19
lines changed

14 files changed

+19
-19
lines changed

src/libfmt_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ mod tests {
463463
fn musterr(s: &str) {
464464
let mut p = Parser::new(s);
465465
p.next();
466-
assert!(p.errors.len() != 0);
466+
assert!(!p.errors.is_empty());
467467
}
468468

469469
#[test]

src/librustc/middle/infer/combine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ pub fn super_tys<'tcx, C>(this: &C,
589589
.map(|(a, b)| this.tys(*a, *b))
590590
.collect::<Result<_, _>>()
591591
.map(|ts| ty::mk_tup(tcx, ts))
592-
} else if as_.len() != 0 && bs.len() != 0 {
592+
} else if !as_.is_empty() && !bs.is_empty() {
593593
Err(ty::terr_tuple_size(
594594
expected_found(this, as_.len(), bs.len())))
595595
} else {

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3698,7 +3698,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
36983698
res = res | TC::OwnsDtor;
36993699
}
37003700

3701-
if variants.len() != 0 {
3701+
if !variants.is_empty() {
37023702
let repr_hints = lookup_repr_hints(cx, did);
37033703
if repr_hints.len() > 1 {
37043704
// this is an error later on, but this type isn't safe

src/librustc_trans/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
27972797
ccx.sess().bug("struct variant kind unexpected in get_item_val")
27982798
}
27992799
};
2800-
assert!(args.len() != 0);
2800+
assert!(!args.is_empty());
28012801
let ty = ty::node_id_to_type(ccx.tcx(), id);
28022802
let parent = ccx.tcx().map.get_parent(id);
28032803
let enm = ccx.tcx().map.expect_item(parent);

src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ fn compute_object_lifetime_bound<'tcx>(
18501850
"only a single explicit lifetime bound is permitted");
18511851
}
18521852

1853-
if explicit_region_bounds.len() != 0 {
1853+
if !explicit_region_bounds.is_empty() {
18541854
// Explicitly specified region bound. Use that.
18551855
let r = explicit_region_bounds[0];
18561856
return ast_region_to_region(tcx, r);

src/libstd/old_io/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl<T: Iterator<Item=u8>> Reader for IterReader<T> {
313313
*slot = elt;
314314
len += 1;
315315
}
316-
if len == 0 && buf.len() != 0 {
316+
if len == 0 && !buf.is_empty() {
317317
Err(old_io::standard_error(old_io::EndOfFile))
318318
} else {
319319
Ok(len)

src/libsyntax/ext/asm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
9090
p.token != token::Colon &&
9191
p.token != token::ModSep {
9292

93-
if outputs.len() != 0 {
93+
if !outputs.is_empty() {
9494
p.eat(&token::Comma);
9595
}
9696

@@ -130,7 +130,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
130130
p.token != token::Colon &&
131131
p.token != token::ModSep {
132132

133-
if inputs.len() != 0 {
133+
if !inputs.is_empty() {
134134
p.eat(&token::Comma);
135135
}
136136

@@ -154,7 +154,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
154154
p.token != token::Colon &&
155155
p.token != token::ModSep {
156156

157-
if clobs.len() != 0 {
157+
if !clobs.is_empty() {
158158
p.eat(&token::Comma);
159159
}
160160

src/libsyntax/ext/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ pub fn check_zero_tts(cx: &ExtCtxt,
782782
sp: Span,
783783
tts: &[ast::TokenTree],
784784
name: &str) {
785-
if tts.len() != 0 {
785+
if !tts.is_empty() {
786786
cx.span_err(sp, &format!("{} takes no arguments", name));
787787
}
788788
}

src/libsyntax/parse/lexer/comments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn read_block_comment(rdr: &mut StringReader,
294294
}
295295
}
296296
}
297-
if curr_line.len() != 0 {
297+
if !curr_line.is_empty() {
298298
trim_whitespace_prefix_and_push_line(&mut lines,
299299
curr_line,
300300
col);

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,7 @@ impl<'a> Parser<'a> {
30053005
self.expect(&token::Comma);
30063006

30073007
if self.token == token::CloseDelim(token::Bracket)
3008-
&& (before_slice || after.len() != 0) {
3008+
&& (before_slice || !after.is_empty()) {
30093009
break
30103010
}
30113011
}

src/libsyntax/print/pp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl<'a> Printer<'a> {
565565
Token::End => {
566566
debug!("print End -> pop End");
567567
let print_stack = &mut self.print_stack;
568-
assert!((print_stack.len() != 0));
568+
assert!((!print_stack.is_empty()));
569569
print_stack.pop().unwrap();
570570
Ok(())
571571
}

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ impl<'a> State<'a> {
22052205
},
22062206
|f| f.node.pat.span));
22072207
if etc {
2208-
if fields.len() != 0 { try!(self.word_space(",")); }
2208+
if !fields.is_empty() { try!(self.word_space(",")); }
22092209
try!(word(&mut self.s, ".."));
22102210
}
22112211
try!(space(&mut self.s));

src/libtest/stats.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,17 @@ impl<T: Float + FromPrimitive> Stats<T> for [T] {
196196
}
197197

198198
fn min(&self) -> T {
199-
assert!(self.len() != 0);
199+
assert!(!self.is_empty());
200200
self.iter().fold(self[0], |p, q| p.min(*q))
201201
}
202202

203203
fn max(&self) -> T {
204-
assert!(self.len() != 0);
204+
assert!(!self.is_empty());
205205
self.iter().fold(self[0], |p, q| p.max(*q))
206206
}
207207

208208
fn mean(&self) -> T {
209-
assert!(self.len() != 0);
209+
assert!(!self.is_empty());
210210
self.sum() / FromPrimitive::from_usize(self.len()).unwrap()
211211
}
212212

@@ -284,7 +284,7 @@ impl<T: Float + FromPrimitive> Stats<T> for [T] {
284284
// linear interpolation. If samples are not sorted, return nonsensical value.
285285
fn percentile_of_sorted<T: Float + FromPrimitive>(sorted_samples: &[T],
286286
pct: T) -> T {
287-
assert!(sorted_samples.len() != 0);
287+
assert!(!sorted_samples.is_empty());
288288
if sorted_samples.len() == 1 {
289289
return sorted_samples[0];
290290
}

src/test/bench/shootout-k-nucleotide.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn generate_frequencies(mut input: &[u8], frame: usize) -> Table {
252252
}
253253
frequencies.lookup(code, BumpCallback);
254254

255-
while input.len() != 0 && input[0] != ('>' as u8) {
255+
while !input.is_empty() && input[0] != ('>' as u8) {
256256
code = code.rotate(input[0], frame);
257257
frequencies.lookup(code, BumpCallback);
258258
input = &input[1..];

0 commit comments

Comments
 (0)