Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate lazy_static #1442

Merged
merged 12 commits into from
Dec 16, 2022
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
toolchain: 1.56.0
toolchain: stable

- uses: Swatinem/rust-cache@v1

Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.56.0
toolchain: stable

- uses: Swatinem/rust-cache@v1

Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
with:
components: clippy, rustfmt
override: true
toolchain: 1.56.0
toolchain: stable

- uses: Swatinem/rust-cache@v1

Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dotenvy = "0.15"
edit-distance = "2.0.0"
env_logger = "0.9.3"
heck = "0.4.0"
lazy_static = "1.0.0"
lexiclean = "0.0.1"
libc = "0.2.0"
log = "0.4.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2421,7 +2421,7 @@ Before merging a particularly large or gruesome change, Janus should be run to m

### Minimum Supported Rust Version

The minimum supported Rust version, or MSRV, is Rust 1.56.0.
The minimum supported Rust version, or MSRV, is current stable Rust. It may build on older versions of Rust, but this is not guaranteed.

### New Releases

Expand Down
2 changes: 1 addition & 1 deletion bin/generate-book/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn main() -> Result {

for chapter in chapters {
let path = format!("{}/chapter_{}.md", src, chapter.number());
fs::write(&path, &chapter.markdown()?)?;
fs::write(path, chapter.markdown()?)?;
let indent = match chapter.level {
HeadingLevel::H1 => 0,
HeadingLevel::H2 => 1,
Expand Down
2 changes: 1 addition & 1 deletion src/assignment_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
self.resolve_expression(&assignment.value)?;
self.evaluated.insert(name);
} else {
let message = format!("attempted to resolve unknown assignment `{}`", name);
let message = format!("attempted to resolve unknown assignment `{name}`");
let token = Token {
src: "",
offset: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'src> Display for Ast<'src> {
let mut iter = self.items.iter().peekable();

while let Some(item) = iter.next() {
writeln!(f, "{}", item)?;
writeln!(f, "{item}")?;

if let Some(next_item) = iter.peek() {
if matches!(item, Item::Recipe(_))
Expand Down
41 changes: 18 additions & 23 deletions src/compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Display for CompileError<'_> {
}
CircularRecipeDependency { recipe, ref circle } => {
if circle.len() == 2 {
write!(f, "Recipe `{}` depends on itself", recipe)?;
write!(f, "Recipe `{recipe}` depends on itself")?;
} else {
write!(
f,
Expand All @@ -54,7 +54,7 @@ impl Display for CompileError<'_> {
ref circle,
} => {
if circle.len() == 2 {
write!(f, "Variable `{}` is defined in terms of itself", variable)?;
write!(f, "Variable `{variable}` is defined in terms of itself")?;
} else {
write!(
f,
Expand All @@ -80,11 +80,11 @@ impl Display for CompileError<'_> {

if min == max {
let expected = min;
write!(f, "{} {}", expected, Count("argument", *expected))?;
write!(f, "{expected} {}", Count("argument", *expected))?;
} else if found < min {
write!(f, "at least {} {}", min, Count("argument", *min))?;
write!(f, "at least {min} {}", Count("argument", *min))?;
} else {
write!(f, "at most {} {}", max, Count("argument", *max))?;
write!(f, "at most {max} {}", Count("argument", *max))?;
}
}
DuplicateAlias { alias, first } => {
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Display for CompileError<'_> {
)?;
}
DuplicateVariable { variable } => {
write!(f, "Variable `{}` has multiple definitions", variable)?;
write!(f, "Variable `{variable}` has multiple definitions")?;
}
ExpectedKeyword { expected, found } => {
if found.kind == TokenKind::Identifier {
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Display for CompileError<'_> {
'"' => r#"""#.to_owned(),
_ => character.escape_default().collect(),
};
write!(f, "`\\{}` is not a valid escape sequence", representation)?;
write!(f, "`\\{representation}` is not a valid escape sequence")?;
}
MismatchedClosingDelimiter {
open,
Expand All @@ -216,13 +216,12 @@ impl Display for CompileError<'_> {
)?;
}
ParameterFollowsVariadicParameter { parameter } => {
write!(f, "Parameter `{}` follows variadic parameter", parameter)?;
write!(f, "Parameter `{parameter}` follows variadic parameter")?;
}
ParameterShadowsVariable { parameter } => {
write!(
f,
"Parameter `{}` shadows variable of the same name",
parameter
"Parameter `{parameter}` shadows variable of the same name",
)?;
}
ParsingRecursionDepthExceeded => {
Expand All @@ -236,41 +235,37 @@ impl Display for CompileError<'_> {
)?;
}
UndefinedVariable { variable } => {
write!(f, "Variable `{}` not defined", variable)?;
write!(f, "Variable `{variable}` not defined")?;
}
UnexpectedCharacter { expected } => {
write!(f, "Expected character `{}`", expected)?;
write!(f, "Expected character `{expected}`")?;
}
UnexpectedClosingDelimiter { close } => {
write!(f, "Unexpected closing delimiter `{}`", close.close())?;
}
UnexpectedEndOfToken { expected } => {
write!(f, "Expected character `{}` but found end-of-file", expected)?;
write!(f, "Expected character `{expected}` but found end-of-file")?;
}
UnexpectedToken {
ref expected,
found,
} => {
write!(f, "Expected {}, but found {}", List::or(expected), found)?;
write!(f, "Expected {}, but found {found}", List::or(expected))?;
}
UnknownAliasTarget { alias, target } => {
write!(f, "Alias `{}` has an unknown target `{}`", alias, target)?;
write!(f, "Alias `{alias}` has an unknown target `{target}`")?;
}
UnknownAttribute { attribute } => {
write!(f, "Unknown attribute `{}`", attribute)?;
write!(f, "Unknown attribute `{attribute}`")?;
}
UnknownDependency { recipe, unknown } => {
write!(
f,
"Recipe `{}` has unknown dependency `{}`",
recipe, unknown
)?;
write!(f, "Recipe `{recipe}` has unknown dependency `{unknown}`",)?;
}
UnknownFunction { function } => {
write!(f, "Call to unknown function `{}`", function)?;
write!(f, "Call to unknown function `{function}`")?;
}
UnknownSetting { setting } => {
write!(f, "Unknown setting `{}`", setting)?;
write!(f, "Unknown setting `{setting}`")?;
}
UnknownStartOfToken => {
write!(f, "Unknown start of token:")?;
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl Config {
arg::COLOR_ALWAYS => Ok(Color::always()),
arg::COLOR_NEVER => Ok(Color::never()),
_ => Err(ConfigError::Internal {
message: format!("Invalid argument `{}` to --color.", value),
message: format!("Invalid argument `{value}` to --color."),
}),
}
}
Expand All @@ -404,7 +404,7 @@ impl Config {
arg::DUMP_FORMAT_JSON => Ok(DumpFormat::Json),
arg::DUMP_FORMAT_JUST => Ok(DumpFormat::Just),
_ => Err(ConfigError::Internal {
message: format!("Invalid argument `{}` to --dump-format.", value),
message: format!("Invalid argument `{value}` to --dump-format."),
}),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/config_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) enum ConfigError {
#[snafu(display(
"`--{}` used with unexpected overrides: {}",
subcommand.to_lowercase(),
List::and_ticked(overrides.iter().map(|(key, value)| format!("{}={}", key, value))),
List::and_ticked(overrides.iter().map(|(key, value)| format!("{key}={value}"))),
))]
SubcommandOverrides {
subcommand: &'static str,
Expand All @@ -37,7 +37,7 @@ pub(crate) enum ConfigError {
#[snafu(display(
"`--{}` used with unexpected overrides: {}; and arguments: {}",
subcommand.to_lowercase(),
List::and_ticked(overrides.iter().map(|(key, value)| format!("{}={}", key, value))),
List::and_ticked(overrides.iter().map(|(key, value)| format!("{key}={value}"))),
List::and_ticked(arguments)))
]
SubcommandOverridesAndArguments {
Expand Down
2 changes: 1 addition & 1 deletion src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'src> Display for Dependency<'src> {
write!(f, "({}", self.recipe.name())?;

for argument in &self.arguments {
write!(f, " {}", argument)?;
write!(f, " {argument}")?;
}

write!(f, ")")
Expand Down
51 changes: 20 additions & 31 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ impl<'src> ColorDisplay for Error<'src> {
}
Backtick { output_error, .. } => match output_error {
OutputError::Code(code) => {
write!(f, "Backtick failed with exit code {}", code)?;
write!(f, "Backtick failed with exit code {code}")?;
}
OutputError::Signal(signal) => {
write!(f, "Backtick was terminated by signal {}", signal)?;
write!(f, "Backtick was terminated by signal {signal}")?;
}
OutputError::Unknown => {
write!(f, "Backtick failed for an unknown reason")?;
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<'src> ColorDisplay for Error<'src> {
recipe, n, code
)?;
} else {
write!(f, "Recipe `{}` failed with exit code {}", recipe, code)?;
write!(f, "Recipe `{recipe}` failed with exit code {code}")?;
}
}
CommandInvoke {
Expand Down Expand Up @@ -422,7 +422,7 @@ impl<'src> ColorDisplay for Error<'src> {
path:\n{}",
recipe, io_error
),
_ => write!(f, "Could not run `cygpath` executable:\n{}", io_error),
_ => write!(f, "Could not run `cygpath` executable:\n{io_error}"),
}?;
}
OutputError::Utf8(utf8_error) => {
Expand All @@ -447,34 +447,28 @@ impl<'src> ColorDisplay for Error<'src> {
)?;
}
Dotenv { dotenv_error } => {
write!(f, "Failed to load environment file: {}", dotenv_error)?;
write!(f, "Failed to load environment file: {dotenv_error}")?;
}
DumpJson { serde_json_error } => {
write!(f, "Failed to dump JSON to stdout: {}", serde_json_error)?;
write!(f, "Failed to dump JSON to stdout: {serde_json_error}")?;
}
EditorInvoke { editor, io_error } => {
write!(
f,
"Editor `{}` invocation failed: {}",
"Editor `{}` invocation failed: {io_error}",
editor.to_string_lossy(),
io_error
)?;
}
EditorStatus { editor, status } => {
write!(
f,
"Editor `{}` failed: {}",
editor.to_string_lossy(),
status
)?;
write!(f, "Editor `{}` failed: {status}", editor.to_string_lossy(),)?;
}
EvalUnknownVariable {
variable,
suggestion,
} => {
write!(f, "Justfile does not contain variable `{}`.", variable,)?;
write!(f, "Justfile does not contain variable `{variable}`.")?;
if let Some(suggestion) = *suggestion {
write!(f, "\n{}", suggestion)?;
write!(f, "\n{suggestion}")?;
}
}
FormatCheckFoundDiff => {
Expand Down Expand Up @@ -533,7 +527,7 @@ impl<'src> ColorDisplay for Error<'src> {
write!(f, "Justfile contains no recipes.")?;
}
RegexCompile { source } => {
write!(f, "{}", source)?;
write!(f, "{source}")?;
}
Search { search_error } => Display::fmt(search_error, f)?,
Shebang {
Expand All @@ -545,14 +539,12 @@ impl<'src> ColorDisplay for Error<'src> {
if let Some(argument) = argument {
write!(
f,
"Recipe `{}` with shebang `#!{} {}` execution error: {}",
recipe, command, argument, io_error
"Recipe `{recipe}` with shebang `#!{command} {argument}` execution error: {io_error}",
)?;
} else {
write!(
f,
"Recipe `{}` with shebang `#!{}` execution error: {}",
recipe, command, io_error
"Recipe `{recipe}` with shebang `#!{command}` execution error: {io_error}",
)?;
}
}
Expand All @@ -564,18 +556,16 @@ impl<'src> ColorDisplay for Error<'src> {
if let Some(n) = line_number {
write!(
f,
"Recipe `{}` was terminated on line {} by signal {}",
recipe, n, signal
"Recipe `{recipe}` was terminated on line {n} by signal {signal}",
)?;
} else {
write!(f, "Recipe `{}` was terminated by signal {}", recipe, signal)?;
write!(f, "Recipe `{recipe}` was terminated by signal {signal}")?;
}
}
TmpdirIo { recipe, io_error } => write!(
f,
"Recipe `{}` could not be run because of an IO error while trying to create a temporary \
directory or write a file to that directory`:{}",
recipe, io_error
"Recipe `{recipe}` could not be run because of an IO error while trying to create a temporary \
directory or write a file to that directory`:{io_error}",
)?,
Unknown {
recipe,
Expand All @@ -584,11 +574,10 @@ impl<'src> ColorDisplay for Error<'src> {
if let Some(n) = line_number {
write!(
f,
"Recipe `{}` failed on line {} for an unknown reason",
recipe, n
"Recipe `{recipe}` failed on line {n} for an unknown reason",
)?;
} else {
write!(f, "Recipe `{}` failed for an unknown reason", recipe)?;
write!(f, "Recipe `{recipe}` failed for an unknown reason")?;
}
}
UnknownOverrides { overrides } => {
Expand All @@ -610,7 +599,7 @@ impl<'src> ColorDisplay for Error<'src> {
List::or_ticked(recipes),
)?;
if let Some(suggestion) = *suggestion {
write!(f, "\n{}", suggestion)?;
write!(f, "\n{suggestion}")?;
}
}
Unstable { message } => {
Expand Down
Loading