diff --git a/Cargo.lock b/Cargo.lock index 54cc9d1c68..4310cfc04a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -32,12 +32,6 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" -[[package]] -name = "always-assert" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1078fa1ce1e34b1872d8611ad921196d76bdd7027e949fbe31231abde201892" - [[package]] name = "anyhow" version = "1.0.97" @@ -85,13 +79,11 @@ dependencies = [ "dashmap 5.5.3", "intern", "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lz4_flex", "query-group-macro", "rustc-hash 2.1.1", "salsa", "semver", "span", - "stdx", "syntax", "tracing", "triomphe", @@ -638,12 +630,10 @@ dependencies = [ "bitflags 2.9.0", "cfg", "cov-mark", - "dashmap 5.5.3", "drop_bomb", "either", "expect-test", "fst", - "hashbrown 0.14.5", "hir-expand", "indexmap", "intern", @@ -652,7 +642,6 @@ dependencies = [ "mbe", "query-group-macro", "ra-ap-rustc_abi", - "ra-ap-rustc_hashes", "ra-ap-rustc_parse_format", "rustc-hash 2.1.1", "rustc_apfloat", @@ -679,10 +668,8 @@ dependencies = [ "cov-mark", "either", "expect-test", - "hashbrown 0.14.5", "intern", "itertools", - "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "mbe", "parser", "query-group-macro", @@ -710,7 +697,6 @@ dependencies = [ "chalk-recursive", "chalk-solve", "cov-mark", - "dashmap 5.5.3", "either", "ena", "expect-test", @@ -720,7 +706,6 @@ dependencies = [ "intern", "itertools", "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nohash-hasher", "oorandom", "project-model", "query-group-macro", @@ -951,7 +936,6 @@ dependencies = [ "bitflags 2.9.0", "cov-mark", "crossbeam-channel", - "dashmap 5.5.3", "either", "expect-test", "fst", @@ -1006,9 +990,7 @@ dependencies = [ "hir", "ide-db", "itertools", - "nohash-hasher", "parser", - "stdx", "syntax", "test-fixture", "test-utils", @@ -1206,7 +1188,6 @@ dependencies = [ "ide-db", "intern", "itertools", - "paths", "proc-macro-api", "project-model", "span", @@ -1284,12 +1265,6 @@ dependencies = [ "url", ] -[[package]] -name = "lz4_flex" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" - [[package]] name = "matchers" version = "0.1.0" @@ -1316,7 +1291,6 @@ dependencies = [ "syntax", "syntax-bridge", "test-utils", - "tracing", "tt", ] @@ -1644,7 +1618,6 @@ dependencies = [ "proc-macro-test", "ra-ap-rustc_lexer", "span", - "stdx", "syntax-bridge", "tt", ] @@ -1767,7 +1740,6 @@ name = "query-group-macro" version = "0.0.0" dependencies = [ "expect-test", - "heck", "proc-macro2", "quote", "salsa", @@ -1960,7 +1932,6 @@ dependencies = [ name = "rust-analyzer" version = "0.0.0" dependencies = [ - "always-assert", "anyhow", "base64", "cargo_metadata", @@ -2292,10 +2263,8 @@ dependencies = [ name = "syntax" version = "0.0.0" dependencies = [ - "cov-mark", "either", "expect-test", - "indexmap", "itertools", "parser", "ra-ap-rustc_lexer", @@ -2321,7 +2290,6 @@ dependencies = [ "stdx", "syntax", "test-utils", - "tracing", "tt", ] @@ -2357,7 +2325,6 @@ dependencies = [ "rustc-hash 2.1.1", "stdx", "text-size", - "tracing", ] [[package]] diff --git a/crates/base-db/Cargo.toml b/crates/base-db/Cargo.toml index 4780d5191b..441434504c 100644 --- a/crates/base-db/Cargo.toml +++ b/crates/base-db/Cargo.toml @@ -12,8 +12,6 @@ rust-version.workspace = true [lib] [dependencies] -lz4_flex = { version = "0.11", default-features = false } - la-arena.workspace = true dashmap.workspace = true salsa.workspace = true @@ -25,7 +23,6 @@ tracing.workspace = true # local deps cfg.workspace = true -stdx.workspace = true syntax.workspace = true vfs.workspace = true span.workspace = true diff --git a/crates/hir-def/Cargo.toml b/crates/hir-def/Cargo.toml index 1b1d430ffd..628a78cdea 100644 --- a/crates/hir-def/Cargo.toml +++ b/crates/hir-def/Cargo.toml @@ -15,7 +15,6 @@ rust-version.workspace = true arrayvec.workspace = true bitflags.workspace = true cov-mark = "2.0.0-pre.1" -dashmap.workspace = true drop_bomb = "0.1.5" either.workspace = true fst = { version = "0.4.7", default-features = false } @@ -25,14 +24,12 @@ la-arena.workspace = true rustc-hash.workspace = true tracing.workspace = true smallvec.workspace = true -hashbrown.workspace = true triomphe.workspace = true rustc_apfloat = "0.2.0" text-size.workspace = true salsa.workspace = true query-group.workspace = true -ra-ap-rustc_hashes.workspace = true ra-ap-rustc_parse_format.workspace = true ra-ap-rustc_abi.workspace = true diff --git a/crates/hir-expand/Cargo.toml b/crates/hir-expand/Cargo.toml index 607199a624..5884c0a5a4 100644 --- a/crates/hir-expand/Cargo.toml +++ b/crates/hir-expand/Cargo.toml @@ -16,9 +16,7 @@ cov-mark = "2.0.0-pre.1" tracing.workspace = true either.workspace = true rustc-hash.workspace = true -la-arena.workspace = true itertools.workspace = true -hashbrown.workspace = true smallvec.workspace = true triomphe.workspace = true query-group.workspace = true diff --git a/crates/hir-ty/Cargo.toml b/crates/hir-ty/Cargo.toml index 3007410533..49d0c5e58f 100644 --- a/crates/hir-ty/Cargo.toml +++ b/crates/hir-ty/Cargo.toml @@ -29,9 +29,7 @@ chalk-recursive.workspace = true chalk-derive.workspace = true la-arena.workspace = true triomphe.workspace = true -nohash-hasher.workspace = true typed-arena = "2.0.1" -dashmap.workspace = true indexmap.workspace = true rustc_apfloat = "0.2.0" query-group.workspace = true diff --git a/crates/ide-db/Cargo.toml b/crates/ide-db/Cargo.toml index 8485565233..485a72050f 100644 --- a/crates/ide-db/Cargo.toml +++ b/crates/ide-db/Cargo.toml @@ -15,7 +15,6 @@ rust-version.workspace = true cov-mark = "2.0.0-pre.1" crossbeam-channel.workspace = true tracing.workspace = true -dashmap.workspace = true rayon.workspace = true fst = { version = "0.4.7", default-features = false } rustc-hash.workspace = true diff --git a/crates/ide-ssr/Cargo.toml b/crates/ide-ssr/Cargo.toml index fa75e5a421..39a71c1d65 100644 --- a/crates/ide-ssr/Cargo.toml +++ b/crates/ide-ssr/Cargo.toml @@ -14,18 +14,16 @@ rust-version.workspace = true [dependencies] cov-mark = "2.0.0-pre.1" itertools.workspace = true -triomphe.workspace = true -nohash-hasher.workspace = true # local deps hir.workspace = true ide-db.workspace = true parser.workspace = true -stdx.workspace = true syntax.workspace = true [dev-dependencies] expect-test = "1.4.0" +triomphe.workspace = true # local deps test-utils.workspace = true diff --git a/crates/load-cargo/Cargo.toml b/crates/load-cargo/Cargo.toml index 23fd50a056..91b012e050 100644 --- a/crates/load-cargo/Cargo.toml +++ b/crates/load-cargo/Cargo.toml @@ -21,7 +21,6 @@ tracing.workspace = true hir-expand.workspace = true ide-db.workspace = true -paths.workspace = true proc-macro-api.workspace = true project-model.workspace = true span.workspace = true diff --git a/crates/mbe/Cargo.toml b/crates/mbe/Cargo.toml index e6fbb298eb..6ee505e64e 100644 --- a/crates/mbe/Cargo.toml +++ b/crates/mbe/Cargo.toml @@ -15,12 +15,10 @@ rust-version.workspace = true cov-mark = "2.0.0-pre.1" rustc-hash.workspace = true smallvec.workspace = true -tracing.workspace = true arrayvec.workspace = true ra-ap-rustc_lexer.workspace = true # local deps -syntax.workspace = true parser.workspace = true tt.workspace = true stdx.workspace = true @@ -31,9 +29,10 @@ syntax-bridge.workspace = true [dev-dependencies] test-utils.workspace = true expect-test.workspace = true +syntax.workspace = true [features] -in-rust-tree = ["parser/in-rust-tree", "tt/in-rust-tree", "syntax/in-rust-tree"] +in-rust-tree = ["parser/in-rust-tree", "tt/in-rust-tree"] [lints] workspace = true diff --git a/crates/proc-macro-srv-cli/src/main.rs b/crates/proc-macro-srv-cli/src/main.rs index 0e6b18ecae..c47ed05325 100644 --- a/crates/proc-macro-srv-cli/src/main.rs +++ b/crates/proc-macro-srv-cli/src/main.rs @@ -1,6 +1,7 @@ //! A standalone binary for `proc-macro-srv`. //! Driver for proc macro server #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] +#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))] #![allow(clippy::print_stderr)] #[cfg(feature = "in-rust-tree")] diff --git a/crates/proc-macro-srv/Cargo.toml b/crates/proc-macro-srv/Cargo.toml index d3b56b402e..8fd675d0d3 100644 --- a/crates/proc-macro-srv/Cargo.toml +++ b/crates/proc-macro-srv/Cargo.toml @@ -13,11 +13,9 @@ rust-version.workspace = true [dependencies] object.workspace = true -libc.workspace = true libloading.workspace = true memmap2.workspace = true -stdx.workspace = true tt.workspace = true syntax-bridge.workspace = true paths.workspace = true @@ -27,6 +25,9 @@ intern.workspace = true ra-ap-rustc_lexer.workspace = true +[target.'cfg(unix)'.dependencies] +libc.workspace = true + [dev-dependencies] expect-test.workspace = true diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs index 4f817b6bc0..2623b2d45c 100644 --- a/crates/proc-macro-srv/src/lib.rs +++ b/crates/proc-macro-srv/src/lib.rs @@ -11,6 +11,7 @@ //! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)… #![cfg(any(feature = "sysroot-abi", rust_analyzer))] +#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))] #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)] #![allow(unreachable_pub, internal_features, clippy::disallowed_types, clippy::print_stderr)] diff --git a/crates/profile/Cargo.toml b/crates/profile/Cargo.toml index 9384fe2655..376737cec6 100644 --- a/crates/profile/Cargo.toml +++ b/crates/profile/Cargo.toml @@ -13,12 +13,14 @@ rust-version.workspace = true [dependencies] cfg-if = "1.0.0" -libc.workspace = true jemalloc-ctl = { version = "0.5.0", package = "tikv-jemalloc-ctl", optional = true } [target.'cfg(all(target_os = "linux", not(target_env = "ohos")))'.dependencies] perf-event = "=0.4.7" +[target.'cfg(all(target_os = "linux", target_env = "gnu"))'.dependencies] +libc.workspace = true + [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.59", features = [ "Win32_System_Threading", diff --git a/crates/query-group-macro/Cargo.toml b/crates/query-group-macro/Cargo.toml index 99d1bf7e2c..116028b5ba 100644 --- a/crates/query-group-macro/Cargo.toml +++ b/crates/query-group-macro/Cargo.toml @@ -13,11 +13,10 @@ rust-version.workspace = true proc-macro = true [dependencies] -heck = "0.5.0" proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } -salsa.workspace = true [dev-dependencies] expect-test = "1.5.0" +salsa.workspace = true diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 9d30c5d38e..d47074198f 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -47,7 +47,6 @@ tracing-tree.workspace = true triomphe.workspace = true toml = "0.8.8" nohash-hasher.workspace = true -always-assert = "0.2.0" walkdir = "2.3.2" semver.workspace = true memchr = "2.7.1" @@ -95,9 +94,7 @@ syntax-bridge.workspace = true [features] jemalloc = ["jemallocator", "profile/jemalloc"] force-always-assert = ["stdx/force-always-assert"] -sysroot-abi = [] in-rust-tree = [ - "sysroot-abi", "syntax/in-rust-tree", "parser/in-rust-tree", "hir/in-rust-tree", diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs index 0b51dd87fe..a09d96d162 100644 --- a/crates/rust-analyzer/src/diagnostics.rs +++ b/crates/rust-analyzer/src/diagnostics.rs @@ -7,7 +7,6 @@ use cargo_metadata::PackageId; use ide::FileId; use ide_db::FxHashMap; use itertools::Itertools; -use nohash_hasher::{IntMap, IntSet}; use rustc_hash::FxHashSet; use stdx::iter_eq_by; use triomphe::Arc; @@ -15,7 +14,7 @@ use triomphe::Arc; use crate::{global_state::GlobalStateSnapshot, lsp, lsp_ext, main_loop::DiagnosticsTaskKind}; pub(crate) type CheckFixes = - Arc>, IntMap>>>>; + Arc>, FxHashMap>>>>; #[derive(Debug, Default, Clone)] pub struct DiagnosticsMapConfig { @@ -29,16 +28,16 @@ pub(crate) type DiagnosticsGeneration = usize; #[derive(Debug, Default, Clone)] pub(crate) struct DiagnosticCollection { - // FIXME: should be IntMap> - pub(crate) native_syntax: IntMap)>, - pub(crate) native_semantic: IntMap)>, + // FIXME: should be FxHashMap> + pub(crate) native_syntax: + FxHashMap)>, + pub(crate) native_semantic: + FxHashMap)>, // FIXME: should be Vec - pub(crate) check: IntMap< - usize, - FxHashMap>, IntMap>>, - >, + pub(crate) check: + Vec>, FxHashMap>>>, pub(crate) check_fixes: CheckFixes, - changes: IntSet, + changes: FxHashSet, /// Counter for supplying a new generation number for diagnostics. /// This is used to keep track of when to clear the diagnostics for a given file as we compute /// diagnostics on multiple worker threads simultaneously which may result in multiple diagnostics @@ -55,11 +54,11 @@ pub(crate) struct Fix { impl DiagnosticCollection { pub(crate) fn clear_check(&mut self, flycheck_id: usize) { - let Some(check) = self.check.get_mut(&flycheck_id) else { + let Some(check) = self.check.get_mut(flycheck_id) else { return; }; self.changes.extend(check.drain().flat_map(|(_, v)| v.into_keys())); - if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) { + if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(flycheck_id) { fixes.clear(); } } @@ -67,7 +66,7 @@ impl DiagnosticCollection { pub(crate) fn clear_check_all(&mut self) { Arc::make_mut(&mut self.check_fixes).clear(); self.changes.extend( - self.check.values_mut().flat_map(|it| it.drain().flat_map(|(_, v)| v.into_keys())), + self.check.iter_mut().flat_map(|it| it.drain().flat_map(|(_, v)| v.into_keys())), ) } @@ -76,14 +75,14 @@ impl DiagnosticCollection { flycheck_id: usize, package_id: Arc, ) { - let Some(check) = self.check.get_mut(&flycheck_id) else { + let Some(check) = self.check.get_mut(flycheck_id) else { return; }; let package_id = Some(package_id); if let Some(checks) = check.remove(&package_id) { self.changes.extend(checks.into_keys()); } - if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) { + if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(flycheck_id) { fixes.remove(&package_id); } } @@ -102,10 +101,10 @@ impl DiagnosticCollection { diagnostic: lsp_types::Diagnostic, fix: Option>, ) { - let diagnostics = self - .check - .entry(flycheck_id) - .or_default() + if self.check.len() <= flycheck_id { + self.check.resize_with(flycheck_id + 1, Default::default); + } + let diagnostics = self.check[flycheck_id] .entry(package_id.clone()) .or_default() .entry(file_id) @@ -118,9 +117,10 @@ impl DiagnosticCollection { if let Some(fix) = fix { let check_fixes = Arc::make_mut(&mut self.check_fixes); - check_fixes - .entry(flycheck_id) - .or_default() + if check_fixes.len() <= flycheck_id { + check_fixes.resize_with(flycheck_id + 1, Default::default); + } + check_fixes[flycheck_id] .entry(package_id.clone()) .or_default() .entry(file_id) @@ -176,14 +176,14 @@ impl DiagnosticCollection { let native_semantic = self.native_semantic.get(&file_id).into_iter().flat_map(|(_, d)| d); let check = self .check - .values() + .iter() .flat_map(|it| it.values()) .filter_map(move |it| it.get(&file_id)) .flatten(); native_syntax.chain(native_semantic).chain(check) } - pub(crate) fn take_changes(&mut self) -> Option> { + pub(crate) fn take_changes(&mut self) -> Option> { if self.changes.is_empty() { return None; } diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index af1f6ce2b0..6fc0ba9e66 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -12,7 +12,6 @@ use ide_db::base_db::{Crate, ProcMacroPaths, SourceDatabase}; use itertools::Itertools; use load_cargo::SourceRootConfig; use lsp_types::{SemanticTokens, Url}; -use nohash_hasher::IntMap; use parking_lot::{ MappedRwLockReadGuard, Mutex, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard, @@ -117,7 +116,7 @@ pub(crate) struct GlobalState { // VFS pub(crate) loader: Handle, Receiver>, - pub(crate) vfs: Arc)>>, + pub(crate) vfs: Arc)>>, pub(crate) vfs_config_version: u32, pub(crate) vfs_progress_config_version: u32, pub(crate) vfs_done: bool, @@ -181,7 +180,7 @@ pub(crate) struct GlobalStateSnapshot { pub(crate) check_fixes: CheckFixes, mem_docs: MemDocs, pub(crate) semantic_tokens_cache: Arc>>, - vfs: Arc)>>, + vfs: Arc)>>, pub(crate) workspaces: Arc>, // used to signal semantic highlighting to fall back to syntax based highlighting until // proc-macros have been loaded @@ -265,7 +264,7 @@ impl GlobalState { discover_sender, discover_receiver, - vfs: Arc::new(RwLock::new((vfs::Vfs::default(), IntMap::default()))), + vfs: Arc::new(RwLock::new((vfs::Vfs::default(), Default::default()))), vfs_config_version: 0, vfs_progress_config_version: 0, vfs_span: None, diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index ec8b324aac..75fe99e95d 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -1465,7 +1465,7 @@ pub(crate) fn handle_code_action( // Fixes from `cargo check`. for fix in snap .check_fixes - .values() + .iter() .flat_map(|it| it.values()) .filter_map(|it| it.get(&frange.file_id)) .flatten() diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 9cc990eec0..47fcb5ac02 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -8,7 +8,6 @@ use std::{ time::{Duration, Instant}, }; -use always_assert::always; use crossbeam_channel::{Receiver, select}; use ide_db::base_db::{SourceDatabase, VfsPath, salsa::Database as _}; use lsp_server::{Connection, Notification, Request}; @@ -845,7 +844,7 @@ impl GlobalState { } vfs::loader::Message::Progress { n_total, n_done, dir, config_version } => { let _p = span!(Level::INFO, "GlobalState::handle_vfs_msg/progress").entered(); - always!(config_version <= self.vfs_config_version); + stdx::always!(config_version <= self.vfs_config_version); let (n_done, state) = match n_done { LoadingProgress::Started => { diff --git a/crates/stdx/Cargo.toml b/crates/stdx/Cargo.toml index 3727d0c956..f6a5dedfda 100644 --- a/crates/stdx/Cargo.toml +++ b/crates/stdx/Cargo.toml @@ -14,12 +14,14 @@ rust-version.workspace = true [dependencies] backtrace = { version = "0.3.67", optional = true } jod-thread = "0.1.2" -libc.workspace = true crossbeam-channel.workspace = true itertools.workspace = true tracing.workspace = true # Think twice before adding anything here +[target.'cfg(unix)'.dependencies] +libc.workspace = true + [target.'cfg(windows)'.dependencies] miow = "0.6.0" windows-sys = { version = "0.59", features = ["Win32_Foundation"] } diff --git a/crates/syntax-bridge/Cargo.toml b/crates/syntax-bridge/Cargo.toml index 3e663422a0..cccd41d542 100644 --- a/crates/syntax-bridge/Cargo.toml +++ b/crates/syntax-bridge/Cargo.toml @@ -13,7 +13,6 @@ rust-version.workspace = true [dependencies] rustc-hash.workspace = true -tracing.workspace = true # local deps syntax.workspace = true diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 3fe6e01dc3..7db1a4e4ba 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -12,12 +12,10 @@ rust-version.workspace = true [lib] [dependencies] -cov-mark = "2.0.0-pre.1" either.workspace = true itertools.workspace = true rowan = "=0.15.15" rustc-hash.workspace = true -indexmap.workspace = true smol_str.workspace = true triomphe.workspace = true tracing.workspace = true diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index b99a2c4bd7..f25512b2b7 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -15,7 +15,6 @@ rust-version.workspace = true # Avoid adding deps here, this crate is widely used in tests it should compile fast! dissimilar = "1.0.7" text-size.workspace = true -tracing.workspace = true rustc-hash.workspace = true paths.workspace = true