From 0efd0f1afc404df4e2eac4640d398b932b5cc2f9 Mon Sep 17 00:00:00 2001 From: German Nikolishin Date: Wed, 31 Jan 2024 23:27:08 +0000 Subject: [PATCH] return stable --- .github/workflows/ci.yml | 4 +- .rustfmt.toml | 60 ----------------- crates/derive_node/src/lib.rs | 16 ++--- crates/parser/src/lexer.rs | 20 ++---- crates/parser/src/tests.rs | 122 ++++++++++++---------------------- 5 files changed, 56 insertions(+), 166 deletions(-) delete mode 100644 .rustfmt.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08587ba..fb7a762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo clippy --workspace --all-targets --all-features - - run: cargo +nightly fmt --check --all + - run: cargo fmt --check --all - run: cargo doc --workspace --no-deps \ No newline at end of file diff --git a/.rustfmt.toml b/.rustfmt.toml deleted file mode 100644 index 4ac630e..0000000 --- a/.rustfmt.toml +++ /dev/null @@ -1,60 +0,0 @@ -max_width = 90 # changed -hard_tabs = false -tab_spaces = 4 -newline_style = "Auto" -use_small_heuristics = "Default" -indent_style = "Block" -wrap_comments = true # changed -format_code_in_doc_comments = true # changed -doc_comment_code_block_width = 100 # changed -comment_width = 90 # changed -normalize_comments = true # changed -normalize_doc_attributes = false -format_strings = false -format_macro_matchers = false -format_macro_bodies = true -empty_item_single_line = true -struct_lit_single_line = true -fn_single_line = false -where_single_line = false -imports_indent = "Block" -imports_layout = "Vertical" # changed -imports_granularity = "Crate" # changed -reorder_imports = true -reorder_modules = true -reorder_impl_items = false -type_punctuation_density = "Wide" -space_before_colon = false -space_after_colon = true -spaces_around_ranges = false -binop_separator = "Front" -remove_nested_parens = true -combine_control_expr = false # changed -overflow_delimited_expr = false -struct_field_align_threshold = 0 -enum_discrim_align_threshold = 0 -match_arm_blocks = true -force_multiline_blocks = true # changed -fn_params_layout = "Tall" -brace_style = "SameLineWhere" -control_brace_style = "AlwaysSameLine" -trailing_semicolon = false # changed -trailing_comma = "Vertical" -match_block_trailing_comma = false -blank_lines_upper_bound = 1 -blank_lines_lower_bound = 0 -edition = "2021" # changed -version = "One" -merge_derives = true -use_try_shorthand = true # changed -use_field_init_shorthand = true # changed -force_explicit_abi = true -condense_wildcard_suffixes = false -color = "Auto" -unstable_features = true # changed -disable_all_formatting = false -skip_children = false -hide_parse_errors = false -error_on_line_overflow = false -error_on_unformatted = false -ignore = [] diff --git a/crates/derive_node/src/lib.rs b/crates/derive_node/src/lib.rs index 0f027a7..0ce16d4 100644 --- a/crates/derive_node/src/lib.rs +++ b/crates/derive_node/src/lib.rs @@ -12,16 +12,12 @@ fn node_derive(mut s: synstructure::Structure) -> TokenStream2 { .add_bounds(synstructure::AddBounds::Fields) .underscore_const(true); match &s.ast().data { - syn::Data::Struct(_) => { - node_derive_struct(s).unwrap_or_else(|err| err.to_compile_error()) - } - _ => { - syn::Error::new( - s.ast().span(), - "can only derive `Node` for Rust `struct` items", - ) - .to_compile_error() - } + syn::Data::Struct(_) => node_derive_struct(s).unwrap_or_else(|err| err.to_compile_error()), + _ => syn::Error::new( + s.ast().span(), + "can only derive `Node` for Rust `struct` items", + ) + .to_compile_error(), } } diff --git a/crates/parser/src/lexer.rs b/crates/parser/src/lexer.rs index 67d9747..ac3f261 100644 --- a/crates/parser/src/lexer.rs +++ b/crates/parser/src/lexer.rs @@ -1,12 +1,6 @@ use super::Span; -use logos::{ - Logos, - SpannedIter, -}; -use std::{ - fmt, - num::ParseIntError, -}; +use logos::{Logos, SpannedIter}; +use std::{fmt, num::ParseIntError}; use thiserror::Error; #[derive(Default, Clone, Debug, PartialEq)] @@ -326,12 +320,10 @@ impl<'input> Iterator for Lexer<'input> { fn next(&mut self) -> Option { if let Some((tok_res, span)) = self.token_stream.next() { match tok_res { - Ok(tok) => { - match tok { - Token::Comment(_) => self.next(), - _ => Some((span.start, tok, span.end)), - } - } + Ok(tok) => match tok { + Token::Comment(_) => self.next(), + _ => Some((span.start, tok, span.end)), + }, Err(err) => { self.errors.push(logos_to_lexical_error(&err, &span)); self.next() diff --git a/crates/parser/src/tests.rs b/crates/parser/src/tests.rs index bba9d54..de93135 100644 --- a/crates/parser/src/tests.rs +++ b/crates/parser/src/tests.rs @@ -1,36 +1,12 @@ use crate::{ ast::{ - self, - AccessAttribute, - BinaryExpression, - Declaration, - Expression, - FuncReturnType, - FunctionCall, - FunctionDeclaration, - FunctionVisibility, - Identifier, - IfElse, - List, - Mapping, - MappingRelation, - Param, - Set, - Source, - StBlock, - StateDeclaration, - Statement, - StatementBlock, - StructInit, - TypeVariant, - UnaryExpression, - Variable, + self, AccessAttribute, BinaryExpression, Declaration, Expression, FuncReturnType, + FunctionCall, FunctionDeclaration, FunctionVisibility, Identifier, IfElse, List, Mapping, + MappingRelation, Param, Set, Source, StBlock, StateDeclaration, Statement, StatementBlock, + StructInit, TypeVariant, UnaryExpression, Variable, }, folidity, - lexer::{ - Lexer, - Token, - }, + lexer::{Lexer, Token}, }; #[test] @@ -279,8 +255,8 @@ fn test_factorial_tree() { }), else_part: Some(Box::new(Statement::Block(StatementBlock { loc: 175..349, - statements: vec![Statement::Return( - Expression::FunctionCall(FunctionCall { + statements: vec![Statement::Return(Expression::FunctionCall( + FunctionCall { loc: 192..342, name: Identifier { loc: 192..201, @@ -288,58 +264,44 @@ fn test_factorial_tree() { }, args: vec![Expression::Pipe(BinaryExpression { loc: 296..324, - left: Box::new(Expression::Multiply( - BinaryExpression { - loc: 296..315, - left: Box::new(Expression::Variable( - Identifier { - loc: 296..301, - name: "value".to_string(), - }, - )), - right: Box::new(Expression::Subtract( - BinaryExpression { - loc: 305..314, - left: Box::new( - Expression::Variable( - Identifier { - loc: 305..310, - name: "value" - .to_string(), - }, - ), - ), - right: Box::new( - Expression::Number( - UnaryExpression { - loc: 313..314, - element: "1" - .to_string(), - }, - ), - ), - }, - )), - }, - )), - right: Box::new(Expression::FunctionCall( - FunctionCall { - loc: 319..324, - name: Identifier { - loc: 319..321, - name: "or".to_string(), + left: Box::new(Expression::Multiply(BinaryExpression { + loc: 296..315, + left: Box::new(Expression::Variable(Identifier { + loc: 296..301, + name: "value".to_string(), + })), + right: Box::new(Expression::Subtract( + BinaryExpression { + loc: 305..314, + left: Box::new(Expression::Variable( + Identifier { + loc: 305..310, + name: "value".to_string(), + }, + )), + right: Box::new(Expression::Number( + UnaryExpression { + loc: 313..314, + element: "1".to_string(), + }, + )), }, - args: vec![Expression::Number( - UnaryExpression { - loc: 322..323, - element: "1".to_string(), - }, - )], + )), + })), + right: Box::new(Expression::FunctionCall(FunctionCall { + loc: 319..324, + name: Identifier { + loc: 319..321, + name: "or".to_string(), }, - )), + args: vec![Expression::Number(UnaryExpression { + loc: 322..323, + element: "1".to_string(), + })], + })), })], - }), - )], + }, + ))], }))), })], }),