From 2ee2460ed483943f45a512fbf28dea6063b05cc3 Mon Sep 17 00:00:00 2001 From: Maksim Bondarenkov <119937608+ognevny@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:12:10 +0300 Subject: [PATCH] feat: Upgrade to Rust 1.82.0 (#9293) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description fix https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph and https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant clippy lints ### Testing Instructions `cargo t` --- crates/turborepo-auth/src/lib.rs | 4 +++- crates/turborepo-dirs/src/lib.rs | 18 ++++++++++-------- crates/turborepo-filewatch/src/cookies.rs | 4 +++- .../turborepo-filewatch/src/package_watcher.rs | 14 ++++++++------ crates/turborepo-globwalk/src/lib.rs | 4 +++- .../src/change_mapper/package.rs | 5 ++++- .../src/package_graph/mod.rs | 4 +++- crates/turborepo-ui/src/prefixed.rs | 5 +++-- crates/turborepo-ui/src/wui/query.rs | 6 ++++-- rust-toolchain.toml | 2 +- 10 files changed, 42 insertions(+), 24 deletions(-) diff --git a/crates/turborepo-auth/src/lib.rs b/crates/turborepo-auth/src/lib.rs index 732b673c61eaa..72b34dd423e1e 100644 --- a/crates/turborepo-auth/src/lib.rs +++ b/crates/turborepo-auth/src/lib.rs @@ -27,7 +27,9 @@ pub const VERCEL_TOKEN_FILE: &str = "auth.json"; pub const TURBO_TOKEN_DIR: &str = "turborepo"; pub const TURBO_TOKEN_FILE: &str = "config.json"; -/// Token is the result of a successful login or an existing token. This acts as +/// Token. +/// +/// It's the result of a successful login or an existing token. This acts as /// a wrapper for a bunch of token operations, like validation. We explicitly do /// not store any information about the underlying token for a few reasons, like /// having a token invalidated on the web but not locally. diff --git a/crates/turborepo-dirs/src/lib.rs b/crates/turborepo-dirs/src/lib.rs index a72dc4b33005c..cff0645f4b18c 100644 --- a/crates/turborepo-dirs/src/lib.rs +++ b/crates/turborepo-dirs/src/lib.rs @@ -2,10 +2,11 @@ use dirs_next::config_dir as dirs_config_dir; use thiserror::Error; use turbopath::{AbsoluteSystemPathBuf, PathError}; -/// Returns the path to the user's configuration directory. This is a wrapper -/// around `dirs_next::config_dir` that also checks the `TURBO_CONFIG_DIR_PATH` -/// environment variable. If the environment variable is set, it will return -/// that path instead of `dirs_next::config_dir`. +/// Returns the path to the user's configuration directory. +/// +/// This is a wrapper around `dirs_next::config_dir` that also checks the +/// `TURBO_CONFIG_DIR_PATH` environment variable. If the environment variable +/// is set, it will return that path instead of `dirs_next::config_dir`. pub fn config_dir() -> Result, PathError> { if let Ok(dir) = std::env::var("TURBO_CONFIG_DIR_PATH") { return AbsoluteSystemPathBuf::new(dir).map(Some); @@ -16,10 +17,11 @@ pub fn config_dir() -> Result, PathError> { .transpose() } -/// Returns the path to the user's configuration directory. This is a wrapper -/// around `dirs_next::config_dir` that also checks the `VERCEL_CONFIG_DIR_PATH` -/// environment variable. If the environment variable is set, it will return -/// that path instead of `dirs_next::config_dir`. +/// Returns the path to the user's configuration directory. +/// +/// This is a wrapper around `dirs_next::config_dir` that also checks the +/// VERCEL_CONFIG_DIR_PATH` environment variable. If the environment variable +/// is set, it will return that path instead of `dirs_next::config_dir`. pub fn vercel_config_dir() -> Result, PathError> { if let Ok(dir) = std::env::var("VERCEL_CONFIG_DIR_PATH") { return AbsoluteSystemPathBuf::new(dir).map(Some); diff --git a/crates/turborepo-filewatch/src/cookies.rs b/crates/turborepo-filewatch/src/cookies.rs index c8be4481915a2..a1a1c38473bb4 100644 --- a/crates/turborepo-filewatch/src/cookies.rs +++ b/crates/turborepo-filewatch/src/cookies.rs @@ -1,4 +1,6 @@ -//! Cookies are the file watcher's way of synchronizing file system events. They +//! Cookies. +//! +//! They are the file watcher's way of synchronizing file system events. They //! are files that are added to the file system that are named with the format //! `[id].cookie`, where `[id]` is an increasing serial number, e.g. //! `1.cookie`, `2.cookie`, and so on. The daemon can then watch for the diff --git a/crates/turborepo-filewatch/src/package_watcher.rs b/crates/turborepo-filewatch/src/package_watcher.rs index 76fcc974c5799..448b4c6e44879 100644 --- a/crates/turborepo-filewatch/src/package_watcher.rs +++ b/crates/turborepo-filewatch/src/package_watcher.rs @@ -155,7 +155,7 @@ enum PackageState { InvalidGlobs(String), ValidWorkspaces { package_manager: PackageManager, - filter: WorkspaceGlobs, + filter: Box, workspaces: HashMap, }, } @@ -166,7 +166,7 @@ enum State { debouncer: Arc, version: Version, }, - Ready(PackageState), + Ready(Box), } // Because our package manager detection is coupled with the workspace globs, we @@ -289,7 +289,7 @@ impl Subscriber { // ignore this update, as we know it is stale. if package_result.version == *version { self.write_state(&package_result.state); - *state = State::Ready(package_result.state); + *state = State::Ready(Box::new(package_result.state)); } } } @@ -400,8 +400,10 @@ impl Subscriber { // If we don't have a valid package manager and workspace globs, nothing to be // done here let PackageState::ValidWorkspaces { - filter, workspaces, .. - } = package_state + ref filter, + ref mut workspaces, + .. + } = **package_state else { return; }; @@ -550,7 +552,7 @@ async fn discover_packages(repo_root: AbsoluteSystemPathBuf) -> PackageState { .collect::>(); PackageState::ValidWorkspaces { package_manager: initial_discovery.package_manager, - filter, + filter: Box::new(filter), workspaces, } } diff --git a/crates/turborepo-globwalk/src/lib.rs b/crates/turborepo-globwalk/src/lib.rs index f986b9059664c..9854ff793cba8 100644 --- a/crates/turborepo-globwalk/src/lib.rs +++ b/crates/turborepo-globwalk/src/lib.rs @@ -282,7 +282,9 @@ pub struct GlobError { reason: String, } -/// ValidatedGlob represents an input string that we have either validated or +/// ValidatedGlob. +/// +/// Represents an input string that we have either validated or /// modified to fit our constraints. It does not _yet_ validate that the glob is /// a valid glob pattern, just that we have checked for unix format, ':'s, clean /// paths, etc. diff --git a/crates/turborepo-repository/src/change_mapper/package.rs b/crates/turborepo-repository/src/change_mapper/package.rs index fa24e05d8e10e..f6aa3645a2bca 100644 --- a/crates/turborepo-repository/src/change_mapper/package.rs +++ b/crates/turborepo-repository/src/change_mapper/package.rs @@ -24,6 +24,7 @@ pub trait PackageChangeMapper { } /// Detects package by checking if the file is inside the package. +/// /// Does *not* use the `globalDependencies` in turbo.json. /// Since we don't have these dependencies, any file that is /// not in any package will automatically invalidate all @@ -77,7 +78,9 @@ pub enum Error { InvalidFilter(#[from] BuildError), } -/// A package detector that uses a global deps list to determine +/// A package detector. +/// +/// It uses a global deps list to determine /// if a file should cause all packages to be marked as changed. /// This is less conservative than the `DefaultPackageChangeMapper`, /// which assumes that any changed file that is not in a package diff --git a/crates/turborepo-repository/src/package_graph/mod.rs b/crates/turborepo-repository/src/package_graph/mod.rs index 2701c3ec26dfc..bdff72e1d862b 100644 --- a/crates/turborepo-repository/src/package_graph/mod.rs +++ b/crates/turborepo-repository/src/package_graph/mod.rs @@ -36,7 +36,9 @@ pub struct PackageGraph { repo_root: AbsoluteSystemPathBuf, } -/// The WorkspacePackage follows the Vercel glossary of terms where "Workspace" +/// The WorkspacePackage. +/// +/// It follows the Vercel glossary of terms where "Workspace" /// is the collection of packages and "Package" is a single package within the /// workspace. https://vercel.com/docs/vercel-platform/glossary /// There are other structs in this module that have "Workspace" in the name, diff --git a/crates/turborepo-ui/src/prefixed.rs b/crates/turborepo-ui/src/prefixed.rs index a6b577f8d0a63..f2f98a788fec4 100644 --- a/crates/turborepo-ui/src/prefixed.rs +++ b/crates/turborepo-ui/src/prefixed.rs @@ -8,8 +8,9 @@ use tracing::error; use crate::{ColorConfig, LineWriter}; -/// Writes messages with different prefixes, depending on log level. Note that -/// this does output the prefix when message is empty, unlike the Go +/// Writes messages with different prefixes, depending on log level. +/// +/// Note that this does output the prefix when message is empty, unlike the Go /// implementation. We do this because this behavior is what we actually /// want for replaying logs. pub struct PrefixedUI { diff --git a/crates/turborepo-ui/src/wui/query.rs b/crates/turborepo-ui/src/wui/query.rs index 004be8e278b86..51b4a6053db3f 100644 --- a/crates/turborepo-ui/src/wui/query.rs +++ b/crates/turborepo-ui/src/wui/query.rs @@ -37,8 +37,10 @@ impl<'a> CurrentRun<'a> { /// reading it. pub type SharedState = Arc>; -/// The query for actively running tasks (as opposed to the query for general -/// repository state `RepositoryQuery` in `turborepo_lib::query`) +/// The query for actively running tasks. +/// +/// (As opposed to the query for general repository state `RepositoryQuery` +/// in `turborepo_lib::query`) /// This is `None` when we're not actually running a task (e.g. `turbo query`) pub struct RunQuery { state: Option, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 702e3576d3baa..f540fb88506e7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-07-19" +channel = "nightly-2024-08-30" components = ["rustfmt", "clippy"] profile = "minimal"