1
Fork 0

use values() or keys() respectively when iterating only over keys or values of maps.

This commit is contained in:
Matthias Krüger 2020-03-01 20:56:30 +01:00
parent 22339c3406
commit 21affdd00d
7 changed files with 9 additions and 9 deletions

View file

@ -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, ", ")?;
}

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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(

View file

@ -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,

View file

@ -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);
}
}

View file

@ -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());
}
}