Skip to content

Rollup of 6 pull requests #69570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Target {
impl Target {
pub fn from_triple(triple: &str) -> Self {
let mut target: Self = Default::default();
if triple.contains("-none-") || triple.contains("nvptx") {
if triple.contains("-none") || triple.contains("nvptx") {
target.no_std = true;
}
target
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,7 @@ where
// The last index of self.v is already checked and found to match
// by the last iteration, so we start searching a new match
// one index to the left.
let remainder = if self.v.len() == 0 { &[] } else { &self.v[..(self.v.len() - 1)] };
let remainder = if self.v.is_empty() { &[] } else { &self.v[..(self.v.len() - 1)] };
let idx = remainder.iter().rposition(|x| (self.pred)(x)).map(|idx| idx + 1).unwrap_or(0);
if idx == 0 {
self.finished = true;
Expand Down Expand Up @@ -4033,7 +4033,7 @@ where
return None;
}

let idx_opt = if self.v.len() == 0 {
let idx_opt = if self.v.is_empty() {
None
} else {
// work around borrowck limitations
Expand Down
37 changes: 20 additions & 17 deletions src/libcore/tests/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn test_siphash_2_4() {
#[cfg(target_pointer_width = "32")]
fn test_hash_usize() {
let val = 0xdeadbeef_deadbeef_u64;
assert!(hash(&(val as u64)) != hash(&(val as usize)));
assert_ne!(hash(&(val as u64)), hash(&(val as usize)));
assert_eq!(hash(&(val as u32)), hash(&(val as usize)));
}

Expand All @@ -247,7 +247,7 @@ fn test_hash_usize() {
fn test_hash_usize() {
let val = 0xdeadbeef_deadbeef_u64;
assert_eq!(hash(&(val as u64)), hash(&(val as usize)));
assert!(hash(&(val as u32)) != hash(&(val as usize)));
assert_ne!(hash(&(val as u32)), hash(&(val as usize)));
}

#[test]
Expand All @@ -262,14 +262,14 @@ fn test_hash_idempotent() {
fn test_hash_no_bytes_dropped_64() {
let val = 0xdeadbeef_deadbeef_u64;

assert!(hash(&val) != hash(&zero_byte(val, 0)));
assert!(hash(&val) != hash(&zero_byte(val, 1)));
assert!(hash(&val) != hash(&zero_byte(val, 2)));
assert!(hash(&val) != hash(&zero_byte(val, 3)));
assert!(hash(&val) != hash(&zero_byte(val, 4)));
assert!(hash(&val) != hash(&zero_byte(val, 5)));
assert!(hash(&val) != hash(&zero_byte(val, 6)));
assert!(hash(&val) != hash(&zero_byte(val, 7)));
assert_ne!(hash(&val), hash(&zero_byte(val, 0)));
assert_ne!(hash(&val), hash(&zero_byte(val, 1)));
assert_ne!(hash(&val), hash(&zero_byte(val, 2)));
assert_ne!(hash(&val), hash(&zero_byte(val, 3)));
assert_ne!(hash(&val), hash(&zero_byte(val, 4)));
assert_ne!(hash(&val), hash(&zero_byte(val, 5)));
assert_ne!(hash(&val), hash(&zero_byte(val, 6)));
assert_ne!(hash(&val), hash(&zero_byte(val, 7)));

fn zero_byte(val: u64, byte: usize) -> u64 {
assert!(byte < 8);
Expand All @@ -281,10 +281,10 @@ fn test_hash_no_bytes_dropped_64() {
fn test_hash_no_bytes_dropped_32() {
let val = 0xdeadbeef_u32;

assert!(hash(&val) != hash(&zero_byte(val, 0)));
assert!(hash(&val) != hash(&zero_byte(val, 1)));
assert!(hash(&val) != hash(&zero_byte(val, 2)));
assert!(hash(&val) != hash(&zero_byte(val, 3)));
assert_ne!(hash(&val), hash(&zero_byte(val, 0)));
assert_ne!(hash(&val), hash(&zero_byte(val, 1)));
assert_ne!(hash(&val), hash(&zero_byte(val, 2)));
assert_ne!(hash(&val), hash(&zero_byte(val, 3)));

fn zero_byte(val: u32, byte: usize) -> u32 {
assert!(byte < 4);
Expand All @@ -299,14 +299,17 @@ fn test_hash_no_concat_alias() {
let u = ("a", "abb");

assert!(s != t && t != u);
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));
assert_ne!(s, t);
assert_ne!(t, u);
assert_ne!(hash(&s), hash(&t));
assert_ne!(hash(&s), hash(&u));

let u = [1, 0, 0, 0];
let v = (&u[..1], &u[1..3], &u[3..]);
let w = (&u[..], &u[4..4], &u[4..4]);

assert!(v != w);
assert!(hash(&v) != hash(&w));
assert_ne!(v, w);
assert_ne!(hash(&v), hash(&w));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'tcx> Arena<'tcx> {

#[inline]
pub fn alloc_slice<T: Copy>(&self, value: &[T]) -> &mut [T] {
if value.len() == 0 {
if value.is_empty() {
return &mut [];
}
self.dropless.alloc_slice(value)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl DepGraph {
dep_node
);

if unlikely!(diagnostics.len() > 0) {
if unlikely!(!diagnostics.is_empty()) {
self.emit_diagnostics(tcx, data, dep_node_index, prev_dep_node_index, diagnostics);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use smallvec::SmallVec;
use std::cmp::Ord;

fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
debug_assert!(!ich::IGNORED_ATTRIBUTES.is_empty());
ich::IGNORED_ATTRIBUTES.iter().map(|&s| s).collect()
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<'ctx> rustc_target::HashStableContext for StableHashingContext<'ctx> {}

impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
if self.len() == 0 {
if self.is_empty() {
self.len().hash_stable(hcx, hasher);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
// Skip the last, which is just the environment of the constant. The stacktrace
// is sometimes empty because we create "fake" eval contexts in CTFE to do work
// on constant values.
if self.stacktrace.len() > 0 {
if !self.stacktrace.is_empty() {
for frame_info in &self.stacktrace[..self.stacktrace.len() - 1] {
err.span_label(frame_info.call_site, frame_info.to_string());
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
});
let region = if print_region {
let mut region = region.to_string();
if region.len() > 0 {
if !region.is_empty() {
region.push(' ');
}
region
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::borrow::Cow;

fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
if def_id.is_top_level_module() {
format!("top-level module")
"top-level module".to_string()
} else {
format!("module `{}`", tcx.def_path_str(def_id))
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ impl<'tcx> TyCtxt<'tcx> {
// FIXME consider asking the input slice to be sorted to avoid
// re-interning permutations, in which case that would be asserted
// here.
if preds.len() == 0 {
if preds.is_empty() {
// The macro-generated method below asserts we don't intern an empty slice.
List::empty()
} else {
Expand All @@ -2482,31 +2482,31 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
if ts.len() == 0 { List::empty() } else { self._intern_type_list(ts) }
if ts.is_empty() { List::empty() } else { self._intern_type_list(ts) }
}

pub fn intern_substs(self, ts: &[GenericArg<'tcx>]) -> &'tcx List<GenericArg<'tcx>> {
if ts.len() == 0 { List::empty() } else { self._intern_substs(ts) }
if ts.is_empty() { List::empty() } else { self._intern_substs(ts) }
}

pub fn intern_projs(self, ps: &[ProjectionKind]) -> &'tcx List<ProjectionKind> {
if ps.len() == 0 { List::empty() } else { self._intern_projs(ps) }
if ps.is_empty() { List::empty() } else { self._intern_projs(ps) }
}

pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> {
if ts.len() == 0 { List::empty() } else { self._intern_place_elems(ts) }
if ts.is_empty() { List::empty() } else { self._intern_place_elems(ts) }
}

pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'tcx> {
if ts.len() == 0 { List::empty() } else { self._intern_canonical_var_infos(ts) }
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
}

pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> {
if ts.len() == 0 { List::empty() } else { self._intern_clauses(ts) }
if ts.is_empty() { List::empty() } else { self._intern_clauses(ts) }
}

pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> {
if ts.len() == 0 { List::empty() } else { self._intern_goals(ts) }
if ts.is_empty() { List::empty() } else { self._intern_goals(ts) }
}

pub fn mk_fn_sig<I>(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl<'tcx> Instance<'tcx> {
) -> Option<Instance<'tcx>> {
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
let fn_sig = tcx.fn_sig(def_id);
let is_vtable_shim = fn_sig.inputs().skip_binder().len() > 0
let is_vtable_shim = !fn_sig.inputs().skip_binder().is_empty()
&& fn_sig.input(0).skip_binder().is_param(0)
&& tcx.generics_of(def_id).has_self;
if is_vtable_shim {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// (Typechecking will reject discriminant-sizing attrs.)

let v = present_first.unwrap();
let kind = if def.is_enum() || variants[v].len() == 0 {
let kind = if def.is_enum() || variants[v].is_empty() {
StructKind::AlwaysSized
} else {
let param_env = tcx.param_env(def.did);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ impl<T: Copy> List<T> {
fn from_arena<'tcx>(arena: &'tcx Arena<'tcx>, slice: &[T]) -> &'tcx List<T> {
assert!(!mem::needs_drop::<T>());
assert!(mem::size_of::<T>() != 0);
assert!(slice.len() != 0);
assert!(!slice.is_empty());

// Align up the size of the len (usize) field
let align = mem::align_of::<T>();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
err.span_label(data.span, "only `Fn` traits may use parentheses");
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
// Do not suggest going from `Trait()` to `Trait<>`
if data.inputs.len() > 0 {
if !data.inputs.is_empty() {
if let Some(split) = snippet.find('(') {
let trait_name = &snippet[0..split];
let args = &snippet[split + 1..snippet.len() - 1];
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ impl<'a> PrintState<'a> for State<'a> {
s.print_generic_arg(generic_arg)
});

let mut comma = data.args.len() != 0;
let mut comma = !data.args.is_empty();

for constraint in data.constraints.iter() {
if comma {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
err.span_suggestion(
span,
"consider removing the prefix",
format!("{}", &lint_str[1..]),
lint_str[1..].to_string(),
Applicability::MaybeIncorrect,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn expand_concat(
}
}
}
if missing_literal.len() > 0 {
if !missing_literal.is_empty() {
let mut err = cx.struct_span_err(missing_literal, "expected a literal");
err.note("only literals (like `\"foo\"`, `42` and `3.14`) can be passed to `concat!()`");
err.emit();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_builtin_macros/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,14 @@ impl<'a> TraitDef<'a> {
span: self.span,
bound_generic_params: wb.bound_generic_params.clone(),
bounded_ty: wb.bounded_ty.clone(),
bounds: wb.bounds.iter().cloned().collect(),
bounds: wb.bounds.to_vec(),
})
}
ast::WherePredicate::RegionPredicate(ref rb) => {
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
span: self.span,
lifetime: rb.lifetime,
bounds: rb.bounds.iter().cloned().collect(),
bounds: rb.bounds.to_vec(),
})
}
ast::WherePredicate::EqPredicate(ref we) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ pub fn expand_preparsed_format_args(
cx.str_pieces.push(s);
}

if cx.invalid_refs.len() >= 1 {
if !cx.invalid_refs.is_empty() {
cx.report_invalid_references(numbered_position_args);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fn fat_lto(
let module: ModuleCodegen<ModuleLlvm> = match costliest_module {
Some((_cost, i)) => in_memory.remove(i),
None => {
assert!(serialized_modules.len() > 0, "must have at least one serialized module");
assert!(!serialized_modules.is_empty(), "must have at least one serialized module");
let (buffer, name) = serialized_modules.remove(0);
info!("no in-memory regular modules to choose from, parsing {:?}", name);
ModuleCodegen {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ unsafe fn configure_llvm(sess: &Session) {
let sess_args = cg_opts.chain(tg_opts);

let user_specified_args: FxHashSet<_> =
sess_args.clone().map(|s| llvm_arg_to_arg_name(s)).filter(|s| s.len() > 0).collect();
sess_args.clone().map(|s| llvm_arg_to_arg_name(s)).filter(|s| !s.is_empty()).collect();

{
// This adds the given argument to LLVM. Unless `force` is true
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,12 +1524,12 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
for &(cnum, _) in deps.iter().rev() {
if let Some(missing) = info.missing_lang_items.get(&cnum) {
end_with.extend(missing.iter().cloned());
if end_with.len() > 0 && group_end.is_none() {
if !end_with.is_empty() && group_end.is_none() {
group_end = Some(cnum);
}
}
end_with.retain(|item| info.lang_item_to_crate.get(item) != Some(&cnum));
if end_with.len() == 0 && group_end.is_some() {
if end_with.is_empty() && group_end.is_some() {
group_start = Some(cnum);
break;
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,11 @@ fn start_executing_work<B: ExtraBackendMethods>(
while !codegen_done
|| running > 0
|| (!codegen_aborted
&& (work_items.len() > 0
|| needs_fat_lto.len() > 0
|| needs_thin_lto.len() > 0
|| lto_import_only_modules.len() > 0
|| main_thread_worker_state != MainThreadWorkerState::Idle))
&& !(work_items.is_empty()
&& needs_fat_lto.is_empty()
&& needs_thin_lto.is_empty()
&& lto_import_only_modules.is_empty()
&& main_thread_worker_state == MainThreadWorkerState::Idle))
{
// While there are still CGUs to be codegened, the coordinator has
// to decide how to utilize the compiler processes implicit Token:
Expand Down Expand Up @@ -1289,7 +1289,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
// Perform the serial work here of figuring out what we're
// going to LTO and then push a bunch of work items onto our
// queue to do LTO
if work_items.len() == 0
if work_items.is_empty()
&& running == 0
&& main_thread_worker_state == MainThreadWorkerState::Idle
{
Expand Down Expand Up @@ -1354,7 +1354,7 @@ fn start_executing_work<B: ExtraBackendMethods>(

// Spin up what work we can, only doing this while we've got available
// parallelism slots and work left to spawn.
while !codegen_aborted && work_items.len() > 0 && running < tokens.len() {
while !codegen_aborted && !work_items.is_empty() && running < tokens.len() {
let (item, _) = work_items.pop().unwrap();

maybe_start_llvm_timer(prof, cgcx.config(item.module_kind()), &mut llvm_start_time);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl SelfProfiler {
}

// Warn about any unknown event names
if unknown_events.len() > 0 {
if !unknown_events.is_empty() {
unknown_events.sort();
unknown_events.dedup();

Expand Down
Loading