diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/abi.rs b/sway-core/src/semantic_analysis/ast_node/declaration/abi.rs index dd14633f799..bb0bc9e2fb8 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/abi.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/abi.rs @@ -43,7 +43,7 @@ impl ty::TyAbiDecl { handler, engines, abi_decl.name.clone(), - Declaration::AbiDeclaration(decl_id.clone()), + Declaration::AbiDeclaration(*decl_id), )?; let _ = ctx.scoped(engines, abi_decl.span.clone(), |scoped_ctx| { diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/configurable.rs b/sway-core/src/semantic_analysis/ast_node/declaration/configurable.rs index 5e37e5d5c22..2c5319b6b1f 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/configurable.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/configurable.rs @@ -33,7 +33,7 @@ impl ty::TyConfigurableDecl { handler, engines, configurable_decl.name.clone(), - Declaration::ConfigurableDeclaration(decl_id.clone()), + Declaration::ConfigurableDeclaration(*decl_id), )?; if let Some(value) = &configurable_decl.value { TyExpression::collect(handler, engines, ctx, value)?; diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/constant.rs b/sway-core/src/semantic_analysis/ast_node/declaration/constant.rs index 98e92137612..615ca02a280 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/constant.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/constant.rs @@ -28,7 +28,7 @@ impl ty::TyConstantDecl { handler, engines, constant_decl.name.clone(), - Declaration::ConstantDeclaration(decl_id.clone()), + Declaration::ConstantDeclaration(*decl_id), )?; if let Some(value) = &constant_decl.value { TyExpression::collect(handler, engines, ctx, value)?; diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs b/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs index 73fb6b3ea77..7dc878e858f 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/enum.rs @@ -20,7 +20,7 @@ impl ty::TyEnumDecl { handler, engines, enum_decl.name.clone(), - Declaration::EnumDeclaration(decl_id.clone()), + Declaration::EnumDeclaration(*decl_id), )?; // create a namespace for the decl, used to create a scope for generics diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/function.rs b/sway-core/src/semantic_analysis/ast_node/declaration/function.rs index dbffe946ae8..31e10d4538a 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/function.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/function.rs @@ -32,7 +32,7 @@ impl ty::TyFunctionDecl { handler, engines, fn_decl.name.clone(), - Declaration::FunctionDeclaration(decl_id.clone()), + Declaration::FunctionDeclaration(*decl_id), ); // create a namespace for the function diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs index 44835142fb5..fdba8b59565 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs @@ -43,7 +43,7 @@ impl TyImplSelfOrTrait { handler, engines, impl_trait.trait_name.suffix.clone(), - Declaration::ImplSelfOrTrait(decl_id.clone()), + Declaration::ImplSelfOrTrait(*decl_id), )?; let _ = ctx.scoped(engines, impl_trait.block_span.clone(), |scoped_ctx| { diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/struct.rs b/sway-core/src/semantic_analysis/ast_node/declaration/struct.rs index 5ed0c052714..77688776b3b 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/struct.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/struct.rs @@ -20,7 +20,7 @@ impl ty::TyStructDecl { handler, engines, struct_decl.name.clone(), - Declaration::StructDeclaration(decl_id.clone()), + Declaration::StructDeclaration(*decl_id), )?; // create a namespace for the decl, used to create a scope for generics diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/trait.rs b/sway-core/src/semantic_analysis/ast_node/declaration/trait.rs index bbc0b45151a..db60470def1 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/trait.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/trait.rs @@ -57,7 +57,7 @@ impl TyTraitDecl { handler, engines, trait_decl.name.clone(), - Declaration::TraitDeclaration(decl_id.clone()), + Declaration::TraitDeclaration(*decl_id), )?; // A temporary namespace for checking within the trait's scope. diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/trait_fn.rs b/sway-core/src/semantic_analysis/ast_node/declaration/trait_fn.rs index 9632162e785..e6b45f08919 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/trait_fn.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/trait_fn.rs @@ -31,7 +31,7 @@ impl ty::TyTraitFn { handler, engines, trait_fn.name.clone(), - Declaration::TraitFnDeclaration(decl_id.clone()), + Declaration::TraitFnDeclaration(*decl_id), )?; let _ = ctx.scoped(engines, trait_fn.span.clone(), |_scoped_ctx| Ok(())); Ok(()) diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/trait_type.rs b/sway-core/src/semantic_analysis/ast_node/declaration/trait_type.rs index d4e7b31d762..c387ecdb27b 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/trait_type.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/trait_type.rs @@ -31,7 +31,7 @@ impl ty::TyTraitType { handler, engines, trait_type_decl.name.clone(), - Declaration::TraitTypeDeclaration(decl_id.clone()), + Declaration::TraitTypeDeclaration(*decl_id), ) } diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/type_alias.rs b/sway-core/src/semantic_analysis/ast_node/declaration/type_alias.rs index aade03d6537..7bcf3fb06c3 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/type_alias.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/type_alias.rs @@ -24,7 +24,7 @@ impl TyTypeAliasDecl { handler, engines, type_alias.name.clone(), - Declaration::TypeAliasDeclaration(decl_id.clone()), + Declaration::TypeAliasDeclaration(*decl_id), ) } } diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/variable.rs b/sway-core/src/semantic_analysis/ast_node/declaration/variable.rs index 2023456519f..8ed4f3b7258 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/variable.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/variable.rs @@ -24,7 +24,7 @@ impl ty::TyVariableDecl { handler, engines, var_decl.name.clone(), - Declaration::VariableDeclaration(decl_id.clone()), + Declaration::VariableDeclaration(*decl_id), )?; TyExpression::collect(handler, engines, ctx, &var_decl.body) } 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 fa7ae406c04..865b0ef673a 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 @@ -149,12 +149,12 @@ impl ty::TyExpression { ExpressionKind::Error(_, _) => {} ExpressionKind::Literal(_) => {} ExpressionKind::AmbiguousPathExpression(expr) => { - let _ = expr.args.iter().for_each(|arg_expr| { + expr.args.iter().for_each(|arg_expr| { let _ = Self::collect(handler, engines, ctx, arg_expr); }); } ExpressionKind::FunctionApplication(expr) => { - let _ = expr.arguments.iter().for_each(|arg_expr| { + expr.arguments.iter().for_each(|arg_expr| { let _ = Self::collect(handler, engines, ctx, arg_expr); }); } @@ -165,7 +165,7 @@ impl ty::TyExpression { ExpressionKind::AmbiguousVariableExpression(_) => {} ExpressionKind::Variable(_) => {} ExpressionKind::Tuple(exprs) => { - let _ = exprs.iter().for_each(|expr| { + exprs.iter().for_each(|expr| { let _ = Self::collect(handler, engines, ctx, expr); }); } @@ -173,12 +173,12 @@ impl ty::TyExpression { Self::collect(handler, engines, ctx, &expr.prefix)?; } ExpressionKind::Array(expr) => { - let _ = expr.contents.iter().for_each(|expr| { - let _ = Self::collect(handler, engines, ctx, &expr); + expr.contents.iter().for_each(|expr| { + let _ = Self::collect(handler, engines, ctx, expr); }); } ExpressionKind::Struct(expr) => { - let _ = expr.fields.iter().for_each(|field| { + expr.fields.iter().for_each(|field| { let _ = Self::collect(handler, engines, ctx, &field.value); }); } @@ -194,7 +194,7 @@ impl ty::TyExpression { } ExpressionKind::Match(expr) => { Self::collect(handler, engines, ctx, &expr.value)?; - let _ = expr.branches.iter().for_each(|branch| { + expr.branches.iter().for_each(|branch| { // create a new namespace for this branch result let _ = ctx.scoped(engines, branch.span.clone(), |scoped_ctx| { Self::collect(handler, engines, scoped_ctx, &branch.result) @@ -203,7 +203,7 @@ impl ty::TyExpression { } ExpressionKind::Asm(_) => {} ExpressionKind::MethodApplication(expr) => { - let _ = expr.arguments.iter().for_each(|expr| { + expr.arguments.iter().for_each(|expr| { let _ = Self::collect(handler, engines, ctx, expr); }); } @@ -212,7 +212,7 @@ impl ty::TyExpression { } ExpressionKind::DelineatedPath(expr) => { if let Some(expr_args) = &expr.args { - let _ = expr_args.iter().for_each(|arg_expr| { + expr_args.iter().for_each(|arg_expr| { let _ = Self::collect(handler, engines, ctx, arg_expr); }); } @@ -226,7 +226,7 @@ impl ty::TyExpression { } ExpressionKind::StorageAccess(_) => {} ExpressionKind::IntrinsicFunction(expr) => { - let _ = expr.arguments.iter().for_each(|arg_expr| { + expr.arguments.iter().for_each(|arg_expr| { let _ = Self::collect(handler, engines, ctx, arg_expr); }); } @@ -250,15 +250,15 @@ impl ty::TyExpression { } Self::collect(handler, engines, ctx, &expr.rhs)?; } - ExpressionKind::ImplicitReturn(expr) => Self::collect(handler, engines, ctx, &expr)?, + ExpressionKind::ImplicitReturn(expr) => Self::collect(handler, engines, ctx, expr)?, ExpressionKind::Return(expr) => { - Self::collect(handler, engines, ctx, &expr)?; + Self::collect(handler, engines, ctx, expr)?; } ExpressionKind::Ref(expr) => { Self::collect(handler, engines, ctx, &expr.value)?; } ExpressionKind::Deref(expr) => { - Self::collect(handler, engines, ctx, &expr)?; + Self::collect(handler, engines, ctx, expr)?; } } Ok(()) diff --git a/sway-core/src/semantic_analysis/namespace/module.rs b/sway-core/src/semantic_analysis/namespace/module.rs index 051b7b61129..d79d60de6b6 100644 --- a/sway-core/src/semantic_analysis/namespace/module.rs +++ b/sway-core/src/semantic_analysis/namespace/module.rs @@ -235,7 +235,6 @@ impl Module { pub fn enter_lexical_scope( &mut self, handler: &Handler, - engines: &Engines, span: Span, ) -> Result { let id_opt = self.lexical_scopes_spans.get(&span); @@ -244,12 +243,10 @@ impl Module { self.current_lexical_scope_id = *id; Ok(*id) } - None => { - return Err(handler.emit_err(CompileError::Internal( - "Could not find a valid lexical scope for this source location.", - span.clone(), - ))) - } + None => Err(handler.emit_err(CompileError::Internal( + "Could not find a valid lexical scope for this source location.", + span.clone(), + ))), } } diff --git a/sway-core/src/semantic_analysis/symbol_collection_context.rs b/sway-core/src/semantic_analysis/symbol_collection_context.rs index 2a3be6aa35d..b60eb6161c6 100644 --- a/sway-core/src/semantic_analysis/symbol_collection_context.rs +++ b/sway-core/src/semantic_analysis/symbol_collection_context.rs @@ -65,9 +65,9 @@ impl SymbolCollectionContext { span: Span, with_ctx: impl FnOnce(&mut SymbolCollectionContext) -> Result, ) -> Result { - self.namespace.module_mut(engines).write(engines, |m| { - m.enter_lexical_scope(handler, engines, span.clone()) - })?; + self.namespace + .module_mut(engines) + .write(engines, |m| m.enter_lexical_scope(handler, span.clone()))?; let ret = with_ctx(self); self.namespace .module_mut(engines)