Positive case of len()
-> is_empty()
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
This commit is contained in:
parent
16e1fcead1
commit
29ac04402d
@ -864,7 +864,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
if !failed && rest.len() == 0 {
|
||||
if !failed && rest.is_empty() {
|
||||
i += 1;
|
||||
}
|
||||
if i == num_check_lines {
|
||||
@ -1662,7 +1662,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
|
||||
// codegen tests (vs. clang)
|
||||
|
||||
fn append_suffix_to_stem(p: &Path, suffix: &str) -> PathBuf {
|
||||
if suffix.len() == 0 {
|
||||
if suffix.is_empty() {
|
||||
p.to_path_buf()
|
||||
} else {
|
||||
let mut stem = p.file_stem().unwrap().to_os_string();
|
||||
|
@ -3788,7 +3788,7 @@ its type parameters are types:
|
||||
|
||||
```ignore
|
||||
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
|
||||
if xs.len() == 0 {
|
||||
if xs.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
let first: B = f(xs[0].clone());
|
||||
|
@ -692,7 +692,7 @@ mod stack {
|
||||
// We've reached the root, so no matter what, we're done. We manually
|
||||
// access the root via the tree itself to avoid creating any dangling
|
||||
// pointers.
|
||||
if self.map.root.len() == 0 && !self.map.root.is_leaf() {
|
||||
if self.map.root.is_empty() && !self.map.root.is_leaf() {
|
||||
// We've emptied out the root, so make its only child the new root.
|
||||
// If it's a leaf, we just let it become empty.
|
||||
self.map.depth -= 1;
|
||||
|
@ -1097,7 +1097,7 @@ impl<K, V> Node<K, V> {
|
||||
/// When a node has no keys or values and only a single edge, extract that edge.
|
||||
pub fn hoist_lone_child(&mut self) {
|
||||
// Necessary for correctness, but in a private module
|
||||
debug_assert!(self.len() == 0);
|
||||
debug_assert!(self.is_empty());
|
||||
debug_assert!(!self.is_leaf());
|
||||
|
||||
unsafe {
|
||||
|
@ -204,7 +204,7 @@ impl<T> SliceExt for [T] {
|
||||
|
||||
#[inline]
|
||||
fn first(&self) -> Option<&T> {
|
||||
if self.len() == 0 { None } else { Some(&self[0]) }
|
||||
if self.is_empty() { None } else { Some(&self[0]) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -217,7 +217,7 @@ impl<T> SliceExt for [T] {
|
||||
|
||||
#[inline]
|
||||
fn last(&self) -> Option<&T> {
|
||||
if self.len() == 0 { None } else { Some(&self[self.len() - 1]) }
|
||||
if self.is_empty() { None } else { Some(&self[self.len() - 1]) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -296,7 +296,7 @@ impl<T> SliceExt for [T] {
|
||||
|
||||
#[inline]
|
||||
fn first_mut(&mut self) -> Option<&mut T> {
|
||||
if self.len() == 0 { None } else { Some(&mut self[0]) }
|
||||
if self.is_empty() { None } else { Some(&mut self[0]) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -1306,7 +1306,7 @@ impl<'a, T> Iterator for Chunks<'a, T> {
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a [T]> {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let chunksz = cmp::min(self.v.len(), self.size);
|
||||
@ -1318,7 +1318,7 @@ impl<'a, T> Iterator for Chunks<'a, T> {
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
(0, Some(0))
|
||||
} else {
|
||||
let n = self.v.len() / self.size;
|
||||
@ -1333,7 +1333,7 @@ impl<'a, T> Iterator for Chunks<'a, T> {
|
||||
impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a [T]> {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let remainder = self.v.len() % self.size;
|
||||
@ -1384,7 +1384,7 @@ impl<'a, T> Iterator for ChunksMut<'a, T> {
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a mut [T]> {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let sz = cmp::min(self.v.len(), self.chunk_size);
|
||||
@ -1397,7 +1397,7 @@ impl<'a, T> Iterator for ChunksMut<'a, T> {
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
(0, Some(0))
|
||||
} else {
|
||||
let n = self.v.len() / self.chunk_size;
|
||||
@ -1412,7 +1412,7 @@ impl<'a, T> Iterator for ChunksMut<'a, T> {
|
||||
impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a mut [T]> {
|
||||
if self.v.len() == 0 {
|
||||
if self.v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let remainder = self.v.len() % self.chunk_size;
|
||||
|
@ -1119,7 +1119,7 @@ enum OldSearcher {
|
||||
impl OldSearcher {
|
||||
#[allow(dead_code)]
|
||||
fn new(haystack: &[u8], needle: &[u8]) -> OldSearcher {
|
||||
if needle.len() == 0 {
|
||||
if needle.is_empty() {
|
||||
// Handle specially
|
||||
unimplemented!()
|
||||
// FIXME: Tune this.
|
||||
|
@ -457,7 +457,7 @@ fn str_search_step<F, G>(mut m: &mut StrSearcher,
|
||||
{
|
||||
if m.state.done() {
|
||||
SearchStep::Done
|
||||
} else if m.needle.len() == 0 && m.start <= m.end {
|
||||
} else if m.needle.is_empty() && m.start <= m.end {
|
||||
// Case for needle == ""
|
||||
if let State::Reject(a, b) = m.state.take() {
|
||||
SearchStep::Reject(a, b)
|
||||
|
@ -45,7 +45,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<String>) {
|
||||
return (dirs, None);
|
||||
}
|
||||
mods.map(|m| { for s in m.split(',') {
|
||||
if s.len() == 0 { continue }
|
||||
if s.is_empty() { continue }
|
||||
let mut parts = s.split('=');
|
||||
let (log_level, name) = match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) {
|
||||
(Some(part0), None, None) => {
|
||||
|
@ -80,7 +80,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
|
||||
(None, Some(sess)) => sess.err(s),
|
||||
}
|
||||
};
|
||||
if s.len() == 0 {
|
||||
if s.is_empty() {
|
||||
say("crate name must not be empty");
|
||||
}
|
||||
for c in s.chars() {
|
||||
|
@ -767,7 +767,7 @@ pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::Nod
|
||||
get_type(cdata, field_ty.id.node, tcx).ty
|
||||
})
|
||||
.collect();
|
||||
let arg_names = if arg_names.len() == 0 { None } else { Some(arg_names) };
|
||||
let arg_names = if arg_names.is_empty() { None } else { Some(arg_names) };
|
||||
|
||||
(None, arg_tys, arg_names)
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
|
||||
|
||||
debug!("found dylib deps: {}", formats.as_str_slice());
|
||||
for spec in formats.as_str_slice().split(',') {
|
||||
if spec.len() == 0 { continue }
|
||||
if spec.is_empty() { continue }
|
||||
let cnum = spec.split(':').nth(0).unwrap();
|
||||
let link = spec.split(':').nth(1).unwrap();
|
||||
let cnum: ast::CrateNum = cnum.parse().unwrap();
|
||||
|
@ -1751,7 +1751,7 @@ fn encode_codemap(ecx: &EncodeContext, rbml_w: &mut Encoder) {
|
||||
|
||||
for filemap in &codemap.files.borrow()[..] {
|
||||
|
||||
if filemap.lines.borrow().len() == 0 || filemap.is_imported() {
|
||||
if filemap.lines.borrow().is_empty() || filemap.is_imported() {
|
||||
// No need to export empty filemaps, as they can't contain spans
|
||||
// that need translation.
|
||||
// Also no need to re-export imported filemaps, as any downstream
|
||||
|
@ -517,7 +517,7 @@ impl<'a> Context<'a> {
|
||||
// library's metadata sections. In theory we should
|
||||
// read both, but reading dylib metadata is quite
|
||||
// slow.
|
||||
if m.len() == 0 {
|
||||
if m.is_empty() {
|
||||
return None
|
||||
} else if m.len() == 1 {
|
||||
return Some(m.into_iter().next().unwrap())
|
||||
|
@ -239,7 +239,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
|
||||
if let Some(DefLocal(_)) = def {
|
||||
if ty::enum_variants(cx.tcx, def_id).iter().any(|variant|
|
||||
token::get_name(variant.name) == token::get_name(ident.node.name)
|
||||
&& variant.args.len() == 0
|
||||
&& variant.args.is_empty()
|
||||
) {
|
||||
span_warn!(cx.tcx.sess, p.span, E0170,
|
||||
"pattern binding `{}` is named the same as one \
|
||||
@ -636,19 +636,19 @@ fn is_useful(cx: &MatchCheckCtxt,
|
||||
-> Usefulness {
|
||||
let &Matrix(ref rows) = matrix;
|
||||
debug!("{:?}", matrix);
|
||||
if rows.len() == 0 {
|
||||
if rows.is_empty() {
|
||||
return match witness {
|
||||
ConstructWitness => UsefulWithWitness(vec!()),
|
||||
LeaveOutWitness => Useful
|
||||
};
|
||||
}
|
||||
if rows[0].len() == 0 {
|
||||
if rows[0].is_empty() {
|
||||
return NotUseful;
|
||||
}
|
||||
assert!(rows.iter().all(|r| r.len() == v.len()));
|
||||
let real_pat = match rows.iter().find(|r| (*r)[0].id != DUMMY_NODE_ID) {
|
||||
Some(r) => raw_pat(r[0]),
|
||||
None if v.len() == 0 => return NotUseful,
|
||||
None if v.is_empty() => return NotUseful,
|
||||
None => v[0]
|
||||
};
|
||||
let left_ty = if real_pat.id == DUMMY_NODE_ID {
|
||||
|
@ -1241,7 +1241,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||
let lifetimes =
|
||||
path.segments.last().unwrap().parameters.lifetimes();
|
||||
let mut insert = Vec::new();
|
||||
if lifetimes.len() == 0 {
|
||||
if lifetimes.is_empty() {
|
||||
let anon = self.cur_anon.get();
|
||||
for (i, a) in (anon..anon+expected).enumerate() {
|
||||
if anon_nums.contains(&a) {
|
||||
@ -1361,7 +1361,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||
|
||||
ast::AngleBracketedParameters(ref data) => {
|
||||
let mut new_lts = Vec::new();
|
||||
if data.lifetimes.len() == 0 {
|
||||
if data.lifetimes.is_empty() {
|
||||
// traverse once to see if there's a need to insert lifetime
|
||||
let need_insert = (0..expected).any(|i| {
|
||||
indexes.contains(&i)
|
||||
|
@ -88,7 +88,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
|
||||
Err(_) => "/tmp/constraints.node%.dot".to_string(),
|
||||
};
|
||||
|
||||
if output_template.len() == 0 {
|
||||
if output_template.is_empty() {
|
||||
tcx.sess.bug("empty string provided as RUST_REGION_GRAPH");
|
||||
}
|
||||
|
||||
|
@ -716,7 +716,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
None => {
|
||||
// Vanilla 'break' or 'loop', so use the enclosing
|
||||
// loop scope
|
||||
if self.loop_scope.len() == 0 {
|
||||
if self.loop_scope.is_empty() {
|
||||
self.ir.tcx.sess.span_bug(sp, "break outside loop");
|
||||
} else {
|
||||
*self.loop_scope.last().unwrap()
|
||||
@ -1586,7 +1586,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
|
||||
fn should_warn(&self, var: Variable) -> Option<String> {
|
||||
let name = self.ir.variable_name(var);
|
||||
if name.len() == 0 || name.as_bytes()[0] == ('_' as u8) {
|
||||
if name.is_empty() || name.as_bytes()[0] == ('_' as u8) {
|
||||
None
|
||||
} else {
|
||||
Some(name)
|
||||
|
@ -361,7 +361,7 @@ impl<T> VecPerParamSpace<T> {
|
||||
pub fn get_self<'a>(&'a self) -> Option<&'a T> {
|
||||
let v = self.get_slice(SelfSpace);
|
||||
assert!(v.len() <= 1);
|
||||
if v.len() == 0 { None } else { Some(&v[0]) }
|
||||
if v.is_empty() { None } else { Some(&v[0]) }
|
||||
}
|
||||
|
||||
pub fn len(&self, space: ParamSpace) -> usize {
|
||||
|
@ -298,7 +298,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
self.predicates.len(),
|
||||
errors.len());
|
||||
|
||||
if errors.len() == 0 {
|
||||
if errors.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(errors)
|
||||
|
@ -698,7 +698,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// is checked for in `evaluate_stack` (and hence users
|
||||
// who might care about this case, like coherence, should use
|
||||
// that function).
|
||||
if candidates.len() == 0 {
|
||||
if candidates.is_empty() {
|
||||
return Err(Unimplemented);
|
||||
}
|
||||
|
||||
@ -873,7 +873,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
try!(self.assemble_candidates_from_caller_bounds(stack, &mut candidates));
|
||||
// Default implementations have lower priority, so we only
|
||||
// consider triggering a default if there is no other impl that can apply.
|
||||
if candidates.vec.len() == 0 {
|
||||
if candidates.vec.is_empty() {
|
||||
try!(self.assemble_candidates_from_default_impls(obligation, &mut candidates));
|
||||
}
|
||||
debug!("candidate list size: {}", candidates.vec.len());
|
||||
|
@ -3036,7 +3036,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
|
||||
}
|
||||
|
||||
fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool {
|
||||
bounds.len() == 0 ||
|
||||
bounds.is_empty() ||
|
||||
bounds[1..].iter().enumerate().all(
|
||||
|(index, bound)| bounds[index].sort_key() <= bound.sort_key())
|
||||
}
|
||||
@ -3687,7 +3687,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
||||
if variants.len() == 2 {
|
||||
let mut data_idx = 0;
|
||||
|
||||
if variants[0].args.len() == 0 {
|
||||
if variants[0].args.is_empty() {
|
||||
data_idx = 1;
|
||||
}
|
||||
|
||||
@ -4200,10 +4200,10 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty_enum(did, _) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
if variants.len() == 0 {
|
||||
if variants.is_empty() {
|
||||
false
|
||||
} else {
|
||||
variants.iter().all(|v| v.args.len() == 0)
|
||||
variants.iter().all(|v| v.args.is_empty())
|
||||
}
|
||||
}
|
||||
_ => false
|
||||
|
@ -902,7 +902,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
};
|
||||
output_types.sort();
|
||||
output_types.dedup();
|
||||
if output_types.len() == 0 {
|
||||
if output_types.is_empty() {
|
||||
output_types.push(OutputTypeExe);
|
||||
}
|
||||
|
||||
|
@ -1269,7 +1269,7 @@ impl<'tcx, T> UserString<'tcx> for ty::Binder<T>
|
||||
let names: Vec<_> = names.iter().map(|s| &s[..]).collect();
|
||||
|
||||
let value_str = unbound_value.user_string(tcx);
|
||||
if names.len() == 0 {
|
||||
if names.is_empty() {
|
||||
value_str
|
||||
} else {
|
||||
format!("for<{}> {}", names.connect(","), value_str)
|
||||
|
@ -887,9 +887,9 @@ pub fn collect_crate_types(session: &Session,
|
||||
// command line, then reuse the empty `base` Vec to hold the types that
|
||||
// will be found in crate attributes.
|
||||
let mut base = session.opts.crate_types.clone();
|
||||
if base.len() == 0 {
|
||||
if base.is_empty() {
|
||||
base.extend(attr_types.into_iter());
|
||||
if base.len() == 0 {
|
||||
if base.is_empty() {
|
||||
base.push(link::default_output_for_target(session));
|
||||
}
|
||||
base.sort();
|
||||
|
@ -425,7 +425,7 @@ impl RustcDefaultCalls {
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>)
|
||||
-> Compilation {
|
||||
if sess.opts.prints.len() == 0 {
|
||||
if sess.opts.prints.is_empty() {
|
||||
return Compilation::Continue;
|
||||
}
|
||||
|
||||
|
@ -676,7 +676,7 @@ fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||
};
|
||||
|
||||
match code {
|
||||
_ if variants.len() == 0 => {
|
||||
_ if variants.is_empty() => {
|
||||
let r = dot::render(&lcfg, &mut out);
|
||||
return expand_err_details(r);
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
f.name
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
if fields.len() == 0 {
|
||||
if fields.is_empty() {
|
||||
child_name_bindings.define_value(def, DUMMY_SP, modifiers);
|
||||
}
|
||||
|
||||
|
@ -2172,7 +2172,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
// check that all of the arms in an or-pattern have exactly the
|
||||
// same set of bindings, with the same binding modes for each.
|
||||
fn check_consistent_bindings(&mut self, arm: &Arm) {
|
||||
if arm.pats.len() == 0 {
|
||||
if arm.pats.is_empty() {
|
||||
return
|
||||
}
|
||||
let map_0 = self.binding_mode_map(&*arm.pats[0]);
|
||||
@ -3522,7 +3522,7 @@ fn module_to_string(module: &Module) -> String {
|
||||
}
|
||||
collect_mod(&mut names, module);
|
||||
|
||||
if names.len() == 0 {
|
||||
if names.is_empty() {
|
||||
return "???".to_string();
|
||||
}
|
||||
names_to_string(&names.into_iter().rev().collect::<Vec<ast::Name>>())
|
||||
|
@ -304,7 +304,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
|
||||
module_to_string(&*module_));
|
||||
|
||||
// First, resolve the module path for the directive, if necessary.
|
||||
let container = if module_path.len() == 0 {
|
||||
let container = if module_path.is_empty() {
|
||||
// Use the crate root.
|
||||
Some((self.resolver.graph_root.get_module(), LastMod(AllPublic)))
|
||||
} else {
|
||||
|
@ -463,7 +463,7 @@ pub fn filename_for_input(sess: &Session,
|
||||
}
|
||||
config::CrateTypeExecutable => {
|
||||
let suffix = &sess.target.target.options.exe_suffix;
|
||||
if suffix.len() == 0 {
|
||||
if suffix.is_empty() {
|
||||
out_filename.to_path_buf()
|
||||
} else {
|
||||
out_filename.with_extension(&suffix[1..])
|
||||
|
@ -263,7 +263,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
||||
|
||||
fn process_formals(&mut self, formals: &Vec<ast::Arg>, qualname: &str) {
|
||||
for arg in formals {
|
||||
assert!(self.collected_paths.len() == 0 && !self.collecting);
|
||||
assert!(self.collected_paths.is_empty() && !self.collecting);
|
||||
self.collecting = true;
|
||||
self.visit_pat(&*arg.pat);
|
||||
self.collecting = false;
|
||||
@ -1394,7 +1394,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_arm(&mut self, arm: &ast::Arm) {
|
||||
assert!(self.collected_paths.len() == 0 && !self.collecting);
|
||||
assert!(self.collected_paths.is_empty() && !self.collecting);
|
||||
self.collecting = true;
|
||||
for pattern in &arm.pats {
|
||||
// collect paths from the arm's patterns
|
||||
@ -1462,7 +1462,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
|
||||
// The local could declare multiple new vars, we must walk the
|
||||
// pattern and collect them all.
|
||||
assert!(self.collected_paths.len() == 0 && !self.collecting);
|
||||
assert!(self.collected_paths.is_empty() && !self.collecting);
|
||||
self.collecting = true;
|
||||
self.visit_pat(&*l.pat);
|
||||
self.collecting = false;
|
||||
|
@ -988,7 +988,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let _indenter = indenter();
|
||||
let _icx = push_ctxt("match::compile_submatch");
|
||||
let mut bcx = bcx;
|
||||
if m.len() == 0 {
|
||||
if m.is_empty() {
|
||||
if chk.is_fallible() {
|
||||
chk.handle_fail(bcx);
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
};
|
||||
|
||||
let defaults = enter_default(else_cx, dm, m, col, val);
|
||||
let exhaustive = chk.is_infallible() && defaults.len() == 0;
|
||||
let exhaustive = chk.is_infallible() && defaults.is_empty();
|
||||
let len = opts.len();
|
||||
|
||||
// Compile subtrees for each option
|
||||
|
@ -235,7 +235,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
|
||||
|
||||
if cases.len() == 0 {
|
||||
if cases.is_empty() {
|
||||
// Uninhabitable; represent as unit
|
||||
// (Typechecking will reject discriminant-sizing attrs.)
|
||||
assert_eq!(hint, attr::ReprAny);
|
||||
@ -244,7 +244,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
dtor_to_init_u8(dtor));
|
||||
}
|
||||
|
||||
if !dtor && cases.iter().all(|c| c.tys.len() == 0) {
|
||||
if !dtor && cases.iter().all(|c| c.tys.is_empty()) {
|
||||
// All bodies empty -> intlike
|
||||
let discrs: Vec<u64> = cases.iter().map(|c| c.discr).collect();
|
||||
let bounds = IntBounds {
|
||||
|
@ -70,7 +70,7 @@ trait ClassList {
|
||||
|
||||
impl ClassList for [RegClass] {
|
||||
fn is_pass_byval(&self) -> bool {
|
||||
if self.len() == 0 { return false; }
|
||||
if self.is_empty() { return false; }
|
||||
|
||||
let class = self[0];
|
||||
class == Memory
|
||||
@ -79,7 +79,7 @@ impl ClassList for [RegClass] {
|
||||
}
|
||||
|
||||
fn is_ret_bysret(&self) -> bool {
|
||||
if self.len() == 0 { return false; }
|
||||
if self.is_empty() { return false; }
|
||||
|
||||
self[0] == Memory
|
||||
}
|
||||
|
@ -2017,7 +2017,7 @@ struct StructMemberDescriptionFactory<'tcx> {
|
||||
impl<'tcx> StructMemberDescriptionFactory<'tcx> {
|
||||
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
|
||||
-> Vec<MemberDescription> {
|
||||
if self.fields.len() == 0 {
|
||||
if self.fields.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
@ -2210,7 +2210,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
adt::Univariant(ref struct_def, _) => {
|
||||
assert!(self.variants.len() <= 1);
|
||||
|
||||
if self.variants.len() == 0 {
|
||||
if self.variants.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
let (variant_type_metadata,
|
||||
|
@ -83,7 +83,7 @@ pub fn trans_impl(ccx: &CrateContext,
|
||||
for impl_item in impl_items {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(ref sig, ref body) => {
|
||||
if sig.generics.ty_params.len() == 0 {
|
||||
if sig.generics.ty_params.is_empty() {
|
||||
let trans_everywhere = attr::requests_inline(&impl_item.attrs);
|
||||
for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
|
||||
let llfn = get_item_val(ccx, impl_item.id);
|
||||
|
@ -69,7 +69,7 @@ pub fn untuple_arguments_if_necessary<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
return inputs.iter().cloned().collect()
|
||||
}
|
||||
|
||||
if inputs.len() == 0 {
|
||||
if inputs.is_empty() {
|
||||
return Vec::new()
|
||||
}
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ fn one_bound_for_assoc_type<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
span: Span)
|
||||
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
|
||||
{
|
||||
if bounds.len() == 0 {
|
||||
if bounds.is_empty() {
|
||||
span_err!(tcx.sess, span, E0220,
|
||||
"associated type `{}` not found for `{}`",
|
||||
assoc_name,
|
||||
@ -2042,7 +2042,7 @@ fn compute_object_lifetime_bound<'tcx>(
|
||||
|
||||
// If there are no derived region bounds, then report back that we
|
||||
// can find no region bound.
|
||||
if derived_region_bounds.len() == 0 {
|
||||
if derived_region_bounds.is_empty() {
|
||||
match rscope.object_lifetime_default(span) {
|
||||
Some(r) => { return r; }
|
||||
None => {
|
||||
|
@ -594,7 +594,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
for (subpat, arg_ty) in subpats.iter().zip(arg_tys.iter()) {
|
||||
check_pat(pcx, &**subpat, *arg_ty);
|
||||
}
|
||||
} else if arg_tys.len() == 0 {
|
||||
} else if arg_tys.is_empty() {
|
||||
span_err!(tcx.sess, pat.span, E0024,
|
||||
"this pattern has {} field{}, but the corresponding {} has no fields",
|
||||
subpats.len(), if subpats.len() == 1 {""} else {"s"}, kind_name);
|
||||
|
@ -4719,7 +4719,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
tps.len(), ppaux::ty_to_string(ccx.tcx, ty));
|
||||
|
||||
// make a vector of booleans initially false, set to true when used
|
||||
if tps.len() == 0 { return; }
|
||||
if tps.is_empty() { return; }
|
||||
let mut tps_used: Vec<_> = repeat(false).take(tps.len()).collect();
|
||||
|
||||
ty::walk_ty(ty, |t| {
|
||||
|
@ -387,7 +387,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
|
||||
for &impl_did in &*trait_impls.borrow() {
|
||||
let items = impl_items.get(&impl_did).unwrap();
|
||||
if items.len() < 1 {
|
||||
if items.is_empty() {
|
||||
// We'll error out later. For now, just don't ICE.
|
||||
continue;
|
||||
}
|
||||
|
@ -1035,7 +1035,7 @@ fn convert_struct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
match struct_def.ctor_id {
|
||||
None => {}
|
||||
Some(ctor_id) => {
|
||||
if struct_def.fields.len() == 0 {
|
||||
if struct_def.fields.is_empty() {
|
||||
// Enum-like.
|
||||
write_ty_to_tcx(tcx, ctor_id, selfty);
|
||||
|
||||
@ -1893,7 +1893,7 @@ fn compute_object_lifetime_default<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
||||
.flat_map(|predicate| {
|
||||
match *predicate {
|
||||
ast::WherePredicate::BoundPredicate(ref data) => {
|
||||
if data.bound_lifetimes.len() == 0 &&
|
||||
if data.bound_lifetimes.is_empty() &&
|
||||
is_param(ccx.tcx, &data.bounded_ty, param_id)
|
||||
{
|
||||
from_bounds(ccx, &data.bounds).into_iter()
|
||||
|
@ -1820,7 +1820,7 @@ impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
// use syntax::parse::token::special_idents::unnamed_field;
|
||||
let kind = match self.arg_names.as_ref().map(|s| &**s) {
|
||||
None | Some([]) if self.args.len() == 0 => CLikeVariant,
|
||||
None | Some([]) if self.args.is_empty() => CLikeVariant,
|
||||
None | Some([]) => {
|
||||
TupleVariant(self.args.clean(cx))
|
||||
}
|
||||
@ -1874,7 +1874,7 @@ impl Clean<VariantKind> for ast::VariantKind {
|
||||
fn clean(&self, cx: &DocContext) -> VariantKind {
|
||||
match self {
|
||||
&ast::TupleVariantKind(ref args) => {
|
||||
if args.len() == 0 {
|
||||
if args.is_empty() {
|
||||
CLikeVariant
|
||||
} else {
|
||||
TupleVariant(args.iter().map(|x| x.ty.clean(cx)).collect())
|
||||
|
@ -94,7 +94,7 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||
|
||||
impl fmt::Display for clean::Generics {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) }
|
||||
if self.lifetimes.is_empty() && self.type_params.is_empty() { return Ok(()) }
|
||||
try!(f.write_str("<"));
|
||||
|
||||
for (i, life) in self.lifetimes.iter().enumerate() {
|
||||
@ -132,7 +132,7 @@ impl fmt::Display for clean::Generics {
|
||||
impl<'a> fmt::Display for WhereClause<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let &WhereClause(gens) = self;
|
||||
if gens.where_predicates.len() == 0 {
|
||||
if gens.where_predicates.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
try!(f.write_str(" <span class='where'>where "));
|
||||
|
@ -130,7 +130,7 @@ r##"<!DOCTYPE html>
|
||||
content = *t,
|
||||
root_path = page.root_path,
|
||||
ty = page.ty,
|
||||
logo = if layout.logo.len() == 0 {
|
||||
logo = if layout.logo.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!("<a href='{}{}/index.html'>\
|
||||
@ -141,7 +141,7 @@ r##"<!DOCTYPE html>
|
||||
title = page.title,
|
||||
description = page.description,
|
||||
keywords = page.keywords,
|
||||
favicon = if layout.favicon.len() == 0 {
|
||||
favicon = if layout.favicon.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
|
||||
@ -152,7 +152,7 @@ r##"<!DOCTYPE html>
|
||||
sidebar = *sidebar,
|
||||
krate = layout.krate,
|
||||
play_url = layout.playground_url,
|
||||
play_js = if layout.playground_url.len() == 0 {
|
||||
play_js = if layout.playground_url.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!(r#"<script src="{}playpen.js"></script>"#, page.root_path)
|
||||
|
@ -305,7 +305,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
||||
let text = format!(r##"<h{lvl} id="{id}" class='section-header'><a
|
||||
href="#{id}">{sec}{}</a></h{lvl}>"##,
|
||||
s, lvl = level, id = id,
|
||||
sec = if sec.len() == 0 {
|
||||
sec = if sec.is_empty() {
|
||||
sec.to_string()
|
||||
} else {
|
||||
format!("{} ", sec)
|
||||
@ -491,7 +491,7 @@ impl<'a> fmt::Display for Markdown<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Markdown(md) = *self;
|
||||
// This is actually common enough to special-case
|
||||
if md.len() == 0 { return Ok(()) }
|
||||
if md.is_empty() { return Ok(()) }
|
||||
render(fmt, md, false)
|
||||
}
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ impl DocFolder for Cache {
|
||||
false)
|
||||
}
|
||||
clean::MethodItem(..) => {
|
||||
if self.parent_stack.len() == 0 {
|
||||
if self.parent_stack.is_empty() {
|
||||
((None, None), false)
|
||||
} else {
|
||||
let last = self.parent_stack.last().unwrap();
|
||||
@ -1115,7 +1115,7 @@ impl Context {
|
||||
fn recurse<T, F>(&mut self, s: String, f: F) -> T where
|
||||
F: FnOnce(&mut Context) -> T,
|
||||
{
|
||||
if s.len() == 0 {
|
||||
if s.is_empty() {
|
||||
panic!("Unexpected empty destination: {:?}", self.current);
|
||||
}
|
||||
let prev = self.dst.clone();
|
||||
@ -1343,7 +1343,7 @@ impl Context {
|
||||
fn ignore_private_item(&self, it: &clean::Item) -> bool {
|
||||
match it.inner {
|
||||
clean::ModuleItem(ref m) => {
|
||||
(m.items.len() == 0 &&
|
||||
(m.items.is_empty() &&
|
||||
it.doc_value().is_none() &&
|
||||
it.visibility != Some(ast::Public)) ||
|
||||
(self.passes.contains("strip-private") && it.visibility != Some(ast::Public))
|
||||
@ -1690,7 +1690,7 @@ struct Initializer<'a>(&'a str);
|
||||
impl<'a> fmt::Display for Initializer<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Initializer(s) = *self;
|
||||
if s.len() == 0 { return Ok(()); }
|
||||
if s.is_empty() { return Ok(()); }
|
||||
try!(write!(f, "<code> = </code>"));
|
||||
write!(f, "<code>{}</code>", s)
|
||||
}
|
||||
@ -1766,7 +1766,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
match m.inner { clean::MethodItem(_) => true, _ => false }
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
if t.items.len() == 0 {
|
||||
if t.items.is_empty() {
|
||||
try!(write!(w, "{{ }}"));
|
||||
} else {
|
||||
try!(write!(w, "{{\n"));
|
||||
@ -1986,7 +1986,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
it.name.as_ref().unwrap(),
|
||||
e.generics,
|
||||
WhereClause(&e.generics)));
|
||||
if e.variants.len() == 0 && !e.variants_stripped {
|
||||
if e.variants.is_empty() && !e.variants_stripped {
|
||||
try!(write!(w, " {{}}"));
|
||||
} else {
|
||||
try!(write!(w, " {{\n"));
|
||||
|
@ -219,7 +219,7 @@ pub fn main_args(args: &[String]) -> isize {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if matches.free.len() == 0 {
|
||||
if matches.free.is_empty() {
|
||||
println!("expected an input file to act on");
|
||||
return 1;
|
||||
} if matches.free.len() > 1 {
|
||||
|
@ -74,7 +74,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
|
||||
};
|
||||
|
||||
let (metadata, text) = extract_leading_metadata(&input_str);
|
||||
if metadata.len() == 0 {
|
||||
if metadata.is_empty() {
|
||||
let _ = writeln!(&mut io::stderr(),
|
||||
"invalid markdown file: expecting initial line with `% ...TITLE...`");
|
||||
return 5;
|
||||
|
@ -215,9 +215,9 @@ impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
match i.inner {
|
||||
// emptied modules/impls have no need to exist
|
||||
clean::ModuleItem(ref m)
|
||||
if m.items.len() == 0 &&
|
||||
if m.items.is_empty() &&
|
||||
i.doc_value().is_none() => None,
|
||||
clean::ImplItem(ref i) if i.items.len() == 0 => None,
|
||||
clean::ImplItem(ref i) if i.items.is_empty() => None,
|
||||
_ => {
|
||||
self.retained.insert(i.def_id.node);
|
||||
Some(i)
|
||||
|
@ -409,7 +409,7 @@ impl Collector {
|
||||
impl DocFolder for Collector {
|
||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||
let pushed = match item.name {
|
||||
Some(ref name) if name.len() == 0 => false,
|
||||
Some(ref name) if name.is_empty() => false,
|
||||
Some(ref name) => { self.names.push(name.to_string()); true }
|
||||
None => false
|
||||
};
|
||||
|
@ -175,7 +175,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
please_inline)
|
||||
}).collect::<Vec<ast::PathListItem>>();
|
||||
|
||||
if mine.len() == 0 {
|
||||
if mine.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(ast::ViewPathList(p, mine))
|
||||
|
@ -3837,7 +3837,7 @@ mod tests {
|
||||
let mut stack = Stack::new();
|
||||
|
||||
assert!(stack.is_empty());
|
||||
assert!(stack.len() == 0);
|
||||
assert!(stack.is_empty());
|
||||
assert!(!stack.last_is_index());
|
||||
|
||||
stack.push_index(0);
|
||||
|
@ -430,7 +430,7 @@ impl<T, S> HashSet<T, S>
|
||||
/// assert!(!v.is_empty());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_empty(&self) -> bool { self.map.len() == 0 }
|
||||
pub fn is_empty(&self) -> bool { self.map.is_empty() }
|
||||
|
||||
/// Clears the set, returning all elements in an iterator.
|
||||
#[inline]
|
||||
|
@ -381,7 +381,7 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> Vec<u16> {
|
||||
// it will be dropped entirely when parsed on the other end.
|
||||
let arg_bytes = &arg.as_inner().inner.as_inner();
|
||||
let quote = arg_bytes.iter().any(|c| *c == b' ' || *c == b'\t')
|
||||
|| arg_bytes.len() == 0;
|
||||
|| arg_bytes.is_empty();
|
||||
if quote {
|
||||
cmd.push('"' as u16);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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 { } }`
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 = || {
|
||||
|
@ -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 {
|
||||
|
@ -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 `{},`",
|
||||
|
@ -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(())
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ use std::path::PathBuf;
|
||||
/// Return path to database entry for `term`
|
||||
#[allow(deprecated)]
|
||||
pub fn get_dbpath_for_term(term: &str) -> Option<Box<PathBuf>> {
|
||||
if term.len() == 0 {
|
||||
if term.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ impl<'a> Iterator for Graphemes<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a str> {
|
||||
use tables::grapheme as gr;
|
||||
if self.string.len() == 0 {
|
||||
if self.string.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ impl<'a> DoubleEndedIterator for Graphemes<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a str> {
|
||||
use tables::grapheme as gr;
|
||||
if self.string.len() == 0 {
|
||||
if self.string.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ fn main() {
|
||||
for line in rdr.lines() {
|
||||
let line = line.unwrap().trim().to_string();
|
||||
|
||||
if line.len() == 0 { continue; }
|
||||
if line.is_empty() { continue; }
|
||||
|
||||
match (line.as_bytes()[0] as char, proc_mode) {
|
||||
|
||||
|
@ -196,7 +196,7 @@ fn shift_mut_ref<'a, T>(r: &mut &'a mut [T]) -> Option<&'a mut T> {
|
||||
use std::mem;
|
||||
use std::raw::Repr;
|
||||
|
||||
if r.len() == 0 { return None }
|
||||
if r.is_empty() { return None }
|
||||
unsafe {
|
||||
let mut raw = r.repr();
|
||||
let ret = raw.data as *mut T;
|
||||
|
@ -79,7 +79,7 @@ pub fn main() {
|
||||
|
||||
// Zero size vec.
|
||||
let f5: &Fat<[isize]> = &Fat { ptr: [] };
|
||||
assert!(f5.ptr.len() == 0);
|
||||
assert!(f5.ptr.is_empty());
|
||||
let f5: &Fat<[Bar]> = &Fat { ptr: [] };
|
||||
assert!(f5.ptr.len() == 0);
|
||||
assert!(f5.ptr.is_empty());
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ pub fn main() {
|
||||
|
||||
// Zero size vec.
|
||||
let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [] };
|
||||
assert!(f5.ptr.len() == 0);
|
||||
assert!(f5.ptr.is_empty());
|
||||
let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [] };
|
||||
assert!(f5.ptr.len() == 0);
|
||||
assert!(f5.ptr.is_empty());
|
||||
|
||||
// Deeply nested.
|
||||
let f1 = Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} };
|
||||
|
Loading…
x
Reference in New Issue
Block a user