Skip to content

Commit

Permalink
Rollup merge of rust-lang#81795 - camsteffen:diagnostics-reduce, r=ol…
Browse files Browse the repository at this point in the history
…i-obk

Small refactor with Iterator::reduce
  • Loading branch information
m-ou-se authored Feb 5, 2021
2 parents 728c955 + c89b9d9 commit 51c6803
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,9 @@ impl<'a> Resolver<'a> {
_,
) = binding.kind
{
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
let def_id = self.parent(ctor_def_id).expect("no parent for a constructor");
let fields = self.field_names.get(&def_id)?;
let first_field = fields.first()?; // Handle `struct Foo()`
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
}
None
}
Expand Down

0 comments on commit 51c6803

Please sign in to comment.