From 9761db07d9b376326841ee895fd71b86ef2b47b5 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 29 Nov 2025 17:10:31 +0300 Subject: [PATCH] resolve: Correctly mark break and continue for determinate errors Existing but private bindings - break, everything else - continue. --- compiler/rustc_resolve/src/ident.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index d1d2f318204b..91cf0f97e252 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -626,7 +626,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { Err(ControlFlow::Break(Determinacy::Undetermined)) => { return ControlFlow::Break(Err(Determinacy::determined(force))); } - Err(ControlFlow::Break(Determinacy::Determined)) => Err(Determined), + // Privacy errors, do not happen during in scope resolution. + Err(ControlFlow::Break(Determinacy::Determined)) => unreachable!(), } } Scope::MacroUsePrelude => match self.macro_use_prelude.get(&ident.name).cloned() { @@ -951,7 +952,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let resolution = &*self .resolution_or_default(module, key) .try_borrow_mut_unchecked() - .map_err(|_| ControlFlow::Break(Determined))?; + .map_err(|_| ControlFlow::Continue(Determined))?; // If the primary binding is unusable, search further and return the shadowed glob // binding if it exists. What we really want here is having two separate scopes in @@ -1086,7 +1087,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } // No resolution and no one else can define the name - determinate error. - Err(ControlFlow::Break(Determined)) + Err(ControlFlow::Continue(Determined)) } fn finalize_module_binding( @@ -1102,7 +1103,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let Finalize { path_span, report_private, used, root_span, .. } = finalize; let Some(binding) = binding else { - return Err(ControlFlow::Break(Determined)); + return Err(ControlFlow::Continue(Determined)); }; if !self.is_accessible_from(binding.vis, parent_scope.module) {