Skip to content

Commit

Permalink
Misc fixes (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik authored Oct 17, 2023
1 parent 55da31a commit be7f161
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:

ci: build-book
cargo test --all
cargo clippy --all --all-targets
cargo clippy --all --all-targets -- --deny warnings
cargo fmt --all -- --check
./bin/forbid
cargo update --locked --package just
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ impl Config {
};

let unstable = matches.is_present(arg::UNSTABLE)
|| std::env::var_os("JUST_UNSTABLE")
|| env::var_os("JUST_UNSTABLE")
.map(|val| !(val == "false" || val == "0" || val.is_empty()))
.unwrap_or_default();

Expand Down Expand Up @@ -662,7 +662,7 @@ impl Config {

pub(crate) fn run(self, loader: &Loader) -> Result<(), Error> {
if let Err(error) = InterruptHandler::install(self.verbosity) {
warn!("Failed to set CTRL-C handler: {}", error);
warn!("Failed to set CTRL-C handler: {error}");
}

self.subcommand.execute(&self, loader)
Expand Down Expand Up @@ -761,7 +761,7 @@ mod tests {

match Config::from_matches(&matches).expect_err("config parsing succeeded") {
$error => { $($check)? }
other => panic!("Unexpected config error: {}", other),
other => panic!("Unexpected config error: {other}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ impl<'src, 'run> Evaluator<'src, 'run> {

cmd.export(self.settings, self.dotenv, &self.scope);

cmd.stdin(process::Stdio::inherit());
cmd.stdin(Stdio::inherit());

cmd.stderr(if self.config.verbosity.quiet() {
process::Stdio::null()
Stdio::null()
} else {
process::Stdio::inherit()
Stdio::inherit()
});

InterruptHandler::guard(|| {
Expand Down
4 changes: 2 additions & 2 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ fn sha256_file(context: &FunctionContext, path: &str) -> Result<String, String>
let justpath = context.search.working_directory.join(path);
let mut hasher = Sha256::new();
let mut file = fs::File::open(&justpath)
.map_err(|err| format!("Failed to open file at `{:?}`: {err}", &justpath.to_str()))?;
.map_err(|err| format!("Failed to open file at `{:?}`: {err}", justpath.to_str()))?;
std::io::copy(&mut file, &mut hasher)
.map_err(|err| format!("Failed to read file at `{:?}`: {err}", &justpath.to_str()))?;
.map_err(|err| format!("Failed to read file at `{:?}`: {err}", justpath.to_str()))?;
let hash = hasher.finalize();
Ok(format!("{hash:x}"))
}
Expand Down
4 changes: 2 additions & 2 deletions src/interrupt_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl InterruptHandler {
}
.color_display(Color::auto().stderr())
);
std::process::exit(EXIT_FAILURE);
process::exit(EXIT_FAILURE);
}
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ impl InterruptHandler {
.color_display(Color::auto().stderr())
);
}
std::process::exit(EXIT_FAILURE);
process::exit(EXIT_FAILURE);
}

self.blocks -= 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ impl<'src> Lexer<'src> {
}
self.token(Whitespace);
} else if let Some(character) = self.next {
return Err(self.error(CompileErrorKind::InvalidEscapeSequence { character }));
return Err(self.error(InvalidEscapeSequence { character }));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) use {
rc::Rc,
str::{self, Chars},
sync::{Mutex, MutexGuard},
usize, vec,
vec,
},
{
camino::Utf8Path,
Expand Down
2 changes: 1 addition & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn output(mut command: Command) -> Result<String, OutputError> {
None => OutputError::Unknown,
});
}
match std::str::from_utf8(&output.stdout) {
match str::from_utf8(&output.stdout) {
Err(error) => Err(OutputError::Utf8(error)),
Ok(utf8) => Ok(
if utf8.ends_with('\n') {
Expand Down
4 changes: 2 additions & 2 deletions src/output_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ pub(crate) enum OutputError {
/// Unknown failure
Unknown,
/// Stdout not UTF-8
Utf8(std::str::Utf8Error),
Utf8(str::Utf8Error),
}

impl Display for OutputError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match *self {
Self::Code(code) => write!(f, "Process exited with status code {code}"),
Self::Io(ref io_error) => write!(f, "Error executing process: {io_error}"),
Expand Down
2 changes: 1 addition & 1 deletion src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl PlatformInterface for Platform {
fs::set_permissions(path, permissions)
}

fn signal_from_exit_status(exit_status: process::ExitStatus) -> Option<i32> {
fn signal_from_exit_status(exit_status: ExitStatus) -> Option<i32> {
use std::os::unix::process::ExitStatusExt;
exit_status.signal()
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) trait PlatformInterface {

/// Extract the signal from a process exit status, if it was terminated by a
/// signal
fn signal_from_exit_status(exit_status: process::ExitStatus) -> Option<i32>;
fn signal_from_exit_status(exit_status: ExitStatus) -> Option<i32>;

/// Translate a path from a "native" path to a path the interpreter expects
fn convert_native_path(working_directory: &Path, path: &Path) -> Result<String, String>;
Expand Down
2 changes: 1 addition & 1 deletion src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'src, D> Recipe<'src, D> {

pub(crate) fn max_arguments(&self) -> usize {
if self.parameters.iter().any(|p| p.kind.is_variadic()) {
usize::max_value() - 1
usize::MAX - 1
} else {
self.parameters.len()
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Subcommand {
let starting_path = match &config.search_config {
SearchConfig::FromInvocationDirectory => config.invocation_directory.clone(),
SearchConfig::FromSearchDirectory { search_directory } => {
std::env::current_dir().unwrap().join(search_directory)
env::current_dir().unwrap().join(search_directory)
}
_ => unreachable!(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ macro_rules! run_error {
).expect_err("Expected runtime error") {
$error => $check
other => {
panic!("Unexpected run error: {:?}", other);
panic!("Unexpected run error: {other:?}");
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/thunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'src> Thunk<'src> {
name: Name<'src>,
mut arguments: Vec<Expression<'src>>,
) -> CompileResult<'src, Thunk<'src>> {
crate::function::get(name.lexeme()).map_or(
function::get(name.lexeme()).map_or(
Err(name.error(CompileErrorKind::UnknownFunction {
function: name.lexeme(),
})),
Expand Down
2 changes: 1 addition & 1 deletion src/verbosity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ impl Verbosity {
}

pub const fn default() -> Self {
Self::Taciturn
Taciturn
}
}
4 changes: 2 additions & 2 deletions tests/choose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn skip_recipes_that_require_arguments() {

#[test]
fn no_choosable_recipes() {
crate::test::Test::new()
Test::new()
.arg("--choose")
.justfile(
"
Expand Down Expand Up @@ -200,7 +200,7 @@ fn default() {
};

let cat = which("cat").unwrap();
let fzf = tmp.path().join(format!("fzf{}", env::consts::EXE_SUFFIX));
let fzf = tmp.path().join(format!("fzf{EXE_SUFFIX}"));

#[cfg(unix)]
std::os::unix::fs::symlink(cat, fzf).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn editor_precedence() {
assert_stdout(&output, JUSTFILE);

let cat = which("cat").unwrap();
let vim = tmp.path().join(format!("vim{}", EXE_SUFFIX));
let vim = tmp.path().join(format!("vim{EXE_SUFFIX}"));

#[cfg(unix)]
std::os::unix::fs::symlink(cat, vim).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn test_downwards_multiple_path_argument() {
}

#[test]
fn single_downards() {
fn single_downwards() {
let tmp = temptree! {
justfile: "default:\n\techo ok",
child: {},
Expand Down
2 changes: 1 addition & 1 deletion tests/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn flag() {
#[cfg(not(windows))]
{
let permissions = std::os::unix::fs::PermissionsExt::from_mode(0o700);
std::fs::set_permissions(&shell, permissions).unwrap();
fs::set_permissions(&shell, permissions).unwrap();
}

let output = Command::new(executable_path("just"))
Expand Down
2 changes: 1 addition & 1 deletion tests/tempdir.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

pub(crate) fn tempdir() -> tempfile::TempDir {
pub(crate) fn tempdir() -> TempDir {
tempfile::Builder::new()
.prefix("just-test-tempdir")
.tempdir()
Expand Down
5 changes: 1 addition & 4 deletions www/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ a:hover {
body {
display: grid;
grid-template-columns: repeat(4, 1fr);
margin-bottom: var(--margin-vertical);
margin-left: var(--margin-horizontal);
margin-right: var(--margin-horizontal);
margin-top: var(--margin-vertical);
margin: var(--margin-vertical) var(--margin-horizontal);
}

body > * {
Expand Down

0 comments on commit be7f161

Please sign in to comment.