Skip to content

Commit b5eca5f

Browse files
committed
collapsible_if
1 parent 3409645 commit b5eca5f

File tree

7 files changed

+49
-53
lines changed

7 files changed

+49
-53
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ new_ret_no_self = "allow"
169169
## Following lints should be tackled at some point
170170
borrowed_box = "allow"
171171
borrow_deref_ref = "allow"
172-
collapsible_if = "allow"
173172
collapsible_match = "allow"
174173
clone_on_copy = "allow"
175174
derivable_impls = "allow"

crates/hir-ty/src/mir/eval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,10 +1842,10 @@ impl Evaluator<'_> {
18421842
}
18431843
}
18441844
let layout = self.layout(ty);
1845-
if self.assert_placeholder_ty_is_unused {
1846-
if matches!(layout, Err(MirEvalError::LayoutError(LayoutError::HasPlaceholder, _))) {
1847-
return Ok(Some((0, 1)));
1848-
}
1845+
if self.assert_placeholder_ty_is_unused
1846+
&& matches!(layout, Err(MirEvalError::LayoutError(LayoutError::HasPlaceholder, _)))
1847+
{
1848+
return Ok(Some((0, 1)));
18491849
}
18501850
let layout = layout?;
18511851
Ok(layout

crates/hir-ty/src/mir/lower.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,10 +948,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
948948
// for binary operator, and use without adjust to simplify our conditions.
949949
let lhs_ty = self.expr_ty_without_adjust(*lhs);
950950
let rhs_ty = self.expr_ty_without_adjust(*rhs);
951-
if matches!(op, BinaryOp::CmpOp(syntax::ast::CmpOp::Eq { .. })) {
952-
if lhs_ty.as_raw_ptr().is_some() && rhs_ty.as_raw_ptr().is_some() {
953-
break 'b true;
954-
}
951+
if matches!(op, BinaryOp::CmpOp(syntax::ast::CmpOp::Eq { .. }))
952+
&& lhs_ty.as_raw_ptr().is_some()
953+
&& rhs_ty.as_raw_ptr().is_some()
954+
{
955+
break 'b true;
955956
}
956957
let builtin_inequal_impls = matches!(
957958
op,

crates/ide-assists/src/handlers/generate_getter_or_setter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,8 @@ fn build_source_change(
377377
};
378378

379379
// Insert `$0` only for last getter we generate
380-
if i == record_fields_count - 1 {
381-
if ctx.config.snippet_cap.is_some() {
382-
getter_buf = getter_buf.replacen("fn ", "fn $0", 1);
383-
}
380+
if i == record_fields_count - 1 && ctx.config.snippet_cap.is_some() {
381+
getter_buf = getter_buf.replacen("fn ", "fn $0", 1);
384382
}
385383

386384
// For first element we do not merge with '\n', as

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,20 @@ fn completion_item(
310310

311311
set_score(&mut lsp_item, max_relevance, item.relevance);
312312

313-
if config.completion().enable_imports_on_the_fly {
314-
if !item.import_to_add.is_empty() {
315-
let imports: Vec<_> = item
316-
.import_to_add
317-
.into_iter()
318-
.filter_map(|(import_path, import_name)| {
319-
Some(lsp_ext::CompletionImport {
320-
full_import_path: import_path,
321-
imported_name: import_name,
322-
})
313+
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
314+
let imports: Vec<_> = item
315+
.import_to_add
316+
.into_iter()
317+
.filter_map(|(import_path, import_name)| {
318+
Some(lsp_ext::CompletionImport {
319+
full_import_path: import_path,
320+
imported_name: import_name,
323321
})
324-
.collect();
325-
if !imports.is_empty() {
326-
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
327-
lsp_item.data = Some(to_value(data).unwrap());
328-
}
322+
})
323+
.collect();
324+
if !imports.is_empty() {
325+
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
326+
lsp_item.data = Some(to_value(data).unwrap());
329327
}
330328
}
331329

crates/rust-analyzer/src/main_loop.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,10 @@ impl GlobalState {
579579
let path = VfsPath::from(path);
580580
// if the file is in mem docs, it's managed by the client via notifications
581581
// so only set it if its not in there
582-
if !self.mem_docs.contains(&path) {
583-
if is_changed || vfs.file_id(&path).is_none() {
584-
vfs.set_file_contents(path, contents);
585-
}
582+
if !self.mem_docs.contains(&path)
583+
&& (is_changed || vfs.file_id(&path).is_none())
584+
{
585+
vfs.set_file_contents(path, contents);
586586
}
587587
}
588588
}

crates/rust-analyzer/src/reload.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -454,27 +454,27 @@ impl GlobalState {
454454
let files_config = self.config.files();
455455
let project_folders = ProjectFolders::new(&self.workspaces, &files_config.exclude);
456456

457-
if self.proc_macro_clients.is_empty() || !same_workspaces {
458-
if self.config.expand_proc_macros() {
459-
tracing::info!("Spawning proc-macro servers");
460-
461-
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
462-
let path = match self.config.proc_macro_srv() {
463-
Some(path) => path,
464-
None => ws.find_sysroot_proc_macro_srv()?,
465-
};
466-
467-
tracing::info!("Using proc-macro server at {path}");
468-
ProcMacroServer::spawn(path.clone()).map_err(|err| {
469-
tracing::error!(
470-
"Failed to run proc-macro server from path {path}, error: {err:?}",
471-
);
472-
anyhow::format_err!(
473-
"Failed to run proc-macro server from path {path}, error: {err:?}",
474-
)
475-
})
476-
}))
477-
};
457+
if (self.proc_macro_clients.is_empty() || !same_workspaces)
458+
&& self.config.expand_proc_macros()
459+
{
460+
tracing::info!("Spawning proc-macro servers");
461+
462+
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
463+
let path = match self.config.proc_macro_srv() {
464+
Some(path) => path,
465+
None => ws.find_sysroot_proc_macro_srv()?,
466+
};
467+
468+
tracing::info!("Using proc-macro server at {path}");
469+
ProcMacroServer::spawn(path.clone()).map_err(|err| {
470+
tracing::error!(
471+
"Failed to run proc-macro server from path {path}, error: {err:?}",
472+
);
473+
anyhow::format_err!(
474+
"Failed to run proc-macro server from path {path}, error: {err:?}",
475+
)
476+
})
477+
}))
478478
}
479479

480480
let watch = match files_config.watcher {

0 commit comments

Comments
 (0)