Skip to content

Commit

Permalink
Upgrade to 2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Apr 11, 2019
1 parent f64f07a commit 1523d24
Show file tree
Hide file tree
Showing 33 changed files with 157 additions and 130 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors = ["Casey Rodarmor <casey@rodarmor.com>"]
license = "CC0-1.0"
homepage = "https://github.com/casey/just"
readme = "crates-io-readme.md"
edition = "2018"

[dependencies]
ansi_term = "0.11"
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cognitive-complexity-threshold = 1337
cyclomatic-complexity-threshold = 1337

doc-valid-idents = ["FreeBSD"]
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ install-dev-deps:

# everyone's favorite animate paper clip
clippy:
cargo +nightly clippy
cargo clippy

# count non-empty lines of code
sloc:
Expand Down
4 changes: 2 additions & 2 deletions src/alias.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

pub struct Alias<'a> {
pub name: &'a str,
Expand All @@ -7,7 +7,7 @@ pub struct Alias<'a> {
}

impl<'a> Display for Alias<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "alias {} = {}", self.name, self.target)
}
}
2 changes: 1 addition & 1 deletion src/alias_resolver.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;
use CompilationErrorKind::*;

pub struct AliasResolver<'a, 'b>
Expand Down
5 changes: 2 additions & 3 deletions src/assignment_evaluator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

use brev;

