diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-11-08 15:16:16 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-11-14 11:35:27 +1100 |
| commit | d71c06d022b07518f97072ad36cbe2c8a25eee2d (patch) | |
| tree | 430bb2c2ce830418006c035050b5fef05444085b /compiler/rustc_resolve/src/ident.rs | |
| parent | e7dffeedcffce81f709da8a076b8ff437b8d3060 (diff) | |
| download | rust-d71c06d022b07518f97072ad36cbe2c8a25eee2d.tar.gz rust-d71c06d022b07518f97072ad36cbe2c8a25eee2d.zip | |
Remove two `_ext` methods.
`resolve_ident_in_module` is a very thin wrapper around `resolve_ident_in_module_ext`, and `resolve_ident_in_module_unadjusted` is a very thin wrapper around `resolve_ident_in_module_unadjusted_ext`. The wrappers make the call sites slightly more concise, but I don't think that's worth the extra code and indirection. This commit removes the two wrappers and removes the `_ext` suffixes from the inner methods.
Diffstat (limited to 'compiler/rustc_resolve/src/ident.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/ident.rs | 69 |
1 files changed, 13 insertions, 56 deletions
diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index d8e1e296b22..b8e07ef5402 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -349,6 +349,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ident, ns, parent_scope, + false, finalize.map(|finalize| Finalize { used: Used::Scope, ..finalize }), ignore_binding, None, @@ -493,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { Scope::CrateRoot => { let root_ident = Ident::new(kw::PathRoot, ident.span); let root_module = this.resolve_crate_root(root_ident); - let binding = this.resolve_ident_in_module_ext( + let binding = this.resolve_ident_in_module( ModuleOrUniformRoot::Module(root_module), ident, ns, @@ -515,7 +516,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } Scope::Module(module, derive_fallback_lint_id) => { let adjusted_parent_scope = &ParentScope { module, ..*parent_scope }; - let binding = this.resolve_ident_in_module_unadjusted_ext( + let binding = this.resolve_ident_in_module_unadjusted( ModuleOrUniformRoot::Module(module), ident, ns, @@ -589,6 +590,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ident, ns, parent_scope, + false, None, ignore_binding, ignore_import, @@ -747,7 +749,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent_scope: &ParentScope<'ra>, ignore_import: Option<Import<'ra>>, ) -> Result<NameBinding<'ra>, Determinacy> { - self.resolve_ident_in_module_ext(module, ident, ns, parent_scope, None, None, ignore_import) + self.resolve_ident_in_module(module, ident, ns, parent_scope, None, None, ignore_import) .map_err(|(determinacy, _)| determinacy) } @@ -755,29 +757,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { pub(crate) fn resolve_ident_in_module( &mut self, module: ModuleOrUniformRoot<'ra>, - ident: Ident, - ns: Namespace, - parent_scope: &ParentScope<'ra>, - finalize: Option<Finalize>, - ignore_binding: Option<NameBinding<'ra>>, - ignore_import: Option<Import<'ra>>, - ) -> Result<NameBinding<'ra>, Determinacy> { - self.resolve_ident_in_module_ext( - module, - ident, - ns, - parent_scope, - finalize, - ignore_binding, - ignore_import, - ) - .map_err(|(determinacy, _)| determinacy) - } - - #[instrument(level = "debug", skip(self))] - fn resolve_ident_in_module_ext( - &mut self, - module: ModuleOrUniformRoot<'ra>, mut ident: Ident, ns: Namespace, parent_scope: &ParentScope<'ra>, @@ -802,7 +781,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // No adjustments } } - self.resolve_ident_in_module_unadjusted_ext( + self.resolve_ident_in_module_unadjusted( module, ident, ns, @@ -814,34 +793,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) } - #[instrument(level = "debug", skip(self))] - fn resolve_ident_in_module_unadjusted( - &mut self, - module: ModuleOrUniformRoot<'ra>, - ident: Ident, - ns: Namespace, - parent_scope: &ParentScope<'ra>, - finalize: Option<Finalize>, - ignore_binding: Option<NameBinding<'ra>>, - ignore_import: Option<Import<'ra>>, - ) -> Result<NameBinding<'ra>, Determinacy> { - self.resolve_ident_in_module_unadjusted_ext( - module, - ident, - ns, - parent_scope, - false, - finalize, - ignore_binding, - ignore_import, - ) - .map_err(|(determinacy, _)| determinacy) - } - /// Attempts to resolve `ident` in namespaces `ns` of `module`. /// Invariant: if `finalize` is `Some`, expansion and import resolution must be complete. #[instrument(level = "debug", skip(self))] - fn resolve_ident_in_module_unadjusted_ext( + fn resolve_ident_in_module_unadjusted( &mut self, module: ModuleOrUniformRoot<'ra>, ident: Ident, @@ -1046,13 +1001,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ignore_binding, ignore_import, ) { - Err(Determined) => continue, + Err((Determined, _)) => continue, Ok(binding) if !self.is_accessible_from(binding.vis, single_import.parent_scope.module) => { continue; } - Ok(_) | Err(Undetermined) => return Err((Undetermined, Weak::No)), + Ok(_) | Err((Undetermined, _)) => return Err((Undetermined, Weak::No)), } } @@ -1121,19 +1076,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ident, ns, adjusted_parent_scope, + false, None, ignore_binding, ignore_import, ); match result { - Err(Determined) => continue, + Err((Determined, _)) => continue, Ok(binding) if !self.is_accessible_from(binding.vis, glob_import.parent_scope.module) => { continue; } - Ok(_) | Err(Undetermined) => return Err((Undetermined, Weak::Yes)), + Ok(_) | Err((Undetermined, _)) => return Err((Undetermined, Weak::Yes)), } } @@ -1564,6 +1520,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ignore_binding, ignore_import, ) + .map_err(|(determinacy, _)| determinacy) } else if let Some(ribs) = ribs && let Some(TypeNS | ValueNS) = opt_ns { |
