diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs index f1faa7d4524..56c2d379e91 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/declaration.rs @@ -188,20 +188,20 @@ impl TyDecl { // save decl_refs for the LSP for supertrait in trait_decl.supertraits.iter_mut() { - let _ = ctx - .resolve_call_path(handler, &supertrait.name) - .map(|supertrait_decl| { - if let ty::TyDecl::TraitDecl(ty::TraitDecl { - decl_id: supertrait_decl_id, - }) = supertrait_decl - { - supertrait.decl_ref = Some(DeclRef::new( - engines.de().get(&supertrait_decl_id).name.clone(), - supertrait_decl_id, - engines.de().get(&supertrait_decl_id).span.clone(), - )); - } - }); + let _ = + ctx.resolve_call_path(handler, &supertrait.name) + .map(|supertrait_decl| { + if let ty::TyDecl::TraitDecl(ty::TraitDecl { + decl_id: supertrait_decl_id, + }) = supertrait_decl + { + supertrait.decl_ref = Some(DeclRef::new( + engines.de().get(&supertrait_decl_id).name.clone(), + supertrait_decl_id, + engines.de().get(&supertrait_decl_id).span.clone(), + )); + } + }); } let decl: ty::TyDecl = decl_engine @@ -359,20 +359,20 @@ impl TyDecl { // save decl_refs for the LSP for supertrait in abi_decl.supertraits.iter_mut() { - let _ = ctx - .resolve_call_path(handler, &supertrait.name) - .map(|supertrait_decl| { - if let ty::TyDecl::TraitDecl(ty::TraitDecl { - decl_id: supertrait_decl_id, - }) = supertrait_decl - { - supertrait.decl_ref = Some(DeclRef::new( - engines.de().get(&supertrait_decl_id).name.clone(), - supertrait_decl_id, - engines.de().get(&supertrait_decl_id).span.clone(), - )); - } - }); + let _ = + ctx.resolve_call_path(handler, &supertrait.name) + .map(|supertrait_decl| { + if let ty::TyDecl::TraitDecl(ty::TraitDecl { + decl_id: supertrait_decl_id, + }) = supertrait_decl + { + supertrait.decl_ref = Some(DeclRef::new( + engines.de().get(&supertrait_decl_id).name.clone(), + supertrait_decl_id, + engines.de().get(&supertrait_decl_id).span.clone(), + )); + } + }); } let decl: ty::TyDecl = decl_engine.insert(abi_decl.clone(), Some(&decl_id)).into(); diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index 0d3ae02555c..e1ef6488ade 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs @@ -49,7 +49,7 @@ use sway_error::{ }; use sway_types::{integer_bits::IntegerBits, u256::U256, Ident, Named, Span, Spanned}; use symbol_collection_context::SymbolCollectionContext; -use type_resolve::resolve_symbol_and_mod_path; +use type_resolve::{resolve_call_path, VisibilityCheck}; #[allow(clippy::too_many_arguments)] impl ty::TyExpression { @@ -298,8 +298,7 @@ impl ty::TyExpression { is_absolute: false, }; if matches!( - ctx.resolve_call_path(&Handler::default(), &call_path,) - .ok(), + ctx.resolve_call_path(&Handler::default(), &call_path,).ok(), Some(ty::TyDecl::EnumVariantDecl { .. }) ) { Self::type_check_delineated_path( @@ -1234,13 +1233,14 @@ impl ty::TyExpression { let storage_key_ident = Ident::new_with_override("StorageKey".into(), span.clone()); // Search for the struct declaration with the call path above. - let (storage_key_decl, _) = resolve_symbol_and_mod_path( + let storage_key_decl = resolve_call_path( handler, engines, - ctx.namespace().root_module(), + ctx.namespace().root(), &storage_key_mod_path, - &storage_key_ident, + &storage_key_ident.into(), None, + VisibilityCheck::No, )?; let storage_key_struct_decl_id = storage_key_decl @@ -1791,7 +1791,7 @@ impl ty::TyExpression { match abi_name { // look up the call path and get the declaration it references AbiName::Known(abi_name) => { - let unknown_decl = ctx.resolve_call_path(handler, abi_name)?; + let unknown_decl = ctx.resolve_call_path(handler, abi_name)?; unknown_decl.to_abi_ref(handler, engines)? } AbiName::Deferred => { diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index 4e9f4c8ed02..072c05932dd 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs @@ -819,11 +819,9 @@ pub(crate) fn resolve_method_name( let type_info_prefix = ctx .namespace() .prepend_module_path(&call_path_binding.inner.prefixes); - ctx.namespace().root_module().lookup_submodule( - handler, - engines, - &type_info_prefix, - )?; + ctx.namespace() + .root_module() + .lookup_submodule(handler, engines, &type_info_prefix)?; // find the method let decl_ref = ctx.find_method_for_type( diff --git a/sway-core/src/semantic_analysis/type_check_context.rs b/sway-core/src/semantic_analysis/type_check_context.rs index 953620096c6..b0c9566c919 100644 --- a/sway-core/src/semantic_analysis/type_check_context.rs +++ b/sway-core/src/semantic_analysis/type_check_context.rs @@ -29,10 +29,7 @@ use sway_types::{span::Span, Ident, Spanned}; use super::{ symbol_collection_context::SymbolCollectionContext, - type_resolve::{ - resolve_call_path, resolve_qualified_call_path, resolve_symbol_and_mod_path, resolve_type, - VisibilityCheck, - }, + type_resolve::{resolve_call_path, resolve_qualified_call_path, resolve_type, VisibilityCheck}, GenericShadowingMode, }; @@ -701,15 +698,16 @@ impl<'a> TypeCheckContext<'a> { handler: &Handler, symbol: &Ident, ) -> Result { - resolve_symbol_and_mod_path( + resolve_call_path( handler, self.engines(), - self.namespace().root_module(), + self.namespace().root(), self.namespace().mod_path(), - symbol, + &symbol.clone().into(), self.self_type(), + VisibilityCheck::No, ) - .map(|d| d.0.expect_typed()) + .map(|d| d.expect_typed()) } /// Short-hand for calling [Root::resolve_call_path_with_visibility_check] on `root` with the `mod_path`. diff --git a/sway-core/src/semantic_analysis/type_resolve.rs b/sway-core/src/semantic_analysis/type_resolve.rs index bfa7c9261ac..e455f92bdbe 100644 --- a/sway-core/src/semantic_analysis/type_resolve.rs +++ b/sway-core/src/semantic_analysis/type_resolve.rs @@ -380,7 +380,7 @@ pub fn resolve_call_path( Ok(decl) } -pub fn resolve_symbol_and_mod_path( +fn resolve_symbol_and_mod_path( handler: &Handler, engines: &Engines, module: &Module, diff --git a/sway-core/src/type_system/ast_elements/type_parameter.rs b/sway-core/src/type_system/ast_elements/type_parameter.rs index a5a0fa5fed8..b8ca628e24d 100644 --- a/sway-core/src/type_system/ast_elements/type_parameter.rs +++ b/sway-core/src/type_system/ast_elements/type_parameter.rs @@ -230,10 +230,7 @@ impl TypeParameter { ctx: &TypeCheckContext, tc: &TraitConstraint, ) -> Vec { - match ctx - .resolve_call_path(handler, &tc.trait_name) - .ok() - { + match ctx.resolve_call_path(handler, &tc.trait_name).ok() { Some(ty::TyDecl::TraitDecl(ty::TraitDecl { decl_id, .. })) => { let trait_decl = ctx.engines.de().get_trait(&decl_id); let mut result = trait_decl