Skip to content

Commit

Permalink
Use stable rustfmt instead of nightly (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Sep 16, 2021
1 parent ca2b596 commit 629c75f
Show file tree
Hide file tree
Showing 55 changed files with 537 additions and 523 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Install Rust Toolchain
run: |
rustup component add clippy
rustup component add clippy rustfmt
rustup target add ${{ matrix.target }}
rustup default "`cat rust-toolchain`-${{ matrix.target }}"
Expand Down Expand Up @@ -108,16 +108,8 @@ jobs:
- name: Clippy
run: cargo clippy --all --all-targets --all-features

- name: Install Rustfmt Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
profile: minimal
components: rustfmt

- name: Format
run: cargo +nightly fmt --all -- --check
run: cargo fmt --all -- --check

- name: Completion Scripts
if: ${{ matrix.os != 'windows-2016' }}
Expand Down
3 changes: 1 addition & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build:
cargo lbuild

fmt:
cargo +nightly fmt --all
cargo fmt --all

watch +COMMAND='ltest':
cargo watch --clear --exec "{{COMMAND}}"
Expand Down Expand Up @@ -94,7 +94,6 @@ install:
install-dev-deps:
rustup install nightly
rustup update nightly
rustup run nightly cargo install clippy
cargo +nightly install cargo-fuzz
cargo install cargo-check
cargo install cargo-limit
Expand Down
27 changes: 6 additions & 21 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
comment_width = 80
edition = "2018"
error_on_line_overflow = true
error_on_unformatted = true
format_code_in_doc_comments = true
format_macro_bodies = true
format_strings = true
imports_granularity = "Crate"
match_arm_blocks = false
match_block_trailing_comma = true
max_width = 100
newline_style = "Unix"
normalize_comments = true
overflow_delimited_expr = true
reorder_impl_items = true
struct_field_align_threshold = 20
tab_spaces = 2
unstable_features = true
use_field_init_shorthand = true
use_try_shorthand = true
wrap_comments = true
edition = "2018"
max_width = 100
newline_style = "Unix"
tab_spaces = 2
use_field_init_shorthand = true
use_try_shorthand = true
2 changes: 1 addition & 1 deletion src/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::common::*;
/// An alias, e.g. `name := target`
#[derive(Debug, PartialEq, Clone)]
pub(crate) struct Alias<'src, T = Rc<Recipe<'src>>> {
pub(crate) name: Name<'src>,
pub(crate) name: Name<'src>,
pub(crate) target: T,
}

Expand Down
32 changes: 16 additions & 16 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use CompileErrorKind::*;

#[derive(Default)]
pub(crate) struct Analyzer<'src> {
recipes: Table<'src, UnresolvedRecipe<'src>>,
recipes: Table<'src, UnresolvedRecipe<'src>>,
assignments: Table<'src, Assignment<'src>>,
aliases: Table<'src, Alias<'src, Name<'src>>>,
sets: Table<'src, Set<'src>>,
aliases: Table<'src, Alias<'src, Name<'src>>>,
sets: Table<'src, Set<'src>>,
}

impl<'src> Analyzer<'src> {
Expand All @@ -21,20 +21,20 @@ impl<'src> Analyzer<'src> {
Item::Alias(alias) => {
self.analyze_alias(&alias)?;
self.aliases.insert(alias);
},
}
Item::Assignment(assignment) => {
self.analyze_assignment(&assignment)?;
self.assignments.insert(assignment);
},
}
Item::Comment(_) => (),
Item::Recipe(recipe) => {
self.analyze_recipe(&recipe)?;
self.recipes.insert(recipe);
},
}
Item::Set(set) => {
self.analyze_set(&set)?;
self.sets.insert(set);
},
}
}
}

Expand Down Expand Up @@ -65,17 +65,17 @@ impl<'src> Analyzer<'src> {
match set.value {
Setting::DotenvLoad(dotenv_load) => {
settings.dotenv_load = Some(dotenv_load);
},
}
Setting::Export(export) => {
settings.export = export;
},
}
Setting::PositionalArguments(positional_arguments) => {
settings.positional_arguments = positional_arguments;
},
}
Setting::Shell(shell) => {
assert!(settings.shell.is_none());
settings.shell = Some(shell);
},
}
}
}

