Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build
- name: Run tests
Expand All @@ -29,12 +30,14 @@ 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:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: cargo fmt --check
run: cargo fmt -- --check --color=always
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ resolver = "2"

[workspace.package]
version = "0.1.0"
rust-version = "1.83"
edition = "2021"
rust-version = "1.85"
edition = "2024"
license = "MIT OR Apache-2.0"

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title = "Werk Book"
create-missing = false

[rust]
edition = "2021"
edition = "2024"

[output.html]
site-url = "/werk/"
Expand Down
4 changes: 2 additions & 2 deletions book/src/examples/cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "test-project"
version = "0.1.0"
edition = "2021"
edition = "2024"

[workspace]
members = []
members = []
20 changes: 11 additions & 9 deletions tests/mock_io.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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 _));
}
}

Expand Down Expand Up @@ -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:?}"
),
));
}
}
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_eval.rs
Original file line number Diff line number Diff line change
@@ -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 _;

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pattern_match.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 2 additions & 2 deletions werk-cli/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Default>(f: impl FnOnce(Workspace) -> Result<T, anyhow::Error> + 'static) -> T {
Expand Down
4 changes: 3 additions & 1 deletion werk-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions werk-cli/render/ansi/term_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion werk-cli/render/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl werk_runner::Render for LogWatcher {
result: &Result<werk_runner::BuildStatus, werk_runner::Error>,
) {
match result {
Ok(ref status) => {
Ok(status) => {
if let werk_runner::BuildStatus::Complete(task_id, _) = status {
tracing::info!(task_id = %task_id, "Success");
}
Expand Down
2 changes: 1 addition & 1 deletion werk-fs/absolute.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion werk-fs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{
};

use crate::{
traits::{self, Normalize},
Absolute,
traits::{self, Normalize},
};

pub trait AsPath {
Expand Down
2 changes: 1 addition & 1 deletion werk-parser/ast.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion werk-parser/ast/expr.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
4 changes: 2 additions & 2 deletions werk-parser/ast/keyword.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions werk-parser/ast/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -33,7 +33,7 @@ impl<const CHAR: char> Spanned for Token<CHAR> {
fn span(&self) -> Span {
Span {
start: self.0,
end: Offset(self.0 .0 + 1),
end: Offset(self.0.0 + 1),
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions werk-parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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 _;
Expand Down
16 changes: 8 additions & 8 deletions werk-parser/parser/string.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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,
terminated,
},
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<Self> {
Expand Down Expand Up @@ -259,15 +259,15 @@ 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
.push(ast::StringFragment::Literal(lit.to_owned()));
}
}
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
Expand All @@ -287,15 +287,15 @@ 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
.push(ast::PatternFragment::Literal(lit.to_owned()));
}
}
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
Expand Down Expand Up @@ -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::*;

Expand Down
2 changes: 1 addition & 1 deletion werk-runner/depfile.rs
Original file line number Diff line number Diff line change
@@ -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<T> = winnow::ModalResult<T>;
Expand Down
Loading