Skip to content

Commit d34f282

Browse files
committed
Use for_each_child in a suitable place.
`for_each_child` exists for this exact pattern.
1 parent d1d8be1 commit d34f282

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
535535
filter_fn: &impl Fn(Res) -> bool,
536536
ctxt: Option<SyntaxContext>,
537537
) {
538-
for (key, resolution) in self.resolutions(module).borrow().iter() {
539-
if let Some(binding) = resolution.borrow().binding {
540-
let res = binding.res();
541-
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == key.ident.span.ctxt()) {
542-
names.push(TypoSuggestion::typo_from_ident(key.ident, res));
543-
}
538+
module.for_each_child(self, |_this, ident, _ns, binding| {
539+
let res = binding.res();
540+
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == ident.span.ctxt()) {
541+
names.push(TypoSuggestion::typo_from_ident(ident, res));
544542
}
545-
}
543+
});
546544
}
547545

548546
/// Combines an error with provided span and emits it.

0 commit comments

Comments
 (0)