Expand All @@ -92,7 +92,7 @@ impl<'src> Analyzer<'src> {
if let Some(original) = self.recipes.get(recipe.name.lexeme()) {
return Err(recipe.name.token().error(DuplicateRecipe {
recipe: original.name(),
first: original.line_number(),
first: original.line_number(),
}));
}

Expand All @@ -102,7 +102,7 @@ impl<'src> Analyzer<'src> {
for parameter in &recipe.parameters {
if parameters.contains(parameter.name.lexeme()) {
return Err(parameter.name.token().error(DuplicateParameter {
recipe: recipe.name.lexeme(),
recipe: recipe.name.lexeme(),
parameter: parameter.name.lexeme(),
}));
}
Expand Down Expand Up @@ -166,7 +166,7 @@ impl<'src> Analyzer<'src> {
if let Some(original) = self.sets.get(set.name.lexeme()) {
return Err(set.name.error(DuplicateSet {
setting: original.name.lexeme(),
first: original.name.line,
first: original.name.line,
}));
}

Expand All @@ -181,7 +181,7 @@ impl<'src> Analyzer<'src> {
// Make sure the alias doesn't conflict with any recipe
if let Some(recipe) = recipes.get(alias.name.lexeme()) {
return Err(token.error(AliasShadowsRecipe {
alias: alias.name.lexeme(),
alias: alias.name.lexeme(),
recipe_line: recipe.line_number(),
}));
}
Expand All @@ -190,7 +190,7 @@ impl<'src> Analyzer<'src> {
match recipes.get(alias.target.lexeme()) {
Some(target) => Ok(alias.resolve(Rc::clone(target))),
None => Err(token.error(UnknownAliasTarget {
alias: alias.name.lexeme(),
alias: alias.name.lexeme(),
target: alias.target.lexeme(),
})),
}
Expand Down
20 changes: 10 additions & 10 deletions src/assignment_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use CompileErrorKind::*;

pub(crate) struct AssignmentResolver<'src: 'run, 'run> {
assignments: &'run Table<'src, Assignment<'src>>,
stack: Vec<&'src str>,
evaluated: BTreeSet<&'src str>,
stack: Vec<&'src str>,
evaluated: BTreeSet<&'src str>,
}

impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
Expand Down Expand Up @@ -38,12 +38,12 @@ impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
} else {
let message = format!("attempted to resolve unknown assignment `{}`", name);
let token = Token {
src: "",
src: "",
offset: 0,
line: 0,
line: 0,
column: 0,
length: 0,
kind: TokenKind::Unspecified,
kind: TokenKind::Unspecified,
};
return Err(CompileError {
kind: Internal { message },
Expand Down Expand Up @@ -74,26 +74,26 @@ impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
} else {
Err(name.token().error(UndefinedVariable { variable }))
}
},
}
Expression::Call { thunk } => match thunk {
Thunk::Nullary { .. } => Ok(()),
Thunk::Unary { arg, .. } => self.resolve_expression(arg),
Thunk::Binary { args: [a, b], .. } => {
self.resolve_expression(a)?;
self.resolve_expression(b)
},
}
Thunk::Ternary {
args: [a, b, c], ..
} => {
self.resolve_expression(a)?;
self.resolve_expression(b)?;
self.resolve_expression(c)
},
}
},
Expression::Concatination { lhs, rhs } => {
self.resolve_expression(lhs)?;
self.resolve_expression(rhs)
},
}
Expression::Conditional {
lhs,
rhs,
Expand All @@ -105,7 +105,7 @@ impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
self.resolve_expression(rhs)?;
self.resolve_expression(then)?;
self.resolve_expression(otherwise)
},
}
Expression::StringLiteral { .. } | Expression::Backtick { .. } => Ok(()),
Expression::Group { contents } => self.resolve_expression(contents),
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::common::*;
#[derive(Debug, Clone)]
pub(crate) struct Ast<'src> {
/// Items in the justfile
pub(crate) items: Vec<Item<'src>>,
pub(crate) items: Vec<Item<'src>>,
/// Non-fatal warnings encountered during parsing
pub(crate) warnings: Vec<Warning>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pub(crate) struct Binding<'src, V = String> {
/// Export binding as an environment variable to child processes
pub(crate) export: bool,
/// Binding name
pub(crate) name: Name<'src>,
pub(crate) name: Name<'src>,
/// Binding value
pub(crate) value: V,
pub(crate) value: V,
}

impl<'src, V> Keyed<'src> for Binding<'src, V> {
Expand Down
8 changes: 4 additions & 4 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use atty::Stream;
#[derive(Copy, Clone, Debug, PartialEq)]
pub(crate) struct Color {
use_color: UseColor,
atty: bool,
style: Style,
atty: bool,
style: Style,
}

impl Color {
Expand Down Expand Up @@ -120,8 +120,8 @@ impl Default for Color {
fn default() -> Self {
Self {
use_color: UseColor::Auto,
atty: false,
style: Style::new(),
atty: false,
style: Style::new(),
}
}
}
Loading

0 comments on commit 629c75f

Please sign in to comment.