Use for_each_child in a suitable place.

`for_each_child` exists for this exact pattern.
This commit is contained in:
Nicholas Nethercote 2024-11-08 09:00:39 +11:00
parent d1d8be1d13
commit d34f2823fd

View File

@ -535,14 +535,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
filter_fn: &impl Fn(Res) -> bool, filter_fn: &impl Fn(Res) -> bool,
ctxt: Option<SyntaxContext>, ctxt: Option<SyntaxContext>,
) { ) {
for (key, resolution) in self.resolutions(module).borrow().iter() { module.for_each_child(self, |_this, ident, _ns, binding| {
if let Some(binding) = resolution.borrow().binding { let res = binding.res();
let res = binding.res(); if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == ident.span.ctxt()) {
if filter_fn(res) && ctxt.map_or(true, |ctxt| ctxt == key.ident.span.ctxt()) { names.push(TypoSuggestion::typo_from_ident(ident, res));
names.push(TypoSuggestion::typo_from_ident(key.ident, res));
}
} }
} });
} }
/// Combines an error with provided span and emits it. /// Combines an error with provided span and emits it.