mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
collapsible_if
This commit is contained in:
parent
3409645c3f
commit
b5eca5f2fc
7 changed files with 47 additions and 51 deletions
|
@ -169,7 +169,6 @@ new_ret_no_self = "allow"
|
|||
## Following lints should be tackled at some point
|
||||
borrowed_box = "allow"
|
||||
borrow_deref_ref = "allow"
|
||||
collapsible_if = "allow"
|
||||
collapsible_match = "allow"
|
||||
clone_on_copy = "allow"
|
||||
derivable_impls = "allow"
|
||||
|
|
|
@ -1842,10 +1842,10 @@ impl Evaluator<'_> {
|
|||
}
|
||||
}
|
||||
let layout = self.layout(ty);
|
||||
if self.assert_placeholder_ty_is_unused {
|
||||
if matches!(layout, Err(MirEvalError::LayoutError(LayoutError::HasPlaceholder, _))) {
|
||||
return Ok(Some((0, 1)));
|
||||
}
|
||||
if self.assert_placeholder_ty_is_unused
|
||||
&& matches!(layout, Err(MirEvalError::LayoutError(LayoutError::HasPlaceholder, _)))
|
||||
{
|
||||
return Ok(Some((0, 1)));
|
||||
}
|
||||
let layout = layout?;
|
||||
Ok(layout
|
||||
|
|
|
@ -948,10 +948,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
|||
// for binary operator, and use without adjust to simplify our conditions.
|
||||
let lhs_ty = self.expr_ty_without_adjust(*lhs);
|
||||
let rhs_ty = self.expr_ty_without_adjust(*rhs);
|
||||
if matches!(op, BinaryOp::CmpOp(syntax::ast::CmpOp::Eq { .. })) {
|
||||
if lhs_ty.as_raw_ptr().is_some() && rhs_ty.as_raw_ptr().is_some() {
|
||||
break 'b true;
|
||||
}
|
||||
if matches!(op, BinaryOp::CmpOp(syntax::ast::CmpOp::Eq { .. }))
|
||||
&& lhs_ty.as_raw_ptr().is_some()
|
||||
&& rhs_ty.as_raw_ptr().is_some()
|
||||
{
|
||||
break 'b true;
|
||||
}
|
||||
let builtin_inequal_impls = matches!(
|
||||
op,
|
||||
|
|
|
@ -377,10 +377,8 @@ fn build_source_change(
|
|||
};
|
||||
|
||||
// Insert `$0` only for last getter we generate
|
||||
if i == record_fields_count - 1 {
|
||||
if ctx.config.snippet_cap.is_some() {
|
||||
getter_buf = getter_buf.replacen("fn ", "fn $0", 1);
|
||||
}
|
||||
if i == record_fields_count - 1 && ctx.config.snippet_cap.is_some() {
|
||||
getter_buf = getter_buf.replacen("fn ", "fn $0", 1);
|
||||
}
|
||||
|
||||
// For first element we do not merge with '\n', as
|
||||
|
|
|
@ -310,22 +310,20 @@ fn completion_item(
|
|||
|
||||
set_score(&mut lsp_item, max_relevance, item.relevance);
|
||||
|
||||
if config.completion().enable_imports_on_the_fly {
|
||||
if !item.import_to_add.is_empty() {
|
||||
let imports: Vec<_> = item
|
||||
.import_to_add
|
||||
.into_iter()
|
||||
.filter_map(|(import_path, import_name)| {
|
||||
Some(lsp_ext::CompletionImport {
|
||||
full_import_path: import_path,
|
||||
imported_name: import_name,
|
||||
})
|
||||
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
|
||||
let imports: Vec<_> = item
|
||||
.import_to_add
|
||||
.into_iter()
|
||||
.filter_map(|(import_path, import_name)| {
|
||||
Some(lsp_ext::CompletionImport {
|
||||
full_import_path: import_path,
|
||||
imported_name: import_name,
|
||||
})
|
||||
.collect();
|
||||
if !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,10 +579,10 @@ impl GlobalState {
|
|||
let path = VfsPath::from(path);
|
||||
// if the file is in mem docs, it's managed by the client via notifications
|
||||
// so only set it if its not in there
|
||||
if !self.mem_docs.contains(&path) {
|
||||
if is_changed || vfs.file_id(&path).is_none() {
|
||||
vfs.set_file_contents(path, contents);
|
||||
}
|
||||
if !self.mem_docs.contains(&path)
|
||||
&& (is_changed || vfs.file_id(&path).is_none())
|
||||
{
|
||||
vfs.set_file_contents(path, contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,27 +454,27 @@ impl GlobalState {
|
|||
let files_config = self.config.files();
|
||||
let project_folders = ProjectFolders::new(&self.workspaces, &files_config.exclude);
|
||||
|
||||
if self.proc_macro_clients.is_empty() || !same_workspaces {
|
||||
if self.config.expand_proc_macros() {
|
||||
tracing::info!("Spawning proc-macro servers");
|
||||
if (self.proc_macro_clients.is_empty() || !same_workspaces)
|
||||
&& self.config.expand_proc_macros()
|
||||
{
|
||||
tracing::info!("Spawning proc-macro servers");
|
||||
|
||||
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
|
||||
let path = match self.config.proc_macro_srv() {
|
||||
Some(path) => path,
|
||||
None => ws.find_sysroot_proc_macro_srv()?,
|
||||
};
|
||||
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
|
||||
let path = match self.config.proc_macro_srv() {
|
||||
Some(path) => path,
|
||||
None => ws.find_sysroot_proc_macro_srv()?,
|
||||
};
|
||||
|
||||
tracing::info!("Using proc-macro server at {path}");
|
||||
ProcMacroServer::spawn(path.clone()).map_err(|err| {
|
||||
tracing::error!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
);
|
||||
anyhow::format_err!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
)
|
||||
})
|
||||
}))
|
||||
};
|
||||
tracing::info!("Using proc-macro server at {path}");
|
||||
ProcMacroServer::spawn(path.clone()).map_err(|err| {
|
||||
tracing::error!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
);
|
||||
anyhow::format_err!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
let watch = match files_config.watcher {
|
||||
|
|
Loading…
Reference in a new issue