Skip to content

Commit

Permalink
Clippy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Aug 28, 2024
1 parent fd8c1ce commit 20b93ce
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ty::TyTraitType {
handler,
engines,
trait_type_decl.name.clone(),
Declaration::TraitTypeDeclaration(decl_id.clone()),
Declaration::TraitTypeDeclaration(*decl_id),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl TyTypeAliasDecl {
handler,
engines,
type_alias.name.clone(),
Declaration::TypeAliasDeclaration(decl_id.clone()),
Declaration::TypeAliasDeclaration(*decl_id),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand All @@ -165,20 +165,20 @@ 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);
});
}
ExpressionKind::TupleIndex(expr) => {
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);
});
}
Expand All @@ -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)
Expand All @@ -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);
});
}
Expand All @@ -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);
});
}
Expand All @@ -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);
});
}
Expand All @@ -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(())
Expand Down
11 changes: 4 additions & 7 deletions sway-core/src/semantic_analysis/namespace/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ impl Module {
pub fn enter_lexical_scope(
&mut self,
handler: &Handler,
engines: &Engines,
span: Span,
) -> Result<LexicalScopeId, ErrorEmitted> {
let id_opt = self.lexical_scopes_spans.get(&span);
Expand All @@ -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(),
))),
}
}

Expand Down
6 changes: 3 additions & 3 deletions sway-core/src/semantic_analysis/symbol_collection_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ impl SymbolCollectionContext {
span: Span,
with_ctx: impl FnOnce(&mut SymbolCollectionContext) -> Result<T, ErrorEmitted>,
) -> Result<T, ErrorEmitted> {
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)
Expand Down

0 comments on commit 20b93ce

Please sign in to comment.