Skip to content

Commit be22cae

Browse files
committed
fix warning by new version clippy
1 parent 7bf73b0 commit be22cae

9 files changed

Lines changed: 23 additions & 28 deletions

File tree

crates/emmylua_code_analysis/src/compilation/analyzer/doc/type_ref_tags.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@ pub fn analyze_param(analyzer: &mut DocAnalyzer, tag: LuaDocTagParam) -> Option<
182182
};
183183

184184
let nullable = tag.is_nullable();
185-
let mut type_ref = if let Some(lua_doc_type) = tag.get_type() {
185+
let mut type_ref = {
186+
let lua_doc_type = tag.get_type()?;
186187
infer_type(&mut analyzer.type_context, lua_doc_type)
187-
} else {
188-
return None;
189188
};
190189

191190
if nullable && !type_ref.is_nullable() {

crates/emmylua_code_analysis/src/config/config_loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn load_configs_raw(config_files: Vec<PathBuf>, partial_emmyrcs: Option<Vec<
2828
Err(e) => {
2929
log::error!(
3030
"Failed to parse lua config file: {:?}, error: {:?}",
31-
&config_file,
31+
config_file,
3232
e
3333
);
3434
continue;
@@ -40,7 +40,7 @@ pub fn load_configs_raw(config_files: Vec<PathBuf>, partial_emmyrcs: Option<Vec<
4040
Err(e) => {
4141
log::error!(
4242
"Failed to parse config file: {:?}, error: {:?}",
43-
&config_file,
43+
config_file,
4444
e
4545
);
4646
continue;

crates/emmylua_code_analysis/src/db_index/module/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ impl LuaModuleIndex {
164164
let node = self.module_nodes.get_mut(&parent_node_id)?;
165165

166166
node.file_ids.push(file_id);
167-
let module_name = match module_parts.last() {
168-
Some(name) => name.to_string(),
169-
None => return None,
167+
let module_name = {
168+
let name = module_parts.last()?;
169+
name.to_string()
170170
};
171171
let module_info = ModuleInfo {
172172
file_id,
@@ -274,9 +274,9 @@ impl LuaModuleIndex {
274274
let mut parent_node_id = self.module_root_id;
275275
for part in module_parts {
276276
let parent_node = self.module_nodes.get(&parent_node_id)?;
277-
let child_id = match parent_node.children.get(*part) {
278-
Some(id) => *id,
279-
None => return None,
277+
let child_id = {
278+
let id = parent_node.children.get(*part)?;
279+
*id
280280
};
281281
parent_node_id = child_id;
282282
}

crates/emmylua_code_analysis/src/db_index/type/type_decl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ impl Serialize for LuaTypeDeclId {
317317
match self.id.as_ref() {
318318
LuaTypeIdentifier::Global(name) => serializer.serialize_str(name.as_ref()),
319319
LuaTypeIdentifier::Internal(workspace_id, name) => {
320-
let s = format!("ws:{}|{}", workspace_id.id, &name);
320+
let s = format!("ws:{}|{}", workspace_id.id, name);
321321
serializer.serialize_str(&s)
322322
}
323323
LuaTypeIdentifier::File(file_id, name) => {
324-
let s = format!("{}|{}", file_id.id, &name);
324+
let s = format!("{}|{}", file_id.id, name);
325325
serializer.serialize_str(&s)
326326
}
327327
}

crates/emmylua_code_analysis/src/semantic/infer/infer_index/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ pub fn get_index_expr_var_ref_id(
140140
cache: &mut LuaInferCache,
141141
index_expr: &LuaIndexExpr,
142142
) -> Option<VarRefId> {
143-
let access_path = match index_expr.get_access_path() {
144-
Some(path) => ArcIntern::new(SmolStr::new(&path)),
145-
None => return None,
143+
let access_path = {
144+
let path = index_expr.get_access_path()?;
145+
ArcIntern::new(SmolStr::new(&path))
146146
};
147147

148148
let mut prefix_expr = index_expr.get_prefix_expr()?;

crates/emmylua_code_analysis/src/semantic/member/find_members.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ fn find_namespace_members(
663663
overload_index: None,
664664
});
665665
} else {
666-
let ns_type = LuaType::Namespace(SmolStr::new(format!("{}.{}", ns, &name)).into());
666+
let ns_type = LuaType::Namespace(SmolStr::new(format!("{}.{}", ns, name)).into());
667667
members.push(LuaMemberInfo {
668668
property_owner_id: None,
669669
key: member_key,

crates/emmylua_code_analysis/src/semantic/semantic_info/infer_expr_semantic_decl.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,10 @@ fn infer_require_module_semantic_decl(
129129
let first_arg = call_expr.get_args_list()?.get_args().next()?;
130130
let module_path = match first_arg {
131131
LuaExpr::LiteralExpr(literal_expr) => {
132-
if let Some(literal_token) = literal_expr.get_literal() {
133-
match literal_token {
134-
LuaLiteralToken::String(string_token) => string_token.get_value(),
135-
_ => return None,
136-
}
137-
} else {
138-
return None;
132+
let literal_token = literal_expr.get_literal()?;
133+
match literal_token {
134+
LuaLiteralToken::String(string_token) => string_token.get_value(),
135+
_ => return None,
139136
}
140137
}
141138
_ => return None,

crates/emmylua_ls/src/context/file_diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl FileDiagnostic {
124124
#[allow(unused)]
125125
pub async fn cancel_all(&self) {
126126
let mut tokens = self.diagnostic_tokens.lock().await;
127-
for (_, token) in tokens.iter() {
127+
for token in tokens.values() {
128128
token.cancel();
129129
}
130130
tokens.clear();

crates/emmylua_ls/src/handlers/rename/rename_decl.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ fn rename_doc_param(
108108
let closure_expr = param_node.ancestors::<LuaClosureExpr>().next()?;
109109
let comments = if let Some(table_field) = closure_expr.get_parent::<LuaTableField>() {
110110
table_field.get_comments()
111-
} else if let Some(stat) = closure_expr.ancestors::<LuaStat>().next() {
112-
stat.get_comments()
113111
} else {
114-
return None;
112+
let stat = closure_expr.ancestors::<LuaStat>().next()?;
113+
stat.get_comments()
115114
};
116115

117116
let document = semantic_model.get_document();

0 commit comments

Comments
 (0)