Skip to content

Commit

Permalink
Use for_each_child in a suitable place.
Browse files Browse the repository at this point in the history
`for_each_child` exists for this exact pattern.
  • Loading branch information
nnethercote committed Nov 14, 2024
1 parent d1d8be1 commit d34f282
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
filter_fn: &impl Fn(Res) -> bool,
ctxt: Option<SyntaxContext>,
) {
for (key, resolution) in self.resolutions(module).borrow().iter() {
if let Some(binding) = resolution.borrow().binding {
let res = binding.res();
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == key.ident.span.ctxt()) {
names.push(TypoSuggestion::typo_from_ident(key.ident, res));
}
module.for_each_child(self, |_this, ident, _ns, binding| {
let res = binding.res();
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == ident.span.ctxt()) {
names.push(TypoSuggestion::typo_from_ident(ident, res));
}
}
});
}

/// Combines an error with provided span and emits it.
Expand Down

0 comments on commit d34f282

Please sign in to comment.