diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52d60667b1156..30e5d21ab90b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -514,7 +514,7 @@ jobs: uses: ./.github/actions/setup-rust with: components: clippy - targets: wasm32-unknown-unknown,wasm32-wasi-preview1-threads + targets: wasm32-unknown-unknown,wasm32-wasip1-threads - name: Run cargo check release run: | @@ -522,7 +522,7 @@ jobs: - name: Run cargo check for the wasi targets run: | - CARGO_BUILD_TARGET="wasm32-wasi-preview1-threads" RUSTFLAGS="-D warnings -A deprecated" cargo groups check turbopack-wasi --release + CARGO_BUILD_TARGET="wasm32-wasip1-threads" RUSTFLAGS="-D warnings -A deprecated" cargo groups check turbopack-wasi --release turbopack_rust_clippy: needs: [turbopack_rust_check] diff --git a/Cargo.lock b/Cargo.lock index 142026ca3525f..c07b89b459a89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1695,9 +1695,9 @@ checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" [[package]] name = "const-random" -version = "0.1.18" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" dependencies = [ "const-random-macro", ] @@ -5604,9 +5604,8 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0444332826c70dc47be74a7c6a5fc44e23a7905ad6858d4162b658320455ef93" +version = "0.5.3" +source = "git+https://github.com/servo/pathfinder?rev=30419d#30419d07660dc11a21e42ef4a7fa329600cff152" dependencies = [ "rustc_version 0.4.0", ] @@ -5640,9 +5639,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -5651,9 +5650,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.6" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a81186863f3d0a27340815be8f2078dd8050b14cd71913db9fbda795e5f707d7" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -5661,22 +5660,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.6" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a1ef20bf3193c15ac345acb32e26b3dc3223aff4d77ae4fc5359567683796b" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.32", ] [[package]] name = "pest_meta" -version = "2.5.6" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e3b284b1f13a20dc5ebc90aff59a51b8d7137c221131b52a7260c08cbc1cc80" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", diff --git a/Cargo.toml b/Cargo.toml index 38faccf5f22bc..0bcc41008b0a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,6 +114,8 @@ swc_core = { version = "0.90.24", features = [ swc_emotion = { version = "0.72.6" } swc_relay = { version = "0.44.5" } testing = { version = "0.35.21" } +# Temporary: Reference the latest git minor version of pathfinder_simd until it's published. +pathfinder_simd = "0.5.3" auto-hash-map = { path = "crates/turbo-tasks-auto-hash-map" } node-file-trace = { path = "crates/node-file-trace", default-features = false } @@ -292,3 +294,6 @@ urlencoding = "2.1.2" webbrowser = "0.8.7" which = "4.4.0" unicode-segmentation = "1.10.1" + +[patch.crates-io] +pathfinder_simd = { git = "https://github.com/servo/pathfinder", rev = "30419d" } diff --git a/crates/turbo-tasks-fs/src/attach.rs b/crates/turbo-tasks-fs/src/attach.rs index 7ae3ba07b5cc1..7fc1af31ec9e1 100644 --- a/crates/turbo-tasks-fs/src/attach.rs +++ b/crates/turbo-tasks-fs/src/attach.rs @@ -97,10 +97,12 @@ impl AttachedFileSystem { let self_fs: Vc> = Vc::upcast(self); if path.fs != self_fs { + let self_fs_str = self_fs.to_string().await?; + let path_fs_str = path.fs.to_string().await?; bail!( "path fs does not match (expected {}, got {})", - self_fs.to_string().await?, - path.fs.to_string().await? + self_fs_str, + path_fs_str ) } @@ -184,10 +186,8 @@ impl FileSystem for AttachedFileSystem { impl ValueToString for AttachedFileSystem { #[turbo_tasks::function] async fn to_string(&self) -> Result> { - Ok(Vc::cell(format!( - "{}-with-{}", - self.root_fs.to_string().await?, - self.child_fs.to_string().await? - ))) + let root_fs_str = self.root_fs.to_string().await?; + let child_fs_str = self.child_fs.to_string().await?; + Ok(Vc::cell(format!("{}-with-{}", root_fs_str, child_fs_str))) } } diff --git a/crates/turbo-tasks-fs/src/glob.rs b/crates/turbo-tasks-fs/src/glob.rs index ea338dc2518d0..f68be03ca9ec0 100644 --- a/crates/turbo-tasks-fs/src/glob.rs +++ b/crates/turbo-tasks-fs/src/glob.rs @@ -346,9 +346,7 @@ impl<'a> Iterator for GlobPartMatchesIterator<'a> { return None; }; let mut chars_in_path = self.path[start..end].chars(); - let Some(c) = chars_in_path.next() else { - return None; - }; + let c = chars_in_path.next()?; if chars_in_path.next().is_some() { return None; } diff --git a/crates/turbo-tasks-fs/src/lib.rs b/crates/turbo-tasks-fs/src/lib.rs index 6ccdb0624e64e..95d73031000a4 100644 --- a/crates/turbo-tasks-fs/src/lib.rs +++ b/crates/turbo-tasks-fs/src/lib.rs @@ -250,8 +250,8 @@ impl DiskFileSystem { } struct PathLockGuard<'a>( - RwLockReadGuard<'a, ()>, - mutex_map::MutexMapGuard<'a, PathBuf>, + #[allow(dead_code)] RwLockReadGuard<'a, ()>, + #[allow(dead_code)] mutex_map::MutexMapGuard<'a, PathBuf>, ); fn format_absolute_fs_path(path: &Path, name: &str, root_path: &Path) -> Option { @@ -1939,9 +1939,7 @@ pub fn register() { #[cfg(test)] mod tests { - use turbo_tasks::Vc; - - use super::{virtual_fs::VirtualFileSystem, *}; + use super::*; #[tokio::test] async fn with_extension() { diff --git a/crates/turbo-tasks-fs/src/retry.rs b/crates/turbo-tasks-fs/src/retry.rs index f15f60606730c..6f34aeb9d5e21 100644 --- a/crates/turbo-tasks-fs/src/retry.rs +++ b/crates/turbo-tasks-fs/src/retry.rs @@ -41,7 +41,7 @@ where let mut attempt = 1; loop { - return match { func(&path) } { + return match func(&path) { Ok(r) => Ok(r), Err(err) => { if attempt < MAX_RETRY_ATTEMPTS && can_retry(&err) { diff --git a/crates/turbo-tasks-macros-shared/src/expand.rs b/crates/turbo-tasks-macros-shared/src/expand.rs index 6d50a8d5efd33..3be16b7a33b1f 100644 --- a/crates/turbo-tasks-macros-shared/src/expand.rs +++ b/crates/turbo-tasks-macros-shared/src/expand.rs @@ -114,7 +114,7 @@ pub fn expand_fields< /// Returns both the capture pattern token stream and the name of the bound /// identifiers corresponding to the input fields. pub fn generate_destructuring<'a, I: Fn(&Field) -> bool>( - fields: impl Iterator + ExactSizeIterator, + fields: impl ExactSizeIterator, filter_field: &I, ) -> (TokenStream, Vec) { let fields_len = fields.len(); @@ -153,7 +153,7 @@ pub fn generate_destructuring<'a, I: Fn(&Field) -> bool>( /// Returns both the capture pattern token stream and the name of the bound /// identifiers corresponding to the input fields. pub fn generate_exhaustive_destructuring<'a>( - fields: impl Iterator + ExactSizeIterator, + fields: impl ExactSizeIterator, ) -> (TokenStream, Vec) { generate_destructuring(fields, &|_| true) } diff --git a/crates/turbo-tasks-macros-tests/tests/value_debug.rs b/crates/turbo-tasks-macros-tests/tests/value_debug.rs index 9daf7f42cb403..37380e6bf3cf7 100644 --- a/crates/turbo-tasks-macros-tests/tests/value_debug.rs +++ b/crates/turbo-tasks-macros-tests/tests/value_debug.rs @@ -7,9 +7,13 @@ register!(); async fn ignored_indexes() { #[derive(ValueDebugFormat)] struct IgnoredIndexes( - #[turbo_tasks(debug_ignore)] i32, + #[allow(dead_code)] + #[turbo_tasks(debug_ignore)] + i32, + i32, + #[allow(dead_code)] + #[turbo_tasks(debug_ignore)] i32, - #[turbo_tasks(debug_ignore)] i32, ); run! { diff --git a/crates/turbo-tasks-memory/src/memory_backend.rs b/crates/turbo-tasks-memory/src/memory_backend.rs index f3738b070348f..ef4d4cdf56e73 100644 --- a/crates/turbo-tasks-memory/src/memory_backend.rs +++ b/crates/turbo-tasks-memory/src/memory_backend.rs @@ -200,7 +200,7 @@ impl MemoryBackend { result_task } - fn lookup_and_connect_task( + fn lookup_and_connect_task( &self, parent_task: TaskId, task_cache: &DashMap, @@ -208,7 +208,7 @@ impl MemoryBackend { turbo_tasks: &dyn TurboTasksBackendApi, ) -> Option where - K: Borrow, + K: Borrow + Hash + Eq, Q: Hash + Eq + ?Sized, { task_cache.get(key).map(|task| { diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 82bea9af6b72c..856a5ad8dc2ce 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -153,7 +153,7 @@ impl Debug for Task { TaskMetaStateReadGuard::Partial(_) => { result.field("state", &"partial"); } - TaskMetaStateReadGuard::Unloaded(_) => { + TaskMetaStateReadGuard::Unloaded => { result.field("state", &"unloaded"); } } @@ -1416,7 +1416,7 @@ impl Task { executions: None, unloaded: true, }, - TaskMetaStateReadGuard::Unloaded(_) => TaskStatsInfo { + TaskMetaStateReadGuard::Unloaded => TaskStatsInfo { total_duration: None, last_duration: Duration::ZERO, executions: None, @@ -1547,7 +1547,7 @@ impl Task { TaskMetaStateReadGuard::Partial(state) => state .aggregation_leaf .get_root_info(&aggregation_context, &RootInfoType::IsActive), - TaskMetaStateReadGuard::Unloaded(_) => false, + TaskMetaStateReadGuard::Unloaded => false, }; if active { child.schedule_when_dirty_from_aggregation(backend, turbo_tasks); diff --git a/crates/turbo-tasks-memory/src/task/meta_state.rs b/crates/turbo-tasks-memory/src/task/meta_state.rs index 3a62ba060c2c9..0adc85679e0e7 100644 --- a/crates/turbo-tasks-memory/src/task/meta_state.rs +++ b/crates/turbo-tasks-memory/src/task/meta_state.rs @@ -77,21 +77,21 @@ impl TaskMetaState { } } -// These need to be impl types since there is no way to reference the zero-sized -// function item type -pub(super) type TaskMetaStateAsFull = impl Fn(&TaskMetaState) -> Option<&TaskState>; -pub(super) type TaskMetaStateAsPartial = impl Fn(&TaskMetaState) -> Option<&PartialTaskState>; -pub(super) type TaskMetaStateAsUnloaded = impl Fn(&TaskMetaState) -> Option<&UnloadedTaskState>; -pub(super) type TaskMetaStateAsFullMut = impl Fn(&mut TaskMetaState) -> Option<&mut TaskState>; +pub(super) type TaskMetaStateAsFull = for<'a> fn(&'a TaskMetaState) -> Option<&'a TaskState>; +pub(super) type TaskMetaStateAsPartial = for<'a> fn(&'a TaskMetaState) -> Option<&PartialTaskState>; +pub(super) type TaskMetaStateAsUnloaded = + for<'a> fn(&'a TaskMetaState) -> Option<&'a UnloadedTaskState>; +pub(super) type TaskMetaStateAsFullMut = + for<'a> fn(&'a mut TaskMetaState) -> Option<&'a mut TaskState>; pub(super) type TaskMetaStateAsPartialMut = - impl Fn(&mut TaskMetaState) -> Option<&mut PartialTaskState>; + for<'a> fn(&'a mut TaskMetaState) -> Option<&'a mut PartialTaskState>; pub(super) type TaskMetaStateAsUnloadedMut = - impl Fn(&mut TaskMetaState) -> Option<&mut UnloadedTaskState>; + for<'a> fn(&'a mut TaskMetaState) -> Option<&'a mut UnloadedTaskState>; pub(super) enum TaskMetaStateReadGuard<'a> { Full(ReadGuard<'a, TaskMetaState, TaskState, TaskMetaStateAsFull>), Partial(ReadGuard<'a, TaskMetaState, PartialTaskState, TaskMetaStateAsPartial>), - Unloaded(ReadGuard<'a, TaskMetaState, UnloadedTaskState, TaskMetaStateAsUnloaded>), + Unloaded, } pub(super) type FullTaskWriteGuard<'a> = @@ -128,9 +128,7 @@ impl<'a> From> for TaskMetaStateReadGuard<'a> TaskMetaState::Partial(_) => { TaskMetaStateReadGuard::Partial(ReadGuard::new(guard, TaskMetaState::as_partial)) } - TaskMetaState::Unloaded(_) => { - TaskMetaStateReadGuard::Unloaded(ReadGuard::new(guard, TaskMetaState::as_unloaded)) - } + TaskMetaState::Unloaded(_) => TaskMetaStateReadGuard::Unloaded, } } } diff --git a/crates/turbo-tasks-signposter/src/log.rs b/crates/turbo-tasks-signposter/src/log.rs index 8d9372aba08fe..d329fb1d4e006 100644 --- a/crates/turbo-tasks-signposter/src/log.rs +++ b/crates/turbo-tasks-signposter/src/log.rs @@ -1,6 +1,6 @@ use std::{ ffi::{CStr, CString}, - ptr::null, + ptr::{addr_of, null}, }; use signposter_sys::*; @@ -48,7 +48,7 @@ unsafe impl Send for Log {} impl Default for Log { fn default() -> Self { Log { - os_log: unsafe { &_os_log_default as *const _ as *mut _ }, + os_log: unsafe { addr_of!(_os_log_default) as *const _ as *mut _ }, } } } @@ -148,7 +148,7 @@ impl Signpost { fn emit(&self, name: &CStr, message: Option<&CStr>, signpost_type: SignpostType) { unsafe { _os_signpost_emit_with_name_impl( - &__dso_handle as *const _ as *mut _, + addr_of!(__dso_handle) as *const _ as *mut _, self.log, signpost_type as _, self.id, diff --git a/crates/turbo-tasks/src/magic_any.rs b/crates/turbo-tasks/src/magic_any.rs index cdc697bfe1969..d2f48ed7a9720 100644 --- a/crates/turbo-tasks/src/magic_any.rs +++ b/crates/turbo-tasks/src/magic_any.rs @@ -149,9 +149,9 @@ pub struct MagicAnyDeserializeSeed { } impl MagicAnyDeserializeSeed { - pub fn new() -> Self + pub fn new() -> Self where - T: for<'de> Deserialize<'de>, + T: for<'de> Deserialize<'de> + Debug + Eq + Ord + Hash + Send + Sync + 'static, { fn deserialize< T: Debug + Eq + Ord + Hash + for<'de> Deserialize<'de> + Send + Sync + 'static, @@ -189,9 +189,9 @@ pub struct AnyDeserializeSeed { } impl AnyDeserializeSeed { - pub fn new() -> Self + pub fn new() -> Self where - T: for<'de> Deserialize<'de>, + T: for<'de> Deserialize<'de> + Any + Send + Sync + 'static, { fn deserialize Deserialize<'de> + Send + Sync + 'static>( deserializer: &mut dyn erased_serde::Deserializer<'_>, diff --git a/crates/turbo-tasks/src/manager.rs b/crates/turbo-tasks/src/manager.rs index 126206779d33e..a194964a7123f 100644 --- a/crates/turbo-tasks/src/manager.rs +++ b/crates/turbo-tasks/src/manager.rs @@ -250,6 +250,7 @@ impl TaskIdProvider for &dyn TaskIdProvider { } } +#[allow(clippy::manual_non_exhaustive)] pub struct UpdateInfo { pub duration: Duration, pub tasks: usize, @@ -460,7 +461,7 @@ impl TurboTasks { let this = self.pin(); let future = async move { - #[allow(clippy::blocks_in_if_conditions)] + #[allow(clippy::blocks_in_conditions)] while CURRENT_TASK_STATE .scope(Default::default(), async { if this.stopped.load(Ordering::Acquire) { diff --git a/crates/turbo-tasks/src/task/concrete_task_input.rs b/crates/turbo-tasks/src/task/concrete_task_input.rs index fb360e9865a9b..7b6b7584e3c65 100644 --- a/crates/turbo-tasks/src/task/concrete_task_input.rs +++ b/crates/turbo-tasks/src/task/concrete_task_input.rs @@ -37,6 +37,9 @@ impl Hash for SharedReference { } } impl PartialEq for SharedReference { + // Must compare with PartialEq rather than std::ptr::addr_eq since the latter + // only compares their addresses. + #[allow(ambiguous_wide_pointer_comparisons)] fn eq(&self, other: &Self) -> bool { PartialEq::eq( &(&*self.1 as *const (dyn Any + Send + Sync)), @@ -53,8 +56,8 @@ impl PartialOrd for SharedReference { impl Ord for SharedReference { fn cmp(&self, other: &Self) -> std::cmp::Ordering { Ord::cmp( - &(&*self.1 as *const (dyn Any + Send + Sync)), - &(&*other.1 as *const (dyn Any + Send + Sync)), + &(&*self.1 as *const (dyn Any + Send + Sync)).cast::<()>(), + &(&*other.1 as *const (dyn Any + Send + Sync)).cast::<()>(), ) } } diff --git a/crates/turbo-tasks/src/task/task_input.rs b/crates/turbo-tasks/src/task/task_input.rs index 24eacfa4d228c..2b3fd67c59bf5 100644 --- a/crates/turbo-tasks/src/task/task_input.rs +++ b/crates/turbo-tasks/src/task/task_input.rs @@ -365,7 +365,6 @@ tuple_impls! { A B C D E F G H I J K L } #[cfg(test)] mod tests { - use anyhow::Result; use turbo_tasks_macros::TaskInput; use super::*; diff --git a/crates/turbopack-browser/src/ecmascript/list/asset.rs b/crates/turbopack-browser/src/ecmascript/list/asset.rs index bee57776ac171..8c1cfc0e89558 100644 --- a/crates/turbopack-browser/src/ecmascript/list/asset.rs +++ b/crates/turbopack-browser/src/ecmascript/list/asset.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use serde::Serialize; use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ asset::{Asset, AssetContent}, @@ -139,17 +138,6 @@ impl Asset for EcmascriptDevChunkList { } } -#[derive(Debug, Clone, Serialize)] -#[serde(rename_all = "camelCase")] -struct EcmascriptDevChunkListParams<'a> { - /// Path to the chunk list to register. - path: &'a str, - /// All chunks that belong to the chunk list. - chunks: Vec, - /// Where this chunk list is from. - source: EcmascriptDevChunkListSource, -} - #[derive(Debug, Clone, Copy, Ord, PartialOrd, Hash)] #[turbo_tasks::value(serialization = "auto_for_input")] #[serde(rename_all = "camelCase")] diff --git a/crates/turbopack-core/src/chunk/containment_tree.rs b/crates/turbopack-core/src/chunk/containment_tree.rs index 33eafdc50f587..3c4fa45fc1144 100644 --- a/crates/turbopack-core/src/chunk/containment_tree.rs +++ b/crates/turbopack-core/src/chunk/containment_tree.rs @@ -210,7 +210,6 @@ where #[cfg(test)] mod tests { - use anyhow::Result; use async_trait::async_trait; use super::*; diff --git a/crates/turbopack-core/src/ident.rs b/crates/turbopack-core/src/ident.rs index c99ce76cfbf4f..f835b241dca49 100644 --- a/crates/turbopack-core/src/ident.rs +++ b/crates/turbopack-core/src/ident.rs @@ -69,7 +69,9 @@ impl ValueToString for AssetIdent { s.push(','); } - write!(s, " {} => {:?}", key.await?, asset.to_string().await?)?; + let key_str = key.await?; + let asset_str = asset.to_string().await?; + write!(s, " {} => {:?}", key_str, asset_str)?; } s.push_str(" }"); diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index 2bb11188ea7f0..a237d647efad2 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -210,10 +210,11 @@ impl ValueToString for IssueProcessingPathItem { #[turbo_tasks::function] async fn to_string(&self) -> Result> { if let Some(context) = self.file_path { + let description_str = self.description.await?; Ok(Vc::cell(format!( "{} ({})", context.to_string().await?, - self.description.await? + description_str ))) } else { Ok(self.description) diff --git a/crates/turbopack-core/src/resolve/mod.rs b/crates/turbopack-core/src/resolve/mod.rs index 46903721ad98b..7f166b7e1c77a 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -1254,6 +1254,7 @@ pub async fn resolve_raw( let mut results = Vec::new(); + let lookup_dir_str = lookup_dir.to_string().await?; let pat = path.await?; if let Some(pat) = pat .filter_could_match("/ROOT/") @@ -1262,10 +1263,11 @@ pub async fn resolve_raw( let path = Pattern::new(pat); let matches = read_matches(lookup_dir.root(), "/ROOT/".to_string(), true, path).await?; if matches.len() > 10000 { + let path_str = path.to_string().await?; println!( "WARN: resolving abs pattern {} in {} leads to {} results", - path.to_string().await?, - lookup_dir.to_string().await?, + path_str, + lookup_dir_str, matches.len() ); } else { @@ -1283,7 +1285,7 @@ pub async fn resolve_raw( println!( "WARN: resolving pattern {} in {} leads to {} results", pat, - lookup_dir.to_string().await?, + lookup_dir_str, matches.len() ); } @@ -2331,7 +2333,9 @@ async fn handle_exports_imports_field( let mut results = Vec::new(); let mut conditions_state = HashMap::new(); - let req = format!("{}{}", path, &*query.await?); + let query_str = query.await?; + + let req = format!("{}{}", path, query_str); let values = exports_imports_field .lookup(&req) .map(AliasMatch::try_into_self) @@ -2545,7 +2549,11 @@ impl ValueToString for ModulePart { ModulePart::RenamedExport { original_export, export, - } => format!("export {} as {}", original_export.await?, export.await?), + } => { + let original_export = original_export.await?; + let export = export.await?; + format!("export {} as {}", original_export, export) + } ModulePart::RenamedNamespace { export } => { format!("export * as {}", export.await?) } diff --git a/crates/turbopack-core/src/resolve/options.rs b/crates/turbopack-core/src/resolve/options.rs index 9fbce0b59c5de..b1ca51ec4eb43 100644 --- a/crates/turbopack-core/src/resolve/options.rs +++ b/crates/turbopack-core/src/resolve/options.rs @@ -307,10 +307,11 @@ impl ValueToString for ImportMapResult { ImportMapResult::Result(_) => Ok(Vc::cell("Resolved by import map".to_string())), ImportMapResult::Alias(request, context) => { let s = if let Some(path) = context { + let path = path.to_string().await?; format!( "aliased to {} inside of {}", request.to_string().await?, - path.to_string().await? + path ) } else { format!("aliased to {}", request.to_string().await?) diff --git a/crates/turbopack-core/src/resolve/pattern.rs b/crates/turbopack-core/src/resolve/pattern.rs index 55c3a5b346bcf..9a0a8f7bdb837 100644 --- a/crates/turbopack-core/src/resolve/pattern.rs +++ b/crates/turbopack-core/src/resolve/pattern.rs @@ -161,7 +161,7 @@ impl Pattern { /// Order into Alternatives -> Concatenation -> Constant/Dynamic /// Merge when possible pub fn normalize(&mut self) { - let mut alternatives = vec![Vec::new()]; + let mut alternatives = [Vec::new()]; match self { Pattern::Constant(c) => { for alt in alternatives.iter_mut() { diff --git a/crates/turbopack-dev-server/src/http.rs b/crates/turbopack-dev-server/src/http.rs index 5f6737f12db2b..739bc152a76c4 100644 --- a/crates/turbopack-dev-server/src/http.rs +++ b/crates/turbopack-dev-server/src/http.rs @@ -9,7 +9,6 @@ use hyper::{ Request, Response, }; use mime::Mime; -use mime_guess::mime; use tokio_util::io::{ReaderStream, StreamReader}; use turbo_tasks::{util::SharedError, CollectiblesSource, ReadRef, TransientInstance, Vc}; use turbo_tasks_bytes::Bytes; diff --git a/crates/turbopack-dev-server/src/lib.rs b/crates/turbopack-dev-server/src/lib.rs index bcf5c46737104..41ccae1a02fb9 100644 --- a/crates/turbopack-dev-server/src/lib.rs +++ b/crates/turbopack-dev-server/src/lib.rs @@ -114,7 +114,7 @@ impl DevServerBuilder { pub fn serve( self, turbo_tasks: Arc, - source_provider: impl SourceProvider + Clone + Send + Sync, + source_provider: impl SourceProvider + Sync, get_issue_reporter: Arc Vc> + Send + Sync>, ) -> DevServer { let ongoing_side_effects = Arc::new(Mutex::new(VecDeque::< diff --git a/crates/turbopack-dev-server/src/source/mod.rs b/crates/turbopack-dev-server/src/source/mod.rs index b9cde5fd67bc9..2b03c7dd95d50 100644 --- a/crates/turbopack-dev-server/src/source/mod.rs +++ b/crates/turbopack-dev-server/src/source/mod.rs @@ -281,7 +281,7 @@ impl ContentSourceDataFilter { this.extend(other); } } else { - *this = other.clone(); + this.clone_from(other); } } diff --git a/crates/turbopack-dev-server/src/source/route_tree.rs b/crates/turbopack-dev-server/src/source/route_tree.rs index b8d22f72d3365..373f62a7814ef 100644 --- a/crates/turbopack-dev-server/src/source/route_tree.rs +++ b/crates/turbopack-dev-server/src/source/route_tree.rs @@ -207,7 +207,8 @@ impl ValueToString for RouteTree { result.push_str(", "); } for (key, tree) in static_segments { - write!(result, "{}: {}, ", key, tree.to_string().await?)?; + let tree = tree.to_string().await?; + write!(result, "{}: {}, ", key, tree)?; } if !sources.is_empty() { write!(result, "{} x source, ", sources.len())?; diff --git a/crates/turbopack-dev-server/src/update/stream.rs b/crates/turbopack-dev-server/src/update/stream.rs index a93e2507ffd3f..af23e8f1598b3 100644 --- a/crates/turbopack-dev-server/src/update/stream.rs +++ b/crates/turbopack-dev-server/src/update/stream.rs @@ -1,7 +1,7 @@ use std::pin::Pin; use anyhow::Result; -use futures::{prelude::*, Stream}; +use futures::prelude::*; use tokio::sync::mpsc::Sender; use tokio_stream::wrappers::ReceiverStream; use tracing::Instrument; diff --git a/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs b/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs index be44cfdc15531..48b77bdbf4d61 100644 --- a/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs +++ b/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs @@ -69,7 +69,7 @@ impl StyledComponentsTransformer { }; if let Some(namespace) = &config.namespace { - options.namespace = namespace.clone(); + options.namespace.clone_from(namespace); } let top_level_import_paths = &config.top_level_import_paths; @@ -81,7 +81,9 @@ impl StyledComponentsTransformer { } let meaningless_file_names = &config.meaningless_file_names; if !meaningless_file_names.is_empty() { - options.meaningless_file_names = meaningless_file_names.clone(); + options + .meaningless_file_names + .clone_from(meaningless_file_names); } Self { config: options } diff --git a/crates/turbopack-ecmascript/src/analyzer/graph.rs b/crates/turbopack-ecmascript/src/analyzer/graph.rs index 8ba96a50ef380..dd5e634b41601 100644 --- a/crates/turbopack-ecmascript/src/analyzer/graph.rs +++ b/crates/turbopack-ecmascript/src/analyzer/graph.rs @@ -9,7 +9,7 @@ use swc_core::{ ecma::{ ast::*, atoms::js_word, - visit::{fields::*, VisitAstPath, VisitWithPath, *}, + visit::{fields::*, *}, }, }; use turbo_tasks::Vc; diff --git a/crates/turbopack-ecmascript/src/analyzer/mod.rs b/crates/turbopack-ecmascript/src/analyzer/mod.rs index 5a6c6f86fffa8..75c9d416e234a 100644 --- a/crates/turbopack-ecmascript/src/analyzer/mod.rs +++ b/crates/turbopack-ecmascript/src/analyzer/mod.rs @@ -3301,7 +3301,7 @@ fn regex_from_js(pattern: &str, flags: &str) -> Result { /// Parse the arguments passed to a require.context invocation, validate them /// and convert them to the appropriate rust values. -pub fn parse_require_context(args: &Vec) -> Result { +pub fn parse_require_context(args: &[JsValue]) -> Result { if !(1..=3).contains(&args.len()) { // https://linear.app/vercel/issue/WEB-910/add-support-for-requirecontexts-mode-argument bail!("require.context() only supports 1-3 arguments (mode is not supported)"); diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index cdcc00e6bb86e..23dc8fa0fcac5 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -1,8 +1,9 @@ +// Needed for swc visit_ macros +#![allow(non_local_definitions)] #![feature(box_patterns)] #![feature(min_specialization)] #![feature(iter_intersperse)] #![feature(int_roundings)] -#![feature(slice_group_by)] #![feature(arbitrary_self_types)] #![recursion_limit = "256"] diff --git a/crates/turbopack-ecmascript/src/tree_shake/graph.rs b/crates/turbopack-ecmascript/src/tree_shake/graph.rs index f1a66196816b8..24ebbf39c07d1 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/graph.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/graph.rs @@ -124,9 +124,6 @@ impl Default for ItemData { } } -#[derive(Debug)] -pub(super) struct VarInfo {} - #[derive(Debug, Clone)] pub struct InternedGraph where diff --git a/crates/turbopack-image/src/process/mod.rs b/crates/turbopack-image/src/process/mod.rs index df8773d4512fe..f5261dc681c2a 100644 --- a/crates/turbopack-image/src/process/mod.rs +++ b/crates/turbopack-image/src/process/mod.rs @@ -48,6 +48,7 @@ impl BlurPlaceholder { } /// Gathered meta information about an image. +#[allow(clippy::manual_non_exhaustive)] #[serde_as] #[turbo_tasks::value] #[derive(Default)] diff --git a/crates/turbopack-node/src/render/rendered_source.rs b/crates/turbopack-node/src/render/rendered_source.rs index 39b7767bfa231..51301c93a5d67 100644 --- a/crates/turbopack-node/src/render/rendered_source.rs +++ b/crates/turbopack-node/src/render/rendered_source.rs @@ -170,11 +170,12 @@ impl GetContentSourceContent for NodeRenderContentSource { path: String, data: Value, ) -> Result> { + let pathname = self.pathname.await?; let Some(params) = &*self.route_match.params(path.clone()).await? else { return Err(anyhow!( "Non matching path ({}) provided for {}", path, - self.pathname.await? + pathname )); }; let ContentSourceData { @@ -207,7 +208,7 @@ impl GetContentSourceContent for NodeRenderContentSource { original_url: original_url.clone(), raw_query: raw_query.clone(), raw_headers: raw_headers.clone(), - path: self.pathname.await?.clone_value(), + path: pathname.clone_value(), data: Some(self.render_data.await?), } .cell(), @@ -215,7 +216,7 @@ impl GetContentSourceContent for NodeRenderContentSource { ) .issue_file_path( entry.module.ident().path(), - format!("server-side rendering {}", self.pathname.await?), + format!("server-side rendering {}", pathname), ) .await?; Ok(match *result.await? { diff --git a/crates/turbopack-node/src/transforms/webpack.rs b/crates/turbopack-node/src/transforms/webpack.rs index 772320af7a434..c5de1d32a26ba 100644 --- a/crates/turbopack-node/src/transforms/webpack.rs +++ b/crates/turbopack-node/src/transforms/webpack.rs @@ -489,6 +489,9 @@ impl EvaluateContext for WebpackLoaderContext { request, options, ); + + let request_str = request.to_string().await?; + let lookup_path_str = lookup_path.to_string().await?; if let Some(source) = *resolved.first_source().await? { if let Some(path) = self .cwd @@ -499,16 +502,12 @@ impl EvaluateContext for WebpackLoaderContext { } else { bail!( "Resolving {} in {} ends up on a different filesystem", - request.to_string().await?, - lookup_path.to_string().await? + request_str, + lookup_path_str ); } } else { - bail!( - "Unable to resolve {} in {}", - request.to_string().await?, - lookup_path.to_string().await? - ); + bail!("Unable to resolve {} in {}", request_str, lookup_path_str); } } } diff --git a/crates/turbopack-resolve/src/node_native_binding.rs b/crates/turbopack-resolve/src/node_native_binding.rs index 467b47c898ee0..52a0afaf6b2b2 100644 --- a/crates/turbopack-resolve/src/node_native_binding.rs +++ b/crates/turbopack-resolve/src/node_native_binding.rs @@ -70,11 +70,12 @@ impl ModuleReference for NodePreGypConfigReference { impl ValueToString for NodePreGypConfigReference { #[turbo_tasks::function] async fn to_string(&self) -> Result> { + let context_dir = self.context_dir.to_string().await?; + let config_file_pattern = self.config_file_pattern.to_string().await?; + let compile_target = self.compile_target.await?; Ok(Vc::cell(format!( "node-gyp in {} with {} for {}", - self.context_dir.to_string().await?, - self.config_file_pattern.to_string().await?, - self.compile_target.await? + context_dir, config_file_pattern, compile_target ))) } } @@ -234,10 +235,11 @@ impl ModuleReference for NodeGypBuildReference { impl ValueToString for NodeGypBuildReference { #[turbo_tasks::function] async fn to_string(&self) -> Result> { + let context_dir = self.context_dir.to_string().await?; + let compile_target = self.compile_target.await?; Ok(Vc::cell(format!( "node-gyp in {} for {}", - self.context_dir.to_string().await?, - self.compile_target.await? + context_dir, compile_target ))) } } diff --git a/crates/turbopack-trace-server/src/span_graph_ref.rs b/crates/turbopack-trace-server/src/span_graph_ref.rs index 0b9be90c71493..03ce092894a54 100644 --- a/crates/turbopack-trace-server/src/span_graph_ref.rs +++ b/crates/turbopack-trace-server/src/span_graph_ref.rs @@ -46,7 +46,7 @@ impl<'a> SpanGraphRef<'a> { self.graph.root_spans.len() + self.graph.recursive_spans.len() } - pub fn root_spans(&self) -> impl Iterator> + DoubleEndedIterator + '_ { + pub fn root_spans(&self) -> impl DoubleEndedIterator> + '_ { self.graph.root_spans.iter().map(move |span| SpanRef { span: &self.store.spans[span.get()], store: self.store, @@ -54,7 +54,7 @@ impl<'a> SpanGraphRef<'a> { }) } - fn recursive_spans(&self) -> impl Iterator> + DoubleEndedIterator + '_ { + fn recursive_spans(&self) -> impl DoubleEndedIterator> + '_ { self.graph .root_spans .iter() @@ -66,7 +66,7 @@ impl<'a> SpanGraphRef<'a> { }) } - pub fn events(&self) -> impl Iterator> + DoubleEndedIterator + '_ { + pub fn events(&self) -> impl DoubleEndedIterator> + '_ { self.graph .events .get_or_init(|| { @@ -113,7 +113,7 @@ impl<'a> SpanGraphRef<'a> { }) } - pub fn children(&self) -> impl Iterator> + DoubleEndedIterator + '_ { + pub fn children(&self) -> impl DoubleEndedIterator> + '_ { self.events().filter_map(|event| match event { SpanGraphEventRef::SelfTime { .. } => None, SpanGraphEventRef::Child { graph: span } => Some(span), diff --git a/crates/turbopack-trace-server/src/span_ref.rs b/crates/turbopack-trace-server/src/span_ref.rs index 2d155519834b4..14c1ad852b0e5 100644 --- a/crates/turbopack-trace-server/src/span_ref.rs +++ b/crates/turbopack-trace-server/src/span_ref.rs @@ -179,7 +179,7 @@ impl<'a> SpanRef<'a> { }) } - pub fn children(&self) -> impl Iterator> + DoubleEndedIterator + 'a { + pub fn children(&self) -> impl DoubleEndedIterator> + 'a { self.span.events.iter().filter_map(|event| match event { SpanEvent::SelfTime { .. } => None, SpanEvent::Child { index } => Some(SpanRef { @@ -411,6 +411,7 @@ impl<'a> Debug for SpanRef<'a> { } } +#[allow(dead_code)] #[derive(Copy, Clone)] pub enum SpanEventRef<'a> { SelfTime { start: u64, end: u64 }, diff --git a/crates/turborepo-env/src/lib.rs b/crates/turborepo-env/src/lib.rs index 4866781e35aba..ee35d5fd46cdc 100644 --- a/crates/turborepo-env/src/lib.rs +++ b/crates/turborepo-env/src/lib.rs @@ -4,7 +4,6 @@ use std::{ collections::HashMap, env, ops::{Deref, DerefMut}, - string::ToString, }; use regex::Regex; diff --git a/crates/turborepo-filewatch/src/lib.rs b/crates/turborepo-filewatch/src/lib.rs index 211bb52498f57..2d601f4a8f604 100644 --- a/crates/turborepo-filewatch/src/lib.rs +++ b/crates/turborepo-filewatch/src/lib.rs @@ -5,7 +5,6 @@ use std::{ fmt::{Debug, Display}, future::IntoFuture, path::Path, - result::Result, sync::Arc, time::Duration, }; @@ -288,7 +287,7 @@ fn filter_relevant(root: &AbsoluteSystemPath, event: &mut Event) { // If we're modifying something along the path to the // root, move the event to the root if is_modify_existing { - *path = root.as_std_path().to_owned(); + root.as_std_path().clone_into(path); } true } diff --git a/crates/turborepo-lib/src/engine/builder.rs b/crates/turborepo-lib/src/engine/builder.rs index e721a7a4d04e2..0d6c4eb1fb7bc 100644 --- a/crates/turborepo-lib/src/engine/builder.rs +++ b/crates/turborepo-lib/src/engine/builder.rs @@ -1139,6 +1139,7 @@ mod test { assert_eq!(all_dependencies(&engine), expected); } + #[allow(clippy::duplicated_attributes)] #[test_case("build", None)] #[test_case("build:prod", None)] #[test_case("build$colon$prod", Some("task contains invalid string '$colon$'"))] diff --git a/crates/turborepo-lib/src/run/scope/filter.rs b/crates/turborepo-lib/src/run/scope/filter.rs index ceabdff57073f..c8f8cb434270e 100644 --- a/crates/turborepo-lib/src/run/scope/filter.rs +++ b/crates/turborepo-lib/src/run/scope/filter.rs @@ -78,7 +78,7 @@ impl PackageInference { }; if let Some(name) = &self.package_name { - selector.name_pattern = name.to_owned(); + name.clone_into(&mut selector.name_pattern); } if selector.parent_dir != turbopath::AnchoredSystemPathBuf::default() { @@ -167,7 +167,7 @@ impl<'a, T: GitChangeDetector> FilterResolver<'a, T> { /// It applies the following rules: pub(crate) fn resolve( &self, - patterns: &Vec, + patterns: &[String], ) -> Result<(HashSet, bool), ResolutionError> { // inference is None only if we are in the root let is_all_packages = patterns.is_empty() && self.inference.is_none(); diff --git a/crates/turborepo-lib/src/unescape.rs b/crates/turborepo-lib/src/unescape.rs index a752780cfd0f0..db0f9f3edebf4 100644 --- a/crates/turborepo-lib/src/unescape.rs +++ b/crates/turborepo-lib/src/unescape.rs @@ -40,9 +40,7 @@ impl Deserializable for UnescapedString { name: &str, diagnostics: &mut Vec, ) -> Option { - let Some(str) = String::deserialize(value, name, diagnostics) else { - return None; - }; + let str = String::deserialize(value, name, diagnostics)?; match unescape_str(str) { Ok(s) => Some(Self(s)), diff --git a/crates/turborepo-lockfiles/Cargo.toml b/crates/turborepo-lockfiles/Cargo.toml index 309b0fe5a877f..e8f2ad2aeafa9 100644 --- a/crates/turborepo-lockfiles/Cargo.toml +++ b/crates/turborepo-lockfiles/Cargo.toml @@ -11,8 +11,8 @@ workspace = true [dependencies] nom = "7" -pest = "2.5.6" -pest_derive = "2.5.6" +pest = "2.7.9" +pest_derive = "2.7.9" rayon = "1" regex = "1" semver = "1.0.17" diff --git a/crates/turborepo-lsp/src/lib.rs b/crates/turborepo-lsp/src/lib.rs index de3f92d32598b..abc7dd8011a26 100644 --- a/crates/turborepo-lsp/src/lib.rs +++ b/crates/turborepo-lsp/src/lib.rs @@ -17,7 +17,6 @@ use jsonc_parser::{ use serde_json::Value; use tokio::sync::watch::{Receiver, Sender}; use tower_lsp::{ - self, jsonrpc::{Error, Result as LspResult}, lsp_types::*, Client, LanguageServer, diff --git a/crates/turborepo-pidlock/src/lib.rs b/crates/turborepo-pidlock/src/lib.rs index f1b67078b22f3..a00b68fb58098 100644 --- a/crates/turborepo-pidlock/src/lib.rs +++ b/crates/turborepo-pidlock/src/lib.rs @@ -2,7 +2,6 @@ #![feature(assert_matches)] use std::{ - convert::TryInto, fs, io::{self, Read, Write}, num::TryFromIntError, diff --git a/crates/turborepo-telemetry/src/config.rs b/crates/turborepo-telemetry/src/config.rs index d6823c8ff0cbc..0c3f68f42a034 100644 --- a/crates/turborepo-telemetry/src/config.rs +++ b/crates/turborepo-telemetry/src/config.rs @@ -11,9 +11,7 @@ use std::env; use chrono::{DateTime, Utc}; pub use config::{Config, ConfigError, File, FileFormat}; -use hex; use serde::{Deserialize, Serialize}; -use serde_json; use sha2::{Digest, Sha256}; use tracing::{debug, error}; use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf}; diff --git a/crates/turborepo-vt100/src/lib.rs b/crates/turborepo-vt100/src/lib.rs index 4cb31909d2fe5..ea24ef28e59ec 100644 --- a/crates/turborepo-vt100/src/lib.rs +++ b/crates/turborepo-vt100/src/lib.rs @@ -33,7 +33,6 @@ //! ); //! ``` -#![warn(clippy::cargo)] #![warn(clippy::pedantic)] #![warn(clippy::nursery)] #![warn(clippy::as_conversions)] diff --git a/crates/turborepo-wax/src/walk/mod.rs b/crates/turborepo-wax/src/walk/mod.rs index 45c94e9295c1a..71696a454081d 100644 --- a/crates/turborepo-wax/src/walk/mod.rs +++ b/crates/turborepo-wax/src/walk/mod.rs @@ -80,7 +80,7 @@ use std::{ }; use thiserror::Error; -use walkdir::{self, DirEntry, Error, WalkDir}; +use walkdir::{DirEntry, Error, WalkDir}; pub use crate::walk::glob::{GlobEntry, GlobWalker}; use crate::{ diff --git a/rust-toolchain b/rust-toolchain index 1d77724c9b5bb..fb98c0f091c33 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2023-11-16 +nightly-2024-04-03 diff --git a/xtask/src/command.rs b/xtask/src/command.rs index 625faadeb85a4..c4ee697a1b936 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -29,7 +29,7 @@ impl Command { } pub fn error_message>(mut self, message: S) -> Self { - self.error_message = message.as_ref().to_owned(); + message.as_ref().clone_into(&mut self.error_message); self } diff --git a/xtask/src/publish.rs b/xtask/src/publish.rs index 50847283487e2..60f83ebecad94 100644 --- a/xtask/src/publish.rs +++ b/xtask/src/publish.rs @@ -242,7 +242,7 @@ pub fn run_bump(names: HashSet, dry_run: bool) { if workspace.name.is_empty() || pkg_json.private { None } else { - pkg_json.path = workspace.path.clone(); + pkg_json.path.clone_from(&workspace.path); Some(pkg_json) } }) diff --git a/xtask/src/summarize_bench/mod.rs b/xtask/src/summarize_bench/mod.rs index de5b48bda5e71..59a643e88af91 100644 --- a/xtask/src/summarize_bench/mod.rs +++ b/xtask/src/summarize_bench/mod.rs @@ -2,7 +2,6 @@ pub(crate) mod data; use std::{ collections::{hash_map::Entry, BTreeMap, HashMap}, - convert::{TryFrom, TryInto}, fs::File, path::{Path, PathBuf}, time::{Duration, UNIX_EPOCH},