mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Auto merge of #16451 - Urhengulas:satisfy-clippy, r=Veykril
internal: Work through temporarily allowed clippy lints, part 2 Another follow-up to https://github.com/rust-lang/rust-analyzer/pull/16401.
This commit is contained in:
commit
850ba2fb63
39 changed files with 136 additions and 149 deletions
|
@ -58,12 +58,14 @@ impl flags::AnalysisStats {
|
|||
Rand32::new(seed)
|
||||
};
|
||||
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = match self.no_sysroot {
|
||||
true => None,
|
||||
false => Some(RustLibSource::Discover),
|
||||
let cargo_config = CargoConfig {
|
||||
sysroot: match self.no_sysroot {
|
||||
true => None,
|
||||
false => Some(RustLibSource::Discover),
|
||||
},
|
||||
sysroot_query_metadata: self.query_sysroot_metadata,
|
||||
..Default::default()
|
||||
};
|
||||
cargo_config.sysroot_query_metadata = self.query_sysroot_metadata;
|
||||
let no_progress = &|_| ();
|
||||
|
||||
let mut db_load_sw = self.stop_watch();
|
||||
|
|
|
@ -13,8 +13,8 @@ use crate::cli::flags;
|
|||
|
||||
impl flags::Diagnostics {
|
||||
pub fn run(self) -> anyhow::Result<()> {
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
let cargo_config =
|
||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||
let with_proc_macro_server = if let Some(p) = &self.proc_macro_srv {
|
||||
let path = vfs::AbsPathBuf::assert(std::env::current_dir()?.join(p));
|
||||
ProcMacroServerChoice::Explicit(path)
|
||||
|
|
|
@ -287,8 +287,8 @@ impl flags::Lsif {
|
|||
pub fn run(self) -> anyhow::Result<()> {
|
||||
eprintln!("Generating LSIF started...");
|
||||
let now = Instant::now();
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
let cargo_config =
|
||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||
let no_progress = &|_| ();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
|
|
|
@ -13,8 +13,8 @@ use crate::cli::{flags, full_name_of_item, Result};
|
|||
|
||||
impl flags::RunTests {
|
||||
pub fn run(self) -> Result<()> {
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
let cargo_config =
|
||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
|
||||
|
|
|
@ -59,8 +59,8 @@ impl Tester {
|
|||
path.push("ra-rustc-test.rs");
|
||||
let tmp_file = AbsPathBuf::try_from(path).unwrap();
|
||||
std::fs::write(&tmp_file, "")?;
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
let cargo_config =
|
||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||
let workspace = ProjectWorkspace::DetachedFiles {
|
||||
files: vec![tmp_file.clone()],
|
||||
sysroot: Ok(Sysroot::discover(
|
||||
|
|
|
@ -10,8 +10,8 @@ use crate::cli::flags;
|
|||
impl flags::Ssr {
|
||||
pub fn run(self) -> anyhow::Result<()> {
|
||||
use ide_db::base_db::SourceDatabaseExt;
|
||||
let mut cargo_config = CargoConfig::default();
|
||||
cargo_config.sysroot = Some(RustLibSource::Discover);
|
||||
let cargo_config =
|
||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
|
||||
|
|
|
@ -32,6 +32,7 @@ use project_model::{
|
|||
};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use stdx::format_to_acc;
|
||||
use vfs::{AbsPath, AbsPathBuf};
|
||||
|
||||
use crate::{
|
||||
|
@ -1744,7 +1745,7 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn main_loop_num_threads(&self) -> usize {
|
||||
self.data.numThreads.unwrap_or(num_cpus::get_physical().try_into().unwrap_or(1))
|
||||
self.data.numThreads.unwrap_or(num_cpus::get_physical())
|
||||
}
|
||||
|
||||
pub fn typing_autoclose_angle(&self) -> bool {
|
||||
|
@ -2563,14 +2564,13 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
|||
|
||||
#[cfg(test)]
|
||||
fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
|
||||
fields
|
||||
.iter()
|
||||
.map(|(field, _ty, doc, default)| {
|
||||
let name = format!("rust-analyzer.{}", field.replace('_', "."));
|
||||
let doc = doc_comment_to_string(doc);
|
||||
if default.contains('\n') {
|
||||
format!(
|
||||
r#"[[{name}]]{name}::
|
||||
fields.iter().fold(String::new(), |mut acc, (field, _ty, doc, default)| {
|
||||
let name = format!("rust-analyzer.{}", field.replace('_', "."));
|
||||
let doc = doc_comment_to_string(doc);
|
||||
if default.contains('\n') {
|
||||
format_to_acc!(
|
||||
acc,
|
||||
r#"[[{name}]]{name}::
|
||||
+
|
||||
--
|
||||
Default:
|
||||
|
@ -2580,16 +2580,17 @@ Default:
|
|||
{doc}
|
||||
--
|
||||
"#
|
||||
)
|
||||
} else {
|
||||
format!("[[{name}]]{name} (default: `{default}`)::\n+\n--\n{doc}--\n")
|
||||
}
|
||||
})
|
||||
.collect::<String>()
|
||||
)
|
||||
} else {
|
||||
format_to_acc!(acc, "[[{name}]]{name} (default: `{default}`)::\n+\n--\n{doc}--\n")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn doc_comment_to_string(doc: &[&str]) -> String {
|
||||
doc.iter().map(|it| it.strip_prefix(' ').unwrap_or(it)).map(|it| format!("{it}\n")).collect()
|
||||
doc.iter()
|
||||
.map(|it| it.strip_prefix(' ').unwrap_or(it))
|
||||
.fold(String::new(), |mut acc, it| format_to_acc!(acc, "{it}\n"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -312,16 +312,14 @@ fn completion_item(
|
|||
set_score(&mut lsp_item, max_relevance, item.relevance);
|
||||
|
||||
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
|
||||
let imports: Vec<_> = item
|
||||
let imports = 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,
|
||||
})
|
||||
.map(|(import_path, import_name)| lsp_ext::CompletionImport {
|
||||
full_import_path: import_path,
|
||||
imported_name: import_name,
|
||||
})
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
if !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
|
|
|
@ -31,6 +31,7 @@ use lsp_types::{
|
|||
};
|
||||
use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams};
|
||||
use serde_json::json;
|
||||
use stdx::format_to_acc;
|
||||
use test_utils::skip_slow_tests;
|
||||
|
||||
use crate::{
|
||||
|
@ -591,8 +592,10 @@ fn diagnostics_dont_block_typing() {
|
|||
return;
|
||||
}
|
||||
|
||||
let librs: String = (0..10).map(|i| format!("mod m{i};")).collect();
|
||||
let libs: String = (0..10).map(|i| format!("//- /src/m{i}.rs\nfn foo() {{}}\n\n")).collect();
|
||||
let librs: String = (0..10).fold(String::new(), |mut acc, i| format_to_acc!(acc, "mod m{i};"));
|
||||
let libs: String = (0..10).fold(String::new(), |mut acc, i| {
|
||||
format_to_acc!(acc, "//- /src/m{i}.rs\nfn foo() {{}}\n\n")
|
||||
});
|
||||
let server = Project::with_fixture(&format!(
|
||||
r#"
|
||||
//- /Cargo.toml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue