Skip to content
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

more cleanups #69619

Merged
merged 4 commits into from
Mar 3, 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/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
6 changes: 2 additions & 4 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

// Write down the order of our locals that will be promoted to the prefix.
{
let mut idx = 0u32;
for local in ineligible_locals.iter() {
assignments[local] = Ineligible(Some(idx));
idx += 1;
for (idx, local) in ineligible_locals.iter().enumerate() {
assignments[local] = Ineligible(Some(idx as u32));
Comment on lines +1385 to +1386
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
debug!("generator saved local assignments: {:?}", assignments);
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
5 changes: 2 additions & 3 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,9 @@ impl EmitterWriter {

let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
let mut line_pos = 0;
let mut lines = complete.lines();
for line in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES) {
for (line_pos, line) in lines.by_ref().take(MAX_SUGGESTION_HIGHLIGHT_LINES).enumerate()
{
// Print the span column to avoid confusion
buffer.puts(
row_num,
Expand All @@ -1587,7 +1587,6 @@ impl EmitterWriter {
// print the suggestion
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
buffer.append(row_num, line, Style::NoStyle);
line_pos += 1;
row_num += 1;
}

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
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// we may want to suggest removing a `&`.
if !sm.span_to_filename(expr.span).is_real() {
if let Ok(code) = sm.span_to_snippet(sp) {
if code.chars().next() == Some('&') {
if code.starts_with('&') {
return Some((
sp,
"consider removing the borrow",
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl Socket {
};
let mut timeout = libc::timeval {
tv_sec: secs,
tv_usec: (dur.subsec_nanos() / 1000) as libc::suseconds_t,
tv_usec: dur.subsec_micros() as libc::suseconds_t,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};
if timeout.tv_sec == 0 && timeout.tv_usec == 0 {
timeout.tv_usec = 1;
Expand Down