Expand Down Expand Up @@ -164,9 +164,8 @@ impl<'a, 'b> AssignmentEvaluator<'a, 'b> {
#[cfg(test)]
mod test {
use super::*;
use crate::testing::parse_success;
use brev::OutputError;
use testing::parse_success;
use Configuration;

fn no_cwd_err() -> Result<PathBuf, String> {
Err(String::from("no cwd in tests"))
Expand Down
4 changes: 2 additions & 2 deletions src/assignment_resolver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use common::*;
use crate::common::*;

use CompilationErrorKind::*;
use crate::CompilationErrorKind::*;

pub struct AssignmentResolver<'a: 'b, 'b> {
assignments: &'b Map<&'a str, Expression<'a>>,
Expand Down
4 changes: 2 additions & 2 deletions src/color.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate ansi_term;
extern crate atty;

use common::*;
use crate::common::*;

use self::ansi_term::Color::*;
use self::ansi_term::{ANSIGenericString, Prefix, Style, Suffix};
Expand Down Expand Up @@ -52,7 +52,7 @@ impl Color {
}
}

pub fn fmt(fmt: &fmt::Formatter) -> Color {
pub fn fmt(fmt: &Formatter) -> Color {
if fmt.alternate() {
Color::always()
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/command_ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

pub trait CommandExt {
fn export_environment_variables<'a>(
Expand Down
90 changes: 52 additions & 38 deletions src/common.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
pub use std::borrow::Cow;
pub use std::collections::{BTreeMap as Map, BTreeSet as Set};
pub use std::fmt::Display;
pub use std::io::prelude::*;
pub use std::ops::{Range, RangeInclusive};
pub use std::path::{Path, PathBuf};
pub use std::process::Command;
pub use std::sync::{Mutex, MutexGuard};
pub use std::{cmp, env, fmt, fs, io, iter, process, usize, vec};
pub(crate) use std::{
borrow::Cow,
cmp,
collections::{BTreeMap as Map, BTreeSet as Set},
env,
fmt::{self, Display, Formatter},
fs, io, iter,
ops::{Range, RangeInclusive},
path::{Path, PathBuf},
process,
process::Command,
sync::{Mutex, MutexGuard},
usize, vec,
};

pub use color::Color;
pub use libc::{EXIT_FAILURE, EXIT_SUCCESS};
pub use regex::Regex;
pub use tempdir::TempDir;
pub(crate) use libc::{EXIT_FAILURE, EXIT_SUCCESS};
pub(crate) use regex::Regex;
pub(crate) use tempdir::TempDir;

pub use alias::Alias;
pub use alias_resolver::AliasResolver;
pub use assignment_evaluator::AssignmentEvaluator;
pub use assignment_resolver::AssignmentResolver;
pub use command_ext::CommandExt;
pub use compilation_error::{CompilationError, CompilationErrorKind, CompilationResult};
pub use configuration::Configuration;
pub use cooked_string::CookedString;
pub use expression::Expression;
pub use fragment::Fragment;
pub use function::{evaluate_function, resolve_function, FunctionContext};
pub use interrupt_handler::InterruptHandler;
pub use justfile::Justfile;
pub use lexer::Lexer;
pub use load_dotenv::load_dotenv;
pub use misc::{default, empty};
pub use parameter::Parameter;
pub use parser::Parser;
pub use range_ext::RangeExt;
pub use recipe::{Recipe, RecipeContext};
pub use recipe_resolver::RecipeResolver;
pub use runtime_error::{RunResult, RuntimeError};
pub use shebang::Shebang;
pub use token::{Token, TokenKind};
pub use verbosity::Verbosity;
pub(crate) use crate::{
alias::Alias,
alias_resolver::AliasResolver,
assignment_evaluator::AssignmentEvaluator,
assignment_resolver::AssignmentResolver,
color::Color,
compilation_error::{CompilationError, CompilationErrorKind, CompilationResult},
configuration::Configuration,
cooked_string::CookedString,
expression::Expression,
fragment::Fragment,
function::{evaluate_function, resolve_function, FunctionContext},
interrupt_handler::InterruptHandler,
justfile::Justfile,
lexer::Lexer,
load_dotenv::load_dotenv,
misc::{default, empty},
parameter::Parameter,
parser::Parser,
recipe::{Recipe, RecipeContext},
recipe_resolver::RecipeResolver,
runtime_error::{RunResult, RuntimeError},
shebang::Shebang,
token::{Token, TokenKind},
verbosity::Verbosity,
};

#[allow(unused_imports)]
pub(crate) use std::io::prelude::*;

#[allow(unused_imports)]
pub(crate) use crate::command_ext::CommandExt;

#[allow(unused_imports)]
pub(crate) use crate::range_ext::RangeExt;
8 changes: 4 additions & 4 deletions src/compilation_error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use common::*;
use crate::common::*;

use misc::{maybe_s, show_whitespace, write_error_context, Or};
use crate::misc::{maybe_s, show_whitespace, write_error_context, Or};

pub type CompilationResult<'a, T> = Result<T, CompilationError<'a>>;

Expand Down Expand Up @@ -103,8 +103,8 @@ pub enum CompilationErrorKind<'a> {
}

impl<'a> Display for CompilationError<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use CompilationErrorKind::*;
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
use crate::CompilationErrorKind::*;
let error = Color::fmt(f).error();
let message = Color::fmt(f).message();

Expand Down
2 changes: 1 addition & 1 deletion src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

pub const DEFAULT_SHELL: &str = "sh";

Expand Down
2 changes: 1 addition & 1 deletion src/cooked_string.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

#[derive(PartialEq, Debug)]
pub struct CookedString<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/expression.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

#[derive(PartialEq, Debug)]
pub enum Expression<'a> {
Expand Down Expand Up @@ -35,7 +35,7 @@ impl<'a> Expression<'a> {
}

impl<'a> Display for Expression<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match *self {
Expression::Backtick { raw, .. } => write!(f, "`{}`", raw)?,
Expression::Concatination { ref lhs, ref rhs } => write!(f, "{} + {}", lhs, rhs)?,
Expand Down
2 changes: 1 addition & 1 deletion src/fragment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

#[derive(PartialEq, Debug)]
pub enum Fragment<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/function.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use common::*;
use crate::common::*;

use target;

use platform::{Platform, PlatformInterface};
use crate::platform::{Platform, PlatformInterface};

lazy_static! {
static ref FUNCTIONS: Map<&'static str, Function> = vec![
Expand Down
2 changes: 1 addition & 1 deletion src/interrupt_handler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

use ctrlc;

Expand Down
10 changes: 5 additions & 5 deletions src/justfile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

use edit_distance::edit_distance;

Expand Down Expand Up @@ -170,7 +170,7 @@ impl<'a> Justfile<'a> where {
}

impl<'a> Display for Justfile<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
let mut items = self.recipes.len() + self.assignments.len() + self.aliases.len();
for (name, expression) in &self.assignments {
if self.exports.contains(name) {
Expand All @@ -183,7 +183,7 @@ impl<'a> Display for Justfile<'a> {
}
}
for alias in self.aliases.values() {
write!(f, "{}",alias)?;
write!(f, "{}", alias)?;
items -= 1;
if items != 0 {
write!(f, "\n\n")?;
Expand All @@ -203,8 +203,8 @@ impl<'a> Display for Justfile<'a> {
#[cfg(test)]
mod test {
use super::*;
use testing::parse_success;
use RuntimeError::*;
use crate::testing::parse_success;
use crate::RuntimeError::*;

fn no_cwd_err() -> Result<PathBuf, String> {
Err(String::from("no cwd in tests"))
Expand Down
10 changes: 5 additions & 5 deletions src/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common::*;
use crate::common::*;

use CompilationErrorKind::*;
use TokenKind::*;
use crate::CompilationErrorKind::*;
use crate::TokenKind::*;

fn re(pattern: &str) -> Regex {
Regex::new(pattern).unwrap()
Expand Down Expand Up @@ -383,7 +383,7 @@ mod test {
fn $name() {
let input = $input;
let expected = $expected;
let tokens = ::Lexer::lex(input).unwrap();
let tokens = crate::Lexer::lex(input).unwrap();
let roundtrip = tokens
.iter()
.map(|t| {
Expand Down Expand Up @@ -688,7 +688,7 @@ c: b
error_test! {
name: unterminated_interpolation,
input: "foo:\n echo {{
",
",
index: 13,
line: 1,
column: 8,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ mod shebang;
mod token;
mod verbosity;

use common::*;
use crate::common::*;

pub use run::run;
pub use crate::run::run;
2 changes: 1 addition & 1 deletion src/load_dotenv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

use dotenv;

Expand Down
12 changes: 6 additions & 6 deletions src/misc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common::*;
use crate::common::*;

use unicode_width::UnicodeWidthChar;

Expand Down Expand Up @@ -34,7 +34,7 @@ pub fn maybe_s(n: usize) -> &'static str {
}

pub fn conjoin<T: Display>(
f: &mut fmt::Formatter,
f: &mut Formatter,
values: &[T],
conjunction: &str,
) -> Result<(), fmt::Error> {
Expand All @@ -58,7 +58,7 @@ pub fn conjoin<T: Display>(
}

pub fn write_error_context(
f: &mut fmt::Formatter,
f: &mut Formatter,
text: &str,
index: usize,
line: usize,
Expand Down Expand Up @@ -135,23 +135,23 @@ pub fn write_error_context(
pub struct And<'a, T: 'a + Display>(pub &'a [T]);

impl<'a, T: Display> Display for And<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
conjoin(f, self.0, "and")
}
}

pub struct Or<'a, T: 'a + Display>(pub &'a [T]);

impl<'a, T: Display> Display for Or<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
conjoin(f, self.0, "or")
}
}

pub struct Tick<'a, T: 'a + Display>(pub &'a T);

impl<'a, T: Display> Display for Tick<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
write!(f, "`{}`", self.0)
}
}
Expand Down
Loading

0 comments on commit 1523d24

Please sign in to comment.