Skip to content

Commit

Permalink
feat: Upgrade to Rust 1.82.0 (#9293)
Browse files Browse the repository at this point in the history
### Description

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->
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`
<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
ognevny authored Oct 22, 2024
1 parent 5e47ff6 commit 2ee2460
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 24 deletions.
4 changes: 3 additions & 1 deletion crates/turborepo-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 10 additions & 8 deletions crates/turborepo-dirs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<AbsoluteSystemPathBuf>, PathError> {
if let Ok(dir) = std::env::var("TURBO_CONFIG_DIR_PATH") {
return AbsoluteSystemPathBuf::new(dir).map(Some);
Expand All @@ -16,10 +17,11 @@ pub fn config_dir() -> Result<Option<AbsoluteSystemPathBuf>, 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<Option<AbsoluteSystemPathBuf>, PathError> {
if let Ok(dir) = std::env::var("VERCEL_CONFIG_DIR_PATH") {
return AbsoluteSystemPathBuf::new(dir).map(Some);
Expand Down
4 changes: 3 additions & 1 deletion crates/turborepo-filewatch/src/cookies.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 8 additions & 6 deletions crates/turborepo-filewatch/src/package_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ enum PackageState {
InvalidGlobs(String),
ValidWorkspaces {
package_manager: PackageManager,
filter: WorkspaceGlobs,
filter: Box<WorkspaceGlobs>,
workspaces: HashMap<AbsoluteSystemPathBuf, WorkspaceData>,
},
}
Expand All @@ -166,7 +166,7 @@ enum State {
debouncer: Arc<Debouncer>,
version: Version,
},
Ready(PackageState),
Ready(Box<PackageState>),
}

// Because our package manager detection is coupled with the workspace globs, we
Expand Down Expand Up @@ -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));
}
}
}
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -550,7 +552,7 @@ async fn discover_packages(repo_root: AbsoluteSystemPathBuf) -> PackageState {
.collect::<HashMap<_, _>>();
PackageState::ValidWorkspaces {
package_manager: initial_discovery.package_manager,
filter,
filter: Box::new(filter),
workspaces,
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/turborepo-globwalk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion crates/turborepo-repository/src/change_mapper/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion crates/turborepo-repository/src/package_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions crates/turborepo-ui/src/prefixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<W> {
Expand Down
6 changes: 4 additions & 2 deletions crates/turborepo-ui/src/wui/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ impl<'a> CurrentRun<'a> {
/// reading it.
pub type SharedState = Arc<Mutex<WebUIState>>;

/// 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<SharedState>,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-07-19"
channel = "nightly-2024-08-30"
components = ["rustfmt", "clippy"]
profile = "minimal"

0 comments on commit 2ee2460

Please sign in to comment.