Skip to content

Commit 9ee421b

Browse files
committed
clippy and fmt issues
1 parent 3732d1d commit 9ee421b

File tree

3 files changed

+71
-39
lines changed

3 files changed

+71
-39
lines changed

sway-core/src/semantic_analysis/type_resolve.rs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ use sway_error::{
55
use sway_types::{Ident, Span, Spanned};
66

77
use crate::{
8-
ast_elements::type_parameter::ConstGenericExpr, language::{
9-
ty::{self, TyTraitItem}, CallPath, CallPathType, QualifiedCallPath
10-
}, monomorphization::type_decl_opt_to_type_id, namespace::{Module, ModulePath, ResolvedDeclaration, ResolvedTraitImplItem}, type_system::SubstTypes, EnforceTypeArguments, Engines, Namespace, SubstTypesContext, TypeId, TypeInfo
8+
ast_elements::type_parameter::ConstGenericExpr,
9+
language::{
10+
ty::{self, TyTraitItem},
11+
CallPath, CallPathType, QualifiedCallPath,
12+
},
13+
monomorphization::type_decl_opt_to_type_id,
14+
namespace::{Module, ModulePath, ResolvedDeclaration, ResolvedTraitImplItem},
15+
type_system::SubstTypes,
16+
EnforceTypeArguments, Engines, Namespace, SubstTypesContext, TypeId, TypeInfo,
1117
};
1218

1319
use super::namespace::TraitMap;
@@ -27,20 +33,21 @@ fn resolve_const_generics_ambiguous(
2733
mod_path: &ModulePath,
2834
self_type: Option<TypeId>,
2935
) -> Result<(), ErrorEmitted> {
30-
match expr {
31-
ConstGenericExpr::AmbiguousVariableExpression { ident } => {
32-
let _ = resolve_call_path(
33-
handler,
34-
engines,
35-
namespace,
36-
mod_path,
37-
&CallPath { prefixes: vec![], suffix: ident.clone(), callpath_type: CallPathType::Ambiguous },
38-
self_type,
39-
VisibilityCheck::No,
40-
)
41-
.map(|d| d.expect_typed())?;
42-
},
43-
_ => {}
36+
if let ConstGenericExpr::AmbiguousVariableExpression { ident } = expr {
37+
let _ = resolve_call_path(
38+
handler,
39+
engines,
40+
namespace,
41+
mod_path,
42+
&CallPath {
43+
prefixes: vec![],
44+
suffix: ident.clone(),
45+
callpath_type: CallPathType::Ambiguous,
46+
},
47+
self_type,
48+
VisibilityCheck::No,
49+
)
50+
.map(|d| d.expect_typed())?;
4451
}
4552
Ok(())
4653
}
@@ -115,7 +122,14 @@ pub fn resolve_type(
115122
check_visibility,
116123
)
117124
.unwrap_or_else(|err| engines.te().id_of_error_recovery(err));
118-
resolve_const_generics_ambiguous(length.expr(), handler, engines, namespace, mod_path, self_type)?;
125+
resolve_const_generics_ambiguous(
126+
length.expr(),
127+
handler,
128+
engines,
129+
namespace,
130+
mod_path,
131+
self_type,
132+
)?;
119133

120134
engines.te().insert_array(engines, elem_ty, length.clone())
121135
}
@@ -209,7 +223,14 @@ pub fn resolve_type(
209223
engines.te().insert_ref(engines, *to_mutable_value, ty)
210224
}
211225
TypeInfo::StringArray(length) => {
212-
resolve_const_generics_ambiguous(length.expr(), handler, engines, namespace, mod_path, self_type)?;
226+
resolve_const_generics_ambiguous(
227+
length.expr(),
228+
handler,
229+
engines,
230+
namespace,
231+
mod_path,
232+
self_type,
233+
)?;
213234
type_id
214235
}
215236
_ => type_id,

sway-core/src/type_system/monomorphization.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
use crate::{
2+
decl_engine::{engine::DeclEngineGetParsedDeclId, DeclEngineInsert, MaterializeConstGenerics},
3+
language::{
4+
ty::{self, TyExpression},
5+
CallPath,
6+
},
7+
namespace::{ModulePath, ResolvedDeclaration},
8+
semantic_analysis::type_resolve::{resolve_type, VisibilityCheck},
9+
type_system::ast_elements::create_type_id::CreateTypeId,
10+
EnforceTypeArguments, Engines, GenericArgument, Namespace, SubstTypes, SubstTypesContext,
11+
TypeId, TypeParameter, TypeSubstMap,
12+
};
113
use std::collections::BTreeMap;
2-
314
use sway_error::{
415
error::CompileError,
516
handler::{ErrorEmitted, Handler},
617
};
7-
use sway_types::{Ident, Named, Span, Spanned};
8-
9-
use crate::{
10-
decl_engine::{engine::DeclEngineGetParsedDeclId, DeclEngineInsert, MaterializeConstGenerics}, engine_threading::DebugWithEngines, language::{
11-
ty::{self, TyExpression},
12-
CallPath,
13-
}, namespace::{ModulePath, ResolvedDeclaration}, semantic_analysis::type_resolve::{resolve_type, VisibilityCheck}, type_system::ast_elements::create_type_id::CreateTypeId, EnforceTypeArguments, Engines, GenericArgument, Namespace, SubstTypes, SubstTypesContext, TypeId, TypeParameter, TypeSubstMap
14-
};
18+
use sway_types::{Ident, Span, Spanned};
1519

1620
pub(crate) trait MonomorphizeHelper {
1721
fn name(&self) -> &Ident;
@@ -115,7 +119,7 @@ where
115119

116120
let params = value.type_parameters();
117121
let args = type_arguments.iter_mut();
118-
122+
119123
for (param, arg) in params.iter().zip(args) {
120124
// eprintln!(" {} {}", param.name(), arg.span().as_str());
121125

@@ -135,28 +139,37 @@ where
135139
VisibilityCheck::Yes,
136140
)
137141
.unwrap_or_else(|err| engines.te().id_of_error_recovery(err));
138-
},
142+
}
139143
(TypeParameter::Const(_), GenericArgument::Type(arg)) => {
140-
let suffix = arg.call_path_tree.as_ref().unwrap().qualified_call_path.call_path.suffix.clone();
144+
let suffix = arg
145+
.call_path_tree
146+
.as_ref()
147+
.unwrap()
148+
.qualified_call_path
149+
.call_path
150+
.suffix
151+
.clone();
141152
let _ = crate::semantic_analysis::type_resolve::resolve_call_path(
142153
handler,
143154
engines,
144155
namespace,
145156
mod_path,
146-
&CallPath { prefixes: vec![], suffix, callpath_type: crate::language::CallPathType::Ambiguous },
157+
&CallPath {
158+
prefixes: vec![],
159+
suffix,
160+
callpath_type: crate::language::CallPathType::Ambiguous,
161+
},
147162
self_type,
148163
VisibilityCheck::No,
149164
)
150165
.map(|d| d.expect_typed())?;
151-
},
166+
}
152167
(TypeParameter::Type(_), GenericArgument::Const(_)) => todo!(),
153168
(TypeParameter::Const(_), GenericArgument::Const(_)) => todo!(),
154169
// GenericArgument::Const(arg) => {
155-
170+
156171
// },
157172
}
158-
159-
160173
}
161174

162175
let mut params = vec![];

sway-core/src/type_system/unify/unifier.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,7 @@ impl<'a> Unifier<'a> {
485485
span,
486486
);
487487
}
488-
(None, None) => {
489-
490-
},
488+
(None, None) => {},
491489
}
492490
}
493491
_ => {

0 commit comments

Comments
 (0)