From d68ad24f2e7381b937554a31cbf3ee2a3081c144 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 09:53:37 +0100 Subject: [PATCH 01/10] Migrate werk-util --- Cargo.toml | 2 +- werk-util/Cargo.toml | 2 +- werk-util/diagnostic.rs | 2 +- werk-util/symbol.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ddf33acb..d85905ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ resolver = "2" [workspace.package] version = "0.1.0" -rust-version = "1.83" +rust-version = "1.85" edition = "2021" license = "MIT OR Apache-2.0" diff --git a/werk-util/Cargo.toml b/werk-util/Cargo.toml index 2b3d10ef..912f9506 100644 --- a/werk-util/Cargo.toml +++ b/werk-util/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-util" version.workspace = true rust-version.workspace = true -edition.workspace = true +edition = "2024" license.workspace = true [lib] diff --git a/werk-util/diagnostic.rs b/werk-util/diagnostic.rs index bbeb255f..e741538c 100644 --- a/werk-util/diagnostic.rs +++ b/werk-util/diagnostic.rs @@ -1,5 +1,5 @@ pub use annotate_snippets::Level; -use indexmap::{map::Entry, IndexMap}; +use indexmap::{IndexMap, map::Entry}; use crate::DiagnosticSpan; diff --git a/werk-util/symbol.rs b/werk-util/symbol.rs index ddf9ec41..ccf6f4ee 100644 --- a/werk-util/symbol.rs +++ b/werk-util/symbol.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use hashbrown::{hash_map::EntryRef, HashMap}; +use hashbrown::{HashMap, hash_map::EntryRef}; use parking_lot::{Mutex, MutexGuard}; #[derive(Clone, Copy, Eq)] From 01c58f2312a4da07fa94b991779610520f6d7ddd Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 09:56:20 +0100 Subject: [PATCH 02/10] Migrate werk-fs --- werk-fs/Cargo.toml | 2 +- werk-fs/absolute.rs | 2 +- werk-fs/path.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/werk-fs/Cargo.toml b/werk-fs/Cargo.toml index 590d16b0..ed534889 100644 --- a/werk-fs/Cargo.toml +++ b/werk-fs/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-fs" version.workspace = true rust-version.workspace = true -edition.workspace = true +edition = "2024" license.workspace = true [lib] diff --git a/werk-fs/absolute.rs b/werk-fs/absolute.rs index 9af3922f..866037e0 100644 --- a/werk-fs/absolute.rs +++ b/werk-fs/absolute.rs @@ -1,8 +1,8 @@ use std::{borrow::Borrow, ops::Deref}; use crate::{ - traits::{IntoBoxedUnsized, Join, Normalize, Parent, Push}, AsPath, TooManyParents, + traits::{IntoBoxedUnsized, Join, Normalize, Parent, Push}, }; /// Toll-free wrapper marking that a path is normalized. diff --git a/werk-fs/path.rs b/werk-fs/path.rs index 7f81eca7..94329a37 100644 --- a/werk-fs/path.rs +++ b/werk-fs/path.rs @@ -8,8 +8,8 @@ use std::{ }; use crate::{ - traits::{self, Normalize}, Absolute, + traits::{self, Normalize}, }; pub trait AsPath { From ed30b5082c4fab34120ee968834d6f3c632fa130 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:01:54 +0100 Subject: [PATCH 03/10] Migrate werk-parser --- werk-parser/Cargo.toml | 2 +- werk-parser/ast.rs | 2 +- werk-parser/ast/expr.rs | 2 +- werk-parser/ast/keyword.rs | 4 ++-- werk-parser/ast/token.rs | 4 ++-- werk-parser/parser.rs | 9 +++++---- werk-parser/parser/string.rs | 16 ++++++++-------- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/werk-parser/Cargo.toml b/werk-parser/Cargo.toml index 5bc9eb95..e5fd9c4f 100644 --- a/werk-parser/Cargo.toml +++ b/werk-parser/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-parser" version.workspace = true rust-version.workspace = true -edition.workspace = true +edition = "2024" license.workspace = true [lib] diff --git a/werk-parser/ast.rs b/werk-parser/ast.rs index 73230488..91b3124a 100644 --- a/werk-parser/ast.rs +++ b/werk-parser/ast.rs @@ -1,6 +1,6 @@ use std::hash::Hash as _; -use werk_util::{hash_is_semantic, SemanticHash, Span, Spanned}; +use werk_util::{SemanticHash, Span, Spanned, hash_is_semantic}; mod expr; pub mod keyword; diff --git a/werk-parser/ast/expr.rs b/werk-parser/ast/expr.rs index c1d57b79..e09dd647 100644 --- a/werk-parser/ast/expr.rs +++ b/werk-parser/ast/expr.rs @@ -1,7 +1,7 @@ use std::hash::Hash as _; use super::{ - keyword, token, Body, BodyStmt, ConfigInt, Ident, PatternExpr, StringExpr, Trailing, Whitespace, + Body, BodyStmt, ConfigInt, Ident, PatternExpr, StringExpr, Trailing, Whitespace, keyword, token, }; use werk_util::{SemanticHash, Span, Spanned}; diff --git a/werk-parser/ast/keyword.rs b/werk-parser/ast/keyword.rs index 0bed808a..2d75c317 100644 --- a/werk-parser/ast/keyword.rs +++ b/werk-parser/ast/keyword.rs @@ -1,8 +1,8 @@ use winnow::Parser as _; use crate::{ - parser::{Input, PResult, Parse, Parser as _}, Failure, + parser::{Input, PResult, Parse, Parser as _}, }; use werk_util::{Offset, Span, Spanned}; @@ -55,7 +55,7 @@ macro_rules! def_keyword { fn span(&self) -> Span { Span { start: self.0, - end: Offset(self.0 .0 + $s.len() as u32), + end: Offset(self.0.0 + $s.len() as u32), } } } diff --git a/werk-parser/ast/token.rs b/werk-parser/ast/token.rs index a0785695..c521894f 100644 --- a/werk-parser/ast/token.rs +++ b/werk-parser/ast/token.rs @@ -3,8 +3,8 @@ use winnow::Parser as _; use werk_util::{Offset, Span, Spanned}; use crate::{ - parser::{Input, PResult, Parse, Parser as _}, Failure, + parser::{Input, PResult, Parse, Parser as _}, }; #[derive(Clone, Copy, Default, PartialEq)] @@ -33,7 +33,7 @@ impl Spanned for Token { fn span(&self) -> Span { Span { start: self.0, - end: Offset(self.0 .0 + 1), + end: Offset(self.0.0 + 1), } } } diff --git a/werk-parser/parser.rs b/werk-parser/parser.rs index 1d3bbfa2..59a7c036 100644 --- a/werk-parser/parser.rs +++ b/werk-parser/parser.rs @@ -2,17 +2,18 @@ use std::marker::PhantomData; use werk_util::{AsDiagnostic as _, DiagnosticFileId, DiagnosticSourceMap, Offset, Span, Spanned}; use winnow::{ + Parser as _, ascii::{line_ending, till_line_ending}, combinator::{alt, cut_err, delimited, empty, eof, opt, peek, preceded, repeat, seq}, error::AddContext as _, stream::{Location, Stream as _}, token::{any, none_of, one_of, take_while}, - Parser as _, }; use crate::{ + ErrContext, Error, Failure, ModalErr, ast::{self, keyword, token, ws_ignore}, - fatal, ErrContext, Error, Failure, ModalErr, + fatal, }; mod string; @@ -1018,7 +1019,7 @@ impl SetFailure for ModalErr { #[inline] fn set_failure(&mut self, failure: Failure) { match self { - ModalErr::Backtrack(_, ref mut fail) => *fail = failure, + ModalErr::Backtrack(_, fail) => *fail = failure, ModalErr::Error(err) => err.fail = failure, } } @@ -1102,7 +1103,7 @@ mod tests { keyword::{self, Keyword as _}, trailing_ignore, ws, ws_ignore, }, - parser::{parse, Offset, ParsedWhitespace}, + parser::{Offset, ParsedWhitespace, parse}, }; use werk_util::span; use winnow::Parser as _; diff --git a/werk-parser/parser/string.rs b/werk-parser/parser/string.rs index 51d6e655..50a3d7ca 100644 --- a/werk-parser/parser/string.rs +++ b/werk-parser/parser/string.rs @@ -1,13 +1,14 @@ use std::{fmt::Write, sync::Arc}; use crate::{ + Error, Failure, ModalErr, ast::{self, token}, fatal, parser::{Input, Parser as _}, - Error, Failure, ModalErr, }; use werk_util::{Offset, Symbol}; use winnow::{ + Parser, ascii::{dec_int, digit1, multispace1}, combinator::{ alt, cut_err, delimited, empty, opt, peek, preceded, repeat, separated, separated_pair, @@ -15,10 +16,9 @@ use winnow::{ }, stream::Location, token::{any, one_of, take_till, take_while}, - Parser, }; -use super::{parse, PResult, Parse, Spanned}; +use super::{PResult, Parse, Spanned, parse}; impl Parse for ast::StringExpr { fn parse(input: &mut Input) -> PResult { @@ -259,7 +259,7 @@ enum StringFragment<'a> { fn push_string_fragment(expr: &mut ast::StringExpr, frag: StringFragment) { match frag { StringFragment::Literal(lit) => { - if let Some(ast::StringFragment::Literal(ref mut last)) = expr.fragments.last_mut() { + if let Some(ast::StringFragment::Literal(last)) = expr.fragments.last_mut() { last.push_str(lit); } else { expr.fragments @@ -267,7 +267,7 @@ fn push_string_fragment(expr: &mut ast::StringExpr, frag: StringFragment) { } } StringFragment::EscapedChar(ch) => { - if let Some(ast::StringFragment::Literal(ref mut last)) = expr.fragments.last_mut() { + if let Some(ast::StringFragment::Literal(last)) = expr.fragments.last_mut() { last.push(ch); } else { expr.fragments @@ -287,7 +287,7 @@ fn push_string_fragment(expr: &mut ast::StringExpr, frag: StringFragment) { fn push_pattern_fragment(expr: &mut ast::PatternExpr, frag: StringFragment) { match frag { StringFragment::Literal(lit) => { - if let Some(ast::PatternFragment::Literal(ref mut last)) = expr.fragments.last_mut() { + if let Some(ast::PatternFragment::Literal(last)) = expr.fragments.last_mut() { last.push_str(lit); } else { expr.fragments @@ -295,7 +295,7 @@ fn push_pattern_fragment(expr: &mut ast::PatternExpr, frag: StringFragment) { } } StringFragment::EscapedChar(ch) => { - if let Some(ast::PatternFragment::Literal(ref mut last)) = expr.fragments.last_mut() { + if let Some(ast::PatternFragment::Literal(last)) = expr.fragments.last_mut() { last.push(ch); } else { expr.fragments @@ -495,7 +495,7 @@ fn file_extension<'a>(input: &mut Input<'a>) -> PResult<&'a str> { #[cfg(test)] mod tests { use crate::parser::parse; - use werk_util::{span, Span}; + use werk_util::{Span, span}; use super::*; From 71304b6833de4b70c7baa6ee8e5af577bfd180a2 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:08:41 +0100 Subject: [PATCH 04/10] Migrate werk-runner --- werk-runner/Cargo.toml | 2 +- werk-runner/depfile.rs | 2 +- werk-runner/error.rs | 28 ++++++++++++++++++---------- werk-runner/eval/used.rs | 8 ++++---- werk-runner/io.rs | 2 +- werk-runner/io/child.rs | 2 +- werk-runner/ir.rs | 4 ++-- werk-runner/outdatedness.rs | 3 ++- werk-runner/pattern.rs | 4 ++-- werk-runner/runner.rs | 14 +++++++------- werk-runner/scope.rs | 27 ++++++--------------------- werk-runner/value.rs | 2 +- werk-runner/workspace.rs | 6 +++--- 13 files changed, 49 insertions(+), 55 deletions(-) diff --git a/werk-runner/Cargo.toml b/werk-runner/Cargo.toml index 60dc7b0a..065d5e34 100644 --- a/werk-runner/Cargo.toml +++ b/werk-runner/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-runner" version.workspace = true rust-version.workspace = true -edition.workspace = true +edition = "2024" license.workspace = true [lib] diff --git a/werk-runner/depfile.rs b/werk-runner/depfile.rs index f5832f50..7b3837c3 100644 --- a/werk-runner/depfile.rs +++ b/werk-runner/depfile.rs @@ -1,13 +1,13 @@ use std::{path::PathBuf, sync::Arc}; use winnow::{ + Parser as _, ascii::{line_ending, multispace0, space0, space1}, combinator::{ alt, cut_err, delimited, eof, opt, peek, preceded, repeat, separated_pair, terminated, }, error::{StrContext, StrContextValue}, token::{none_of, take_till}, - Parser as _, }; type PResult = winnow::ModalResult; diff --git a/werk-runner/error.rs b/werk-runner/error.rs index c8a059ab..f07f127f 100644 --- a/werk-runner/error.rs +++ b/werk-runner/error.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use werk_fs::Absolute; use werk_util::{AnnotateLevelExt, DiagnosticFileId, DiagnosticSpan, Level}; -use crate::{depfile::DepfileError, OwnedDependencyChain, ShellCommandLine, TaskId, Value}; +use crate::{OwnedDependencyChain, ShellCommandLine, TaskId, Value, depfile::DepfileError}; #[derive(Debug, Clone, thiserror::Error)] pub enum Error { @@ -36,9 +36,13 @@ pub enum Error { /// `TrackRunner` interface. #[error("command failed: {0}")] CommandFailed(std::process::ExitStatus), - #[error("cannot convert abstract paths to native OS paths yet; output directory has not been set in the [global] scope")] + #[error( + "cannot convert abstract paths to native OS paths yet; output directory has not been set in the [global] scope" + )] OutputDirectoryNotAvailable, - #[error("depfile was not found: '{0}'; perhaps the rule to generate it writes to the wrong location?")] + #[error( + "depfile was not found: '{0}'; perhaps the rule to generate it writes to the wrong location?" + )] DepfileNotFound(werk_fs::PathBuf), #[error(transparent)] DepfileError(#[from] DepfileError), @@ -177,7 +181,7 @@ impl werk_util::AsDiagnostic for Error { // Additional context and help match self { - Error::AmbiguousPattern(ref err) => diag.annotations([ + Error::AmbiguousPattern(err) => diag.annotations([ err.pattern1.annotation(Level::Note, "first pattern here"), err.pattern2.annotation(Level::Note, "second pattern here"), ]), @@ -213,8 +217,8 @@ impl PartialEq for ShellError { fn eq(&self, other: &Self) -> bool { self.command == other.command && match (&*self.result, &*other.result) { - (Ok(ref l), Ok(ref r)) => l == r, - (Err(ref l), Err(ref r)) => l.kind() == r.kind(), + (Ok(l), Ok(r)) => l == r, + (Err(l), Err(r)) => l.kind() == r.kind(), _ => false, } } @@ -226,12 +230,12 @@ impl std::fmt::Display for ShellError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "command failed: {}", self.command.program.display())?; match &*self.result { - Ok(ref output) => { + Ok(output) => { if !output.stderr.is_empty() { write!(f, "\nstderr:\n{}", String::from_utf8_lossy(&output.stderr))?; } } - Err(ref err) => writeln!(f, "\nerror: {err}")?, + Err(err) => writeln!(f, "\nerror: {err}")?, } Ok(()) @@ -256,7 +260,9 @@ pub enum EvalError { DuplicatePattern(DiagnosticSpan, DiagnosticSpan), #[error("duplicate config statement")] DuplicateConfigStatement(DiagnosticSpan, DiagnosticSpan), - #[error("no implied interpolation value in this context; provide an identifier or a capture group index")] + #[error( + "no implied interpolation value in this context; provide an identifier or a capture group index" + )] NoImpliedValue(DiagnosticSpan), #[error("capture group with index {1} is out of bounds in the current scope")] NoSuchCaptureGroup(DiagnosticSpan, u32), @@ -268,7 +274,9 @@ pub enum EvalError { PatternStemInterpolationInPattern(DiagnosticSpan), #[error("path resolution `<...>` interpolations cannot be used in patterns")] ResolvePathInPattern(DiagnosticSpan), - #[error("path resolution `<...>` of a string that already contains resolved paths, but is not a resolved path")] + #[error( + "path resolution `<...>` of a string that already contains resolved paths, but is not a resolved path" + )] DoubleResolvePath(DiagnosticSpan), #[error("join interpolations `{{...*}}` cannot be used in patterns")] JoinInPattern(DiagnosticSpan), diff --git a/werk-runner/eval/used.rs b/werk-runner/eval/used.rs index c5674269..dff3ab3d 100644 --- a/werk-runner/eval/used.rs +++ b/werk-runner/eval/used.rs @@ -38,7 +38,7 @@ impl SmallSet { SmallSet::One(lhs) => { *self = SmallSet::Set(BTreeSet::from_iter([*lhs, *rhs])); } - SmallSet::Set(ref mut lhs) => { + SmallSet::Set(lhs) => { lhs.insert(*rhs); } }, @@ -65,7 +65,7 @@ impl SmallSet { SmallSet::One(lhs) => { *self = SmallSet::Set(BTreeSet::from_iter([*lhs, rhs])); } - SmallSet::Set(ref mut lhs) => { + SmallSet::Set(lhs) => { lhs.insert(rhs); } }, @@ -91,7 +91,7 @@ impl SmallSet { SmallSet::One(one) => { *self = SmallSet::Set(BTreeSet::from_iter([*one, var])); } - SmallSet::Set(ref mut set) => { + SmallSet::Set(set) => { set.insert(var); } } @@ -210,7 +210,7 @@ impl IntoIterator for SmallSet { impl Extend for SmallSet { fn extend>(&mut self, iter: T) { - if let SmallSet::Set(ref mut set) = self { + if let SmallSet::Set(set) = self { set.extend(iter); } else { for var in iter { diff --git a/werk-runner/io.rs b/werk-runner/io.rs index 6bca69f6..b7f0dc80 100644 --- a/werk-runner/io.rs +++ b/werk-runner/io.rs @@ -272,7 +272,7 @@ impl Io for RealSystem { impl Drop for Visitor<'_> { fn drop(&mut self) { let mut results = self.1.lock(); - let Ok(ref mut entries) = &mut *results else { + let Ok(entries) = &mut *results else { // Already errored. return; }; diff --git a/werk-runner/io/child.rs b/werk-runner/io/child.rs index 4c1c2e94..9683f593 100644 --- a/werk-runner/io/child.rs +++ b/werk-runner/io/child.rs @@ -6,7 +6,7 @@ use std::{ }; use futures::{ - io::BufReader, ready, AsyncBufRead, AsyncRead, AsyncWrite, FutureExt as _, Stream, StreamExt, + AsyncBufRead, AsyncRead, AsyncWrite, FutureExt as _, Stream, StreamExt, io::BufReader, ready, }; pub trait Child: Send + Sync + Unpin { diff --git a/werk-runner/ir.rs b/werk-runner/ir.rs index a13c6148..74cee6bb 100644 --- a/werk-runner/ir.rs +++ b/werk-runner/ir.rs @@ -4,8 +4,8 @@ use werk_parser::ast; use werk_util::{DiagnosticFileId, DiagnosticMainSourceMap, DiagnosticSpan, Symbol}; use crate::{ - cache::Hash128, AmbiguousPatternError, ConfigVar, EvalError, LocalVariables, Pattern, - PatternMatchData, Value, + AmbiguousPatternError, ConfigVar, EvalError, LocalVariables, Pattern, PatternMatchData, Value, + cache::Hash128, }; type Result = std::result::Result; diff --git a/werk-runner/outdatedness.rs b/werk-runner/outdatedness.rs index d7eb0ecf..127cd12c 100644 --- a/werk-runner/outdatedness.rs +++ b/werk-runner/outdatedness.rs @@ -7,9 +7,10 @@ use werk_fs::{Absolute, SymPath}; use werk_util::Symbol; use crate::{ + TaskId, Workspace, cache::TargetOutdatednessCache, eval::{Used, UsedVariable}, - ir, TaskId, Workspace, + ir, }; /// A reason why a variable or recipe is "outdated". diff --git a/werk-runner/pattern.rs b/werk-runner/pattern.rs index 28eab72b..ddfda430 100644 --- a/werk-runner/pattern.rs +++ b/werk-runner/pattern.rs @@ -33,8 +33,8 @@ impl PartialEq for Pattern { #[inline] fn eq(&self, other: &Self) -> bool { match (&self.matcher, &other.matcher) { - (PatternMatcher::Literal(ref lhs), PatternMatcher::Literal(ref rhs)) => *lhs == *rhs, - (PatternMatcher::Regex(ref lhs), PatternMatcher::Regex(ref rhs)) => { + (PatternMatcher::Literal(lhs), PatternMatcher::Literal(rhs)) => *lhs == *rhs, + (PatternMatcher::Regex(lhs), PatternMatcher::Regex(rhs)) => { lhs.regex.as_str() == rhs.regex.as_str() } _ => false, diff --git a/werk-runner/runner.rs b/werk-runner/runner.rs index a04917c0..ac2dfddf 100644 --- a/werk-runner/runner.rs +++ b/werk-runner/runner.rs @@ -1,18 +1,18 @@ use std::{future::Future, sync::Arc, time::SystemTime}; -use futures::{channel::oneshot, StreamExt}; -use indexmap::{map::Entry, IndexMap}; +use futures::{StreamExt, channel::oneshot}; +use indexmap::{IndexMap, map::Entry}; use parking_lot::Mutex; use werk_fs::{Absolute, Normalize as _, Path, SymPath}; use werk_util::{Annotated, AsDiagnostic, DiagnosticSpan, Symbol}; use crate::{ - depfile::Depfile, - eval::{self, Eval}, - ir::{self}, AmbiguousPatternError, BuildRecipeScope, ChildCaptureOutput, ChildLinesStream, Env, Error, Outdatedness, OutdatednessTracker, Reason, Scope as _, ShellCommandLine, TaskRecipeScope, Value, Warning, Workspace, WorkspaceSettings, + depfile::Depfile, + eval::{self, Eval}, + ir, }; /// Workspace-wide runner state. @@ -356,8 +356,8 @@ impl<'a> Inner<'a> { fn schedule<'a>(this: &RunnerState, spec: TaskSpec<'a>) -> Scheduling<'a> { match this.tasks.lock().entry(spec.to_task_id()) { Entry::Occupied(mut entry) => match entry.get_mut() { - TaskStatus::Built(ref result) => Scheduling::Done(result.clone()), - TaskStatus::Pending(ref mut waiters) => { + TaskStatus::Built(result) => Scheduling::Done(result.clone()), + TaskStatus::Pending(waiters) => { let (send, recv) = oneshot::channel(); waiters.push(send); Scheduling::Pending(recv) diff --git a/werk-runner/scope.rs b/werk-runner/scope.rs index ecc37b83..5c9cd641 100644 --- a/werk-runner/scope.rs +++ b/werk-runner/scope.rs @@ -2,8 +2,9 @@ use ahash::HashMap; use werk_util::{DiagnosticSpan, Symbol, SymbolRegistryLock}; use crate::{ + Io, PatternMatchData, Render, TaskId, Value, Warning, Workspace, eval::{Eval, Used}, - ir, Io, PatternMatchData, Render, TaskId, Value, Warning, Workspace, + ir, }; pub type LocalVariables = indexmap::IndexMap>; @@ -310,20 +311,12 @@ pub const fn current_arch_family() -> &'static str { #[must_use] pub const fn exe_suffix() -> &'static str { - if cfg!(windows) { - ".exe" - } else { - "" - } + if cfg!(windows) { ".exe" } else { "" } } #[must_use] pub const fn dylib_prefix() -> &'static str { - if cfg!(windows) { - "" - } else { - "lib" - } + if cfg!(windows) { "" } else { "lib" } } #[must_use] @@ -339,20 +332,12 @@ pub const fn dylib_suffix() -> &'static str { #[must_use] pub const fn staticlib_prefix() -> &'static str { - if cfg!(windows) { - "" - } else { - "lib" - } + if cfg!(windows) { "" } else { "lib" } } #[must_use] pub const fn staticlib_suffix() -> &'static str { - if cfg!(windows) { - ".lib" - } else { - ".a" - } + if cfg!(windows) { ".lib" } else { ".a" } } pub fn default_global_constants() -> &'static HashMap { diff --git a/werk-runner/value.rs b/werk-runner/value.rs index c2552425..54842a20 100644 --- a/werk-runner/value.rs +++ b/werk-runner/value.rs @@ -465,7 +465,7 @@ impl Value { visitor: &mut V, ) -> Result<(), E> { match this { - Value::List(ref mut values) => { + Value::List(values) => { for value in values { try_map_strings(value, visitor)?; } diff --git a/werk-runner/workspace.rs b/werk-runner/workspace.rs index f2a839c6..bb929478 100644 --- a/werk-runner/workspace.rs +++ b/werk-runner/workspace.rs @@ -7,10 +7,10 @@ use werk_parser::ast; use werk_util::{DiagnosticFileId, DiagnosticSpan, Symbol}; use crate::{ + DirEntry, Error, EvalError, Io, Render, Value, Warning, cache::{Hash128, TargetOutdatednessCache, WerkCache}, eval::{self, Eval, UsedVariable}, ir::{self, BuildRecipe, TaskRecipe}, - DirEntry, Error, EvalError, Io, Render, Value, Warning, }; #[derive(Clone)] @@ -151,7 +151,7 @@ impl Workspace { return Err(Error::InvalidTargetPath( entry.path.display().to_string(), err, - )) + )); } Err(_) => continue, }; @@ -358,7 +358,7 @@ impl Workspace { // Note: Other types of `default` statements are handled upstream, while // parsing `Defaults`, which happens prior to creating the workspace. - if let ast::DefaultStmt::Target(ref stmt) = stmt { + if let ast::DefaultStmt::Target(stmt) = stmt { let value = eval::eval_string_expr(self, &stmt.value, file)?; self.default_target = Some(value.value.string); } From e351a23b5e4c12d1684928407720adfea94dc6ec Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:10:44 +0100 Subject: [PATCH 05/10] Migrate werk-cli --- werk-cli/Cargo.toml | 2 +- werk-cli/complete.rs | 4 ++-- werk-cli/main.rs | 4 +++- werk-cli/render/ansi/term_width.rs | 4 ++-- werk-cli/render/log.rs | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/werk-cli/Cargo.toml b/werk-cli/Cargo.toml index 096cb944..8369d93d 100644 --- a/werk-cli/Cargo.toml +++ b/werk-cli/Cargo.toml @@ -3,7 +3,7 @@ name = "werk-cli" build = "build.rs" version.workspace = true rust-version.workspace = true -edition.workspace = true +edition = "2024" license.workspace = true [[bin]] diff --git a/werk-cli/complete.rs b/werk-cli/complete.rs index 3120ab04..66fcc9bc 100644 --- a/werk-cli/complete.rs +++ b/werk-cli/complete.rs @@ -6,10 +6,10 @@ use werk_fs::Normalize; use werk_runner::Workspace; use werk_util::DiagnosticFileId; +use crate::Args; use crate::dry_run::DryRun; -use crate::render::null::NullRender; use crate::render::ColorOutputKind; -use crate::Args; +use crate::render::null::NullRender; use crate::{find_werkfile, get_workspace_dir, get_workspace_settings}; fn with_werk(f: impl FnOnce(Workspace) -> Result + 'static) -> T { diff --git a/werk-cli/main.rs b/werk-cli/main.rs index d7032d31..610007c4 100644 --- a/werk-cli/main.rs +++ b/werk-cli/main.rs @@ -161,7 +161,9 @@ pub enum Error { NoWerkfile, #[error("Invalid define (must take the form `key=value`): {0}")] InvalidDefineArg(String), - #[error("No target specified. Pass a target name on the command-line, or set the `config.default` variable. Use `--list` to get a list of available targets.")] + #[error( + "No target specified. Pass a target name on the command-line, or set the `config.default` variable. Use `--list` to get a list of available targets." + )] NoTarget, #[error(transparent)] Io(#[from] std::io::Error), diff --git a/werk-cli/render/ansi/term_width.rs b/werk-cli/render/ansi/term_width.rs index 759174f8..c2fa3e02 100644 --- a/werk-cli/render/ansi/term_width.rs +++ b/werk-cli/render/ansi/term_width.rs @@ -58,15 +58,15 @@ mod imp { #[cfg(windows)] mod imp { use windows_sys::{ - core::PCSTR, Win32::{ Foundation::{CloseHandle, GENERIC_READ, GENERIC_WRITE, INVALID_HANDLE_VALUE}, Storage::FileSystem::{CreateFileA, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING}, System::Console::{ - GetConsoleScreenBufferInfo, GetStdHandle, CONSOLE_SCREEN_BUFFER_INFO, + CONSOLE_SCREEN_BUFFER_INFO, GetConsoleScreenBufferInfo, GetStdHandle, STD_ERROR_HANDLE, }, }, + core::PCSTR, }; use super::TtyWidth; diff --git a/werk-cli/render/log.rs b/werk-cli/render/log.rs index bce56ccb..813e93f8 100644 --- a/werk-cli/render/log.rs +++ b/werk-cli/render/log.rs @@ -40,7 +40,7 @@ impl werk_runner::Render for LogWatcher { result: &Result, ) { match result { - Ok(ref status) => { + Ok(status) => { if let werk_runner::BuildStatus::Complete(task_id, _) = status { tracing::info!(task_id = %task_id, "Success"); } From deea4076fb5f6428bc87a034b9550905d2aa92c2 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:12:34 +0100 Subject: [PATCH 06/10] Migrate tests --- tests/Cargo.toml | 2 +- tests/mock_io.rs | 20 +++++++++++--------- tests/test_eval.rs | 4 ++-- tests/test_pattern_match.rs | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/Cargo.toml b/tests/Cargo.toml index a8a8c619..e85760b6 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -2,7 +2,7 @@ name = "tests" publish = false version.workspace = true -edition.workspace = true +edition = "2024" rust-version.workspace = true license.workspace = true diff --git a/tests/mock_io.rs b/tests/mock_io.rs index e1676fc2..1fff1e5f 100644 --- a/tests/mock_io.rs +++ b/tests/mock_io.rs @@ -1,17 +1,17 @@ use core::panic; use std::{ - collections::{hash_map, HashMap}, + collections::{HashMap, hash_map}, ffi::{OsStr, OsString}, pin::Pin, - sync::{atomic::AtomicU64, Arc, OnceLock}, + sync::{Arc, OnceLock, atomic::AtomicU64}, time::SystemTime, }; use parking_lot::Mutex; use werk_fs::Absolute; use werk_runner::{ - globset, BuildStatus, DirEntry, Env, Error, EvalError, GlobSettings, Io, Metadata, - Outdatedness, ShellCommandLine, TaskId, Warning, WhichError, Workspace, WorkspaceSettings, + BuildStatus, DirEntry, Env, Error, EvalError, GlobSettings, Io, Metadata, Outdatedness, + ShellCommandLine, TaskId, Warning, WhichError, Workspace, WorkspaceSettings, globset, }; use werk_util::{ Annotated, AsDiagnostic as _, DiagnosticFileId, DiagnosticSource, DiagnosticSourceMap, Offset, @@ -244,7 +244,7 @@ impl<'a> Test<'a> { Ok(ast) => ast, Err(err) => { return Err(Error::Eval(EvalError::Parse(DiagnosticFileId(0), err)) - .into_diagnostic_error(&*self as _)) + .into_diagnostic_error(&*self as _)); } }; self.reload_test_pragmas(&ast); @@ -271,7 +271,7 @@ impl<'a> Test<'a> { ) { Ok(_) => (), Err(err) => { - return Err(Error::Eval(err).into_diagnostic_error(&workspace.manifest as _)) + return Err(Error::Eval(err).into_diagnostic_error(&workspace.manifest as _)); } } @@ -366,7 +366,9 @@ impl<'a> Test<'a> { if actual != expected { return Err(werk_runner::EvalError::AssertCustomFailed( DiagnosticFileId(0).span(*span), - format!("contents of output file `{filename}` do not match\nexpected: {expected:?}\n actual: {actual:?}"), + format!( + "contents of output file `{filename}` do not match\nexpected: {expected:?}\n actual: {actual:?}" + ), )); } } @@ -759,7 +761,7 @@ pub fn insert_fs( hash_map::Entry::Occupied(occupied_entry) => { if rest.as_os_str().is_empty() { match occupied_entry.into_mut() { - MockDirEntry::File(ref mut m, ref mut v) => { + MockDirEntry::File(m, v) => { *m = metadata; *v = vec; Ok(()) @@ -929,7 +931,7 @@ pub fn read_fs<'a>( std::io::ErrorKind::NotFound, "file not found", ))?; - if let MockDirEntry::File(ref metadata, ref data) = entry { + if let MockDirEntry::File(metadata, data) = entry { Ok(( DirEntry { path: path.to_path_buf(), diff --git a/tests/test_eval.rs b/tests/test_eval.rs index 2dbb4576..6a022ad6 100644 --- a/tests/test_eval.rs +++ b/tests/test_eval.rs @@ -1,6 +1,6 @@ use tests::mock_io::*; -use werk_parser::parser::{parse, Input}; -use werk_runner::{eval, Error, EvalError, ShellCommandLine}; +use werk_parser::parser::{Input, parse}; +use werk_runner::{Error, EvalError, ShellCommandLine, eval}; use werk_util::DiagnosticFileId; use winnow::Parser as _; diff --git a/tests/test_pattern_match.rs b/tests/test_pattern_match.rs index 1e472d6f..0b8582ad 100644 --- a/tests/test_pattern_match.rs +++ b/tests/test_pattern_match.rs @@ -1,5 +1,5 @@ use tests::mock_io::*; -use werk_parser::parser::{pattern_expr_inside_quotes, Input}; +use werk_parser::parser::{Input, pattern_expr_inside_quotes}; use werk_runner::{Pattern, PatternMatchData, Workspace}; use werk_util::DiagnosticFileId; From f0c8239a3721611778ae044235be32abb3f0eb3a Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:13:46 +0100 Subject: [PATCH 07/10] Migrate book --- book/book.toml | 2 +- book/src/examples/cargo/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/book/book.toml b/book/book.toml index 68daa421..a0ef9891 100644 --- a/book/book.toml +++ b/book/book.toml @@ -9,7 +9,7 @@ title = "Werk Book" create-missing = false [rust] -edition = "2021" +edition = "2024" [output.html] site-url = "/werk/" diff --git a/book/src/examples/cargo/Cargo.toml b/book/src/examples/cargo/Cargo.toml index f491c171..876a4c9b 100644 --- a/book/src/examples/cargo/Cargo.toml +++ b/book/src/examples/cargo/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "test-project" version = "0.1.0" -edition = "2021" +edition = "2024" [workspace] -members = [] \ No newline at end of file +members = [] From 5b3708887d3115a8f0cc2db326eee7df2b2c8020 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:15:34 +0100 Subject: [PATCH 08/10] Restore crates to use `edition.workspace` --- Cargo.toml | 2 +- tests/Cargo.toml | 2 +- werk-cli/Cargo.toml | 2 +- werk-fs/Cargo.toml | 2 +- werk-parser/Cargo.toml | 2 +- werk-runner/Cargo.toml | 2 +- werk-util/Cargo.toml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d85905ec..dc6d623b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" [workspace.package] version = "0.1.0" rust-version = "1.85" -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index e85760b6..a8a8c619 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -2,7 +2,7 @@ name = "tests" publish = false version.workspace = true -edition = "2024" +edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/werk-cli/Cargo.toml b/werk-cli/Cargo.toml index 8369d93d..096cb944 100644 --- a/werk-cli/Cargo.toml +++ b/werk-cli/Cargo.toml @@ -3,7 +3,7 @@ name = "werk-cli" build = "build.rs" version.workspace = true rust-version.workspace = true -edition = "2024" +edition.workspace = true license.workspace = true [[bin]] diff --git a/werk-fs/Cargo.toml b/werk-fs/Cargo.toml index ed534889..590d16b0 100644 --- a/werk-fs/Cargo.toml +++ b/werk-fs/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-fs" version.workspace = true rust-version.workspace = true -edition = "2024" +edition.workspace = true license.workspace = true [lib] diff --git a/werk-parser/Cargo.toml b/werk-parser/Cargo.toml index e5fd9c4f..5bc9eb95 100644 --- a/werk-parser/Cargo.toml +++ b/werk-parser/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-parser" version.workspace = true rust-version.workspace = true -edition = "2024" +edition.workspace = true license.workspace = true [lib] diff --git a/werk-runner/Cargo.toml b/werk-runner/Cargo.toml index 065d5e34..60dc7b0a 100644 --- a/werk-runner/Cargo.toml +++ b/werk-runner/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-runner" version.workspace = true rust-version.workspace = true -edition = "2024" +edition.workspace = true license.workspace = true [lib] diff --git a/werk-util/Cargo.toml b/werk-util/Cargo.toml index 912f9506..2b3d10ef 100644 --- a/werk-util/Cargo.toml +++ b/werk-util/Cargo.toml @@ -2,7 +2,7 @@ name = "werk-util" version.workspace = true rust-version.workspace = true -edition = "2024" +edition.workspace = true license.workspace = true [lib] From 6b5915e88407b0e7d2ca27b0e1c5d1b3a40ac983 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:21:49 +0100 Subject: [PATCH 09/10] Use dtolnay/rust-toolchain on CI --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 918faecf..3042e4e9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,6 +20,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - name: Build run: cargo build - name: Run tests From 4a2369cdcbbae5ff7b43550b8f28eac8ef4b9e35 Mon Sep 17 00:00:00 2001 From: Simon Ask Ulsnes Date: Tue, 25 Feb 2025 10:23:16 +0100 Subject: [PATCH 10/10] CI: Also use dtolnay/rust-toolchain for lint/fmt --- .github/workflows/rust.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3042e4e9..5fb05d17 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,6 +30,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - name: cargo clippy run: cargo clippy --all-features -- -D warnings fmt: @@ -37,5 +38,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - name: cargo fmt --check run: cargo fmt -- --check --color=always