Skip to content

Commit be2a10f

Browse files
committed
Fix clippy lints and formatting
1 parent 54e2dc3 commit be2a10f

16 files changed

Lines changed: 126 additions & 102 deletions

File tree

.github/workflows/build-test-all.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
strategy:
1717
matrix:
1818
crate:
19-
- vhdl_lang
20-
- vhdl_ls
21-
- vhdl_syntax
22-
- vhdl-dump-ast
19+
- { name: "vhdl_lang", path: "crates/vhdl_lang", binary: true }
20+
- { name: "vhdl_ls", path: "crates/vhdl_ls", binary: true }
21+
- { name: "vhdl_syntax", path: "crates/vhdl_syntax", binary: false }
22+
- { name: "vhdl-dump-ast", path: "crates/vhdl-dump-ast", binary: false }
2323
target:
2424
- x86_64-unknown-linux-gnu
2525
- x86_64-unknown-linux-musl
@@ -51,11 +51,15 @@ jobs:
5151
uses: dtolnay/rust-toolchain@stable
5252
with:
5353
toolchain: ${{ matrix.rust }}
54-
target: x86_64-unknown-linux-musl
54+
target: ${{ matrix.target }}
5555
components: rustfmt, clippy
56-
57-
- name: Add Apple Silicon Dependencies
58-
run: rustup target add aarch64-apple-darwin
56+
- name: Cache cargo
57+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
58+
with:
59+
path: |
60+
~/.cargo/registry
61+
~/.cargo/git
62+
key: ${{ runner.os }}-${{ matrix.target }}-${{ matrix.rust }}-${{ matrix.crate.name }}-${{ hashFiles('**/Cargo.lock') }}
5963

6064
- uses: awalsh128/cache-apt-pkgs-action@5902b33ae29014e6ca012c5d8025d4346556bd40 # v1.5.0
6165
if: matrix.os == 'ubuntu-latest'
@@ -64,34 +68,34 @@ jobs:
6468
version: 1.0
6569

6670
- name: Build
67-
run: cargo build --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
71+
run: cargo build --manifest-path ${{ matrix.crate.path }}/Cargo.toml --release --target ${{ matrix.target }}
6872

6973
- name: Test
7074
if: matrix.os != 'macos-latest' # There are no free runners for Apple Silicon available at the moment
71-
run: cargo test --manifest-path ${{ matrix.crate }}/Cargo.toml --release --target ${{ matrix.target }}
75+
run: cargo test --manifest-path ${{ matrix.crate.path }}/Cargo.toml --release --target ${{ matrix.target }}
7276

7377
- name: rustfmt
7478
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable'
75-
run: cargo fmt --package ${{ matrix.crate }} -- --check
79+
run: cargo fmt --manifest-path ${{ matrix.crate.path }}/Cargo.toml -- --check
7680

7781
- name: clippy
78-
if: matrix.os == 'ubuntu-latest'
79-
run: cargo clippy --package ${{ matrix.crate }} --all-targets --all-features -- -D warnings
82+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' }}
83+
run: cargo clippy --manifest-path ${{ matrix.crate.path }}/Cargo.toml --all-targets --all-features -- -D warnings
8084

8185
- name: Assemble
82-
if: matrix.rust == 'stable'
86+
if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }}
8387
run: |
84-
mkdir ${{ matrix.crate }}-${{ matrix.target }}
85-
mkdir ${{ matrix.crate }}-${{ matrix.target }}/bin
86-
cp -R vhdl_libraries ${{ matrix.crate }}-${{ matrix.target }}
87-
cp target/${{ matrix.target }}/release/${{ matrix.crate }}${{ matrix.ext }} ${{ matrix.crate }}-${{ matrix.target }}/bin
88+
mkdir ${{ matrix.crate.name }}-${{ matrix.target }}
89+
mkdir ${{ matrix.crate.name }}-${{ matrix.target }}/bin
90+
cp -R vhdl_libraries ${{ matrix.crate.name }}-${{ matrix.target }}
91+
cp target/${{ matrix.target }}/release/${{ matrix.crate.name }}${{ matrix.ext }} ${{ matrix.crate.name }}-${{ matrix.target }}/bin
8892
8993
- name: Upload
90-
if: matrix.rust == 'stable'
94+
if: ${{ matrix.crate.binary == true && matrix.rust == 'stable' }}
9195
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9296
with:
93-
name: ${{ matrix.crate }}-${{ matrix.target }}
94-
path: ${{ matrix.crate }}-${{ matrix.target }}
97+
name: ${{ matrix.crate.name }}-${{ matrix.target }}
98+
path: ${{ matrix.crate.name }}-${{ matrix.target }}
9599

96100
release:
97101
name: Release
@@ -128,7 +132,7 @@ jobs:
128132
version_string=$(~/temp/vhdl_ls-x86_64-unknown-linux-musl/bin/vhdl_ls --version)
129133
if [ "$version_string" != "vhdl_ls $v" ]
130134
then
131-
echo "Version string mismatch (\"$version_string\" != \"vhdl_lang $v\""
135+
echo "Version string mismatch (\"$version_string\" != \"vhdl_ls $v\""
132136
exit 1
133137
else
134138
echo "Version string matched"

vhdl_syntax/examples/linting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use vhdl_syntax::syntax::EntityDeclarationSyntax;
1111

