Skip to content

Commit

Permalink
use values() or keys() respectively when iterating only over keys or …
Browse files Browse the repository at this point in the history
…values of maps.
  • Loading branch information
matthiaskrgr committed Mar 2, 2020
1 parent 22339c3 commit 21affdd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl BoundNamesCollector {
start = false;
write!(fmt, "{}", r)?;
}
for (_, t) in &self.types {
for t in self.types.values() {
if !start {
write!(fmt, ", ")?;
}
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 @@ -188,7 +188,7 @@ fn parse_args<'a>(
let mut err = ecx
.struct_span_err(e.span, "positional arguments cannot follow named arguments");
err.span_label(e.span, "positional arguments must be before named arguments");
for (_, pos) in &names {
for pos in names.values() {
err.span_label(args[*pos].span, "named argument");
}
err.emit();
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_hir/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ impl Crate<'_> {
where
V: itemlikevisit::ItemLikeVisitor<'hir>,
{
for (_, item) in &self.items {
for item in self.items.values() {
visitor.visit_item(item);
}

for (_, trait_item) in &self.trait_items {
for trait_item in self.trait_items.values() {
visitor.visit_trait_item(trait_item);
}

for (_, impl_item) in &self.impl_items {
for impl_item in self.impl_items.values() {
visitor.visit_impl_item(impl_item);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
let dummy_source = graph.add_node(());
let dummy_sink = graph.add_node(());

for (constraint, _) in &self.data.constraints {
for constraint in self.data.constraints.keys() {
match *constraint {
Constraint::VarSubVar(a_id, b_id) => {
graph.add_edge(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/region_constraints/leak_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
assert!(self.in_snapshot());

// Go through each placeholder that we created.
for (_, &placeholder_region) in placeholder_map {
for &placeholder_region in placeholder_map.values() {
// Find the universe this placeholder inhabits.
let placeholder = match placeholder_region {
ty::RePlaceholder(p) => p,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ fn krate(tcx: TyCtxt<'_>) -> NamedRegionMap {
lifetime_uses: &mut Default::default(),
missing_named_lifetime_spots: vec![],
};
for (_, item) in &krate.items {
for item in krate.items.values() {
visitor.visit_item(item);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}

for (projection_bound, _) in &bounds.projection_bounds {
for (_, def_ids) in &mut associated_types {
for def_ids in associated_types.values_mut() {
def_ids.remove(&projection_bound.projection_def_id());
}
}
Expand Down

0 comments on commit 21affdd

Please sign in to comment.