about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-11-08 09:00:39 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-11-14 11:35:26 +1100
commitd34f2823fdaeeee3bced7834d43589a3954bc62f (patch)
treea88f298ef0356627c25b59a8c7875a755e8be343
parentd1d8be1d137404a52cdd28e78a9a9c59d38615b0 (diff)
downloadrust-d34f2823fdaeeee3bced7834d43589a3954bc62f.tar.gz
rust-d34f2823fdaeeee3bced7834d43589a3954bc62f.zip
Use `for_each_child` in a suitable place.
`for_each_child` exists for this exact pattern.
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 5437ca65935..5b78acd904a 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -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.