From 6d188656da005efc999fd3ba803db3777f8ea079 Mon Sep 17 00:00:00 2001 From: Maksim Bondarenkov Date: Fri, 13 Sep 2024 10:59:46 +0300 Subject: [PATCH 1/2] feat: support rust 1.81.0 --- crates/turborepo-lib/src/lib.rs | 1 - crates/turborepo-lib/src/panic_handler.rs | 7 ++----- crates/turborepo-paths/src/absolute_system_path.rs | 2 +- crates/turborepo-paths/src/lib.rs | 1 - rust-toolchain.toml | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/turborepo-lib/src/lib.rs b/crates/turborepo-lib/src/lib.rs index be3e9b95eb581..0014816ab3d38 100644 --- a/crates/turborepo-lib/src/lib.rs +++ b/crates/turborepo-lib/src/lib.rs @@ -4,7 +4,6 @@ #![feature(hash_extract_if)] #![feature(option_get_or_insert_default)] #![feature(once_cell_try)] -#![feature(panic_info_message)] #![feature(try_blocks)] #![feature(impl_trait_in_assoc_type)] #![deny(clippy::all)] diff --git a/crates/turborepo-lib/src/panic_handler.rs b/crates/turborepo-lib/src/panic_handler.rs index 4cd4bd221e428..7b59874c83473 100644 --- a/crates/turborepo-lib/src/panic_handler.rs +++ b/crates/turborepo-lib/src/panic_handler.rs @@ -5,11 +5,8 @@ use crate::get_version; const OPEN_ISSUE_MESSAGE: &str = "Please open an issue at https://github.com/vercel/turborepo/issues/new/choose"; -pub fn panic_handler(panic_info: &std::panic::PanicInfo) { - let cause = panic_info - .message() - .map(ToString::to_string) - .unwrap_or_else(|| "Unknown".to_string()); +pub fn panic_handler(panic_info: &std::panic::PanicHookInfo) { + let cause = panic_info.to_string(); let explanation = match panic_info.location() { Some(location) => format!("file '{}' at line {}\n", location.file(), location.line()), diff --git a/crates/turborepo-paths/src/absolute_system_path.rs b/crates/turborepo-paths/src/absolute_system_path.rs index b85050ebb5a3c..2393a758b3336 100644 --- a/crates/turborepo-paths/src/absolute_system_path.rs +++ b/crates/turborepo-paths/src/absolute_system_path.rs @@ -193,7 +193,7 @@ impl AbsoluteSystemPath { pub fn try_exists(&self) -> Result { // try_exists is an experimental API and not yet in fs_err - Ok(std::fs::try_exists(&self.0)?) + Ok(std::fs::exists(&self.0)?) } pub fn extension(&self) -> Option<&str> { diff --git a/crates/turborepo-paths/src/lib.rs b/crates/turborepo-paths/src/lib.rs index 24f734d81432e..8debe62150c87 100644 --- a/crates/turborepo-paths/src/lib.rs +++ b/crates/turborepo-paths/src/lib.rs @@ -1,5 +1,4 @@ #![feature(assert_matches)] -#![feature(fs_try_exists)] #![deny(clippy::all)] //! Turborepo's path handling library. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ec33a6d0a9122..702e3576d3baa 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-05-31" +channel = "nightly-2024-07-19" components = ["rustfmt", "clippy"] profile = "minimal" From 67f223cfd52e2288b19b04a5d67802c79b3b1870 Mon Sep 17 00:00:00 2001 From: Maksim Bondarenkov Date: Fri, 13 Sep 2024 19:38:32 +0300 Subject: [PATCH 2/2] chore: fix clippy lints from rust 1.81.0 --- crates/turborepo-lib/src/shim/mod.rs | 2 +- crates/turborepo-lib/src/task_graph/visitor.rs | 3 +-- crates/turborepo-lib/src/task_hash.rs | 3 +-- crates/turborepo-scm/src/ls_tree.rs | 2 +- crates/turborepo-scm/src/status.rs | 2 +- crates/turborepo-vt100/src/screen.rs | 4 ++-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/turborepo-lib/src/shim/mod.rs b/crates/turborepo-lib/src/shim/mod.rs index 509d14859f1f6..4ae3651fa9ed8 100644 --- a/crates/turborepo-lib/src/shim/mod.rs +++ b/crates/turborepo-lib/src/shim/mod.rs @@ -161,7 +161,7 @@ fn spawn_npx_turbo( let mut command = process::Command::new(npx_path); command.arg("-y"); - command.arg(&format!("turbo@{turbo_version}")); + command.arg(format!("turbo@{turbo_version}")); // rather than passing an argument that local turbo might not understand, set // an environment variable that can be optionally used diff --git a/crates/turborepo-lib/src/task_graph/visitor.rs b/crates/turborepo-lib/src/task_graph/visitor.rs index 7c683161d01d6..4c37eaa77d943 100644 --- a/crates/turborepo-lib/src/task_graph/visitor.rs +++ b/crates/turborepo-lib/src/task_graph/visitor.rs @@ -980,9 +980,8 @@ impl ExecContext { let mut stdout_writer = self .task_cache .output_writer(prefixed_ui.task_writer()) - .map_err(|e| { + .inspect_err(|_| { telemetry.track_error(TrackedErrors::FailedToCaptureOutputs); - e })?; let exit_status = match process.wait_with_piped_outputs(&mut stdout_writer).await { diff --git a/crates/turborepo-lib/src/task_hash.rs b/crates/turborepo-lib/src/task_hash.rs index a6e1e9a4099a3..90a585e5f989a 100644 --- a/crates/turborepo-lib/src/task_hash.rs +++ b/crates/turborepo-lib/src/task_hash.rs @@ -142,12 +142,11 @@ impl PackageInputsHashes { ) .await }) - .map_err(|e| { + .inspect_err(|_| { tracing::debug!( "daemon file hashing timed out for {}", package_path ); - e }) .ok() // If we timed out, we don't need to // error, diff --git a/crates/turborepo-scm/src/ls_tree.rs b/crates/turborepo-scm/src/ls_tree.rs index 1a82670a9c1ed..fddf6f3e0f61d 100644 --- a/crates/turborepo-scm/src/ls_tree.rs +++ b/crates/turborepo-scm/src/ls_tree.rs @@ -72,7 +72,7 @@ fn nom_parse_ls_tree(i: &[u8]) -> nom::IResult<&[u8], LsTreeEntry<'_>> { let (i, _) = nom::bytes::complete::take(1usize)(i)?; let (i, filename) = nom::bytes::complete::is_not("\0")(i)?; // We explicitly support a missing terminator - let (i, _) = nom::combinator::opt(nom::bytes::complete::tag(&[b'\0']))(i)?; + let (i, _) = nom::combinator::opt(nom::bytes::complete::tag(b"\0"))(i)?; Ok((i, LsTreeEntry { filename, hash })) } diff --git a/crates/turborepo-scm/src/status.rs b/crates/turborepo-scm/src/status.rs index c9b8421c1d99b..dc6d89e686590 100644 --- a/crates/turborepo-scm/src/status.rs +++ b/crates/turborepo-scm/src/status.rs @@ -94,7 +94,7 @@ fn nom_parse_status(i: &[u8]) -> nom::IResult<&[u8], StatusEntry<'_>> { let (i, _) = nom::character::complete::space1(i)?; let (i, filename) = nom::bytes::complete::is_not("\0")(i)?; // We explicitly support a missing terminator - let (i, _) = nom::combinator::opt(nom::bytes::complete::tag(&[b'\0']))(i)?; + let (i, _) = nom::combinator::opt(nom::bytes::complete::tag(b"\0"))(i)?; Ok(( i, StatusEntry { diff --git a/crates/turborepo-vt100/src/screen.rs b/crates/turborepo-vt100/src/screen.rs index 22d7cd4e20c89..b51c1248a5067 100644 --- a/crates/turborepo-vt100/src/screen.rs +++ b/crates/turborepo-vt100/src/screen.rs @@ -1294,7 +1294,7 @@ impl Screen { // CSI h #[allow(clippy::unused_self)] - pub(crate) fn sm(&mut self, params: &vte::Params) { + pub(crate) fn sm(&self, params: &vte::Params) { // nothing, i think? if log::log_enabled!(log::Level::Debug) { log::debug!( @@ -1353,7 +1353,7 @@ impl Screen { // CSI l #[allow(clippy::unused_self)] - pub(crate) fn rm(&mut self, params: &vte::Params) { + pub(crate) fn rm(&self, params: &vte::Params) { // nothing, i think? if log::log_enabled!(log::Level::Debug) { log::debug!(