1212
/// Showcases how one could write a simple linter that checks that the declared name and final name
1313
/// of an entity match.
14-
1514
fn main() {
1615
let vhdl = "\
1716
entity baz is

vhdl_syntax/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
//! Provides facilities to format nodes and tokens to encoded strings.
22
3-
pub mod utf8;
43
pub mod latin1;
4+
pub mod utf8;

vhdl_syntax/src/fmt/utf8.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Provides facilities to format nodes and tokens to UTF-8 encoded strings.
2-
//!
2+
//!
33
//! # Important considerations
44
//!
55
//! ## Latin1 encoding
@@ -10,15 +10,15 @@
1010
//! the encoding is simply `[0xE9]`.
1111
//! As a consequence, the round-trip VHDL-file -> parse -> to string is not guaranteed to yield
1212
//! the same result.
13-
//!
14-
//! If you want to format to Latin-1, consider using the [fmt::latin1](crate::fmt::latin1) module.
13+
//!
14+
//! If you want to format to Latin-1, consider using the [fmt::latin1](crate::fmt::latin1) module.
1515
//!
1616
//! ## Comment handling
17-
//!
17+
//!
1818
//! VHDL allows comments to have a different encoding compared to the rest of the file.
1919
//! This implementation assumes `UTF-8` and will replace every invalid UTF-8 sequences
2020
//! with `U+FFFD REPLACEMENT CHARACTER`, which looks like this: �
21-
//!
21+
//!
2222
//! To circumvent the issues from above, the byte-oriented facilities
2323
//! (e.g., [SyntaxNode::write_to], [Token::write_to]) can be used. These always guarantee that the round-trip
2424
//! VHDL-file -> parse -> write will yield the exact same result.

vhdl_syntax/src/parser/productions/concurrent_statement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Parser {
193193
_ => {
194194
self.skip();
195195
self.expect_tokens_err([Keyword(Kw::Block)])
196-
},
196+
}
197197
}
198198
}
199199

vhdl_syntax/src/parser/productions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub mod association_lists;
99
pub mod attributes;
1010
pub mod component_declaration;
1111
pub mod composite_types;
12-
pub mod context;
1312
pub mod concurrent_statement;
1413
pub mod configuration_declarations;
14+
pub mod context;
1515
pub mod declarations;
1616
pub mod design;
1717
pub mod entity_declaration;

vhdl_syntax/src/parser/productions/names.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ mod tests {
373373

374374
#[test]
375375
fn test_external_name_explicit_relative_multiple_levels() {
376-
insta::assert_snapshot!(name_to_test_text(
377-
"<< signal ^.^.^.dut.gen : std_logic >>"
378-
));
376+
insta::assert_snapshot!(name_to_test_text("<< signal ^.^.^.dut.gen : std_logic >>"));
379377
}
380378

381379
#[test]

vhdl_syntax/src/parser/util.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ impl Parser {
115115
}
116116
}
117117

118-
pub(crate) fn expect_one_of_tokens<const N: usize>(&mut self, kinds: [TokenKind; N]) -> Option<TokenKind> {
118+
pub(crate) fn expect_one_of_tokens<const N: usize>(
119+
&mut self,
120+
kinds: [TokenKind; N],
121+
) -> Option<TokenKind> {
119122
for kind in kinds {
120123
if self.opt_token(kind) {
121124
return Some(kind);
@@ -126,11 +129,17 @@ impl Parser {
126129
}
127130

128131
pub(crate) fn peek_token(&self) -> TokenKind {
129-
self.token_stream.peek(0).map(|tok| tok.kind()).unwrap_or(TokenKind::Eof)
132+
self.token_stream
133+
.peek(0)
134+
.map(|tok| tok.kind())
135+
.unwrap_or(TokenKind::Eof)
130136
}
131137

132138
pub(crate) fn peek_nth_token(&self, n: usize) -> TokenKind {
133-
self.token_stream.peek(n).map(|tok| tok.kind()).unwrap_or(TokenKind::Eof)
139+
self.token_stream
140+
.peek(n)
141+
.map(|tok| tok.kind())
142+
.unwrap_or(TokenKind::Eof)
134143
}
135144

136145
pub(crate) fn next_is(&self, kind: TokenKind) -> bool {

vhdl_syntax/src/serde/flags.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//! let flags = SerdeFlags::default()
1111
//! .include_trivia(false)
1212
//! .include_loc(true);
13-
//!
13+
//!
1414
//! // Serialized data will not include trivia information
1515
//! assert!(!flags.includes_trivia());
16-
//!
16+
//!
1717
//! // Serialized data will include source location
1818
//! assert!(flags.includes_loc());
1919
//! ```
@@ -31,7 +31,7 @@ impl Default for SerdeFlags {
3131
Self {
3232
include_trivia: true,
3333
include_loc: true,
34-
comment_encoding: "utf-8".into()
34+
comment_encoding: "utf-8".into(),
3535
}
3636
}
3737
}
@@ -61,7 +61,7 @@ impl SerdeFlags {
6161

6262
/// Comments in VHDL can have arbitrary encoding. This flag allows serializers to specify an
6363
/// encoding that is attached to individual comments in the serialized AST.
64-
///
64+
///
6565
/// Currently, this encoding serves merely as an information to consumers.
6666
/// It is not enforced nor is the string actually encoded using the specified value.
6767
/// This may change in the future.

vhdl_syntax/src/serde/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Support for serializing and de-serializing syntax elements.
22
3-
pub mod serialize_impl;
43
pub mod flags;
4+
pub mod serialize_impl;
55
pub use flags::SerdeFlags;
66
pub mod serializable;
77
pub use serializable::Serializable;

0 commit comments

Comments
 (0)