Skip to content

Commit 11ae28c

Browse files
authored
Merge pull request #1172 from openmina/rustfmt-proof-systems
Rustfmt proof systems
2 parents cf7d0d3 + 28946ea commit 11ae28c

File tree

184 files changed

+1469
-1266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+1469
-1266
lines changed

.github/workflows/fmt.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
8+
jobs:
9+
format:
10+
name: Format using nightly
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: dtolnay/rust-toolchain@stable
15+
with:
16+
toolchain: nightly
17+
components: rustfmt
18+
- name: rustfmt
19+
run: make check-format

.github/workflows/lint.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: lint
1+
name: Lint
22

33
on:
44
push:
@@ -18,12 +18,8 @@ jobs:
1818
- uses: dtolnay/rust-toolchain@stable
1919
with:
2020
toolchain: 1.84
21-
components: rustfmt, clippy
22-
- name: rustfmt
23-
run: cargo fmt --all -- --check
21+
components: clippy, rustfmt
2422
- name: check
25-
run: cargo check --all-targets
26-
env:
27-
RUSTFLAGS: -D warnings
23+
run: make check
2824
- name: clippy
29-
run: cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type
25+
run: make lint

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
indent_style = "Block"
2+
imports_granularity = "Crate"
3+
reorder_imports = true

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ build-wasm: ## Build WebAssembly node
2424
check: ## Check code for compilation errors
2525
cargo check --all-targets
2626

27+
.PHONY: check-format
28+
check-format: ## Check code formatting
29+
cargo +nightly fmt -- --check
30+
2731
.PHONY: clean
2832
clean: ## Clean build artifacts
2933
cargo clean
3034

31-
.PHONY: fmt
32-
fmt: ## Format code using rustfmt
33-
cargo fmt --all
35+
.PHONY: format
36+
format: ## Format code using rustfmt
37+
cargo +nightly fmt
3438

3539
.PHONY: lint
3640
lint: ## Run linter (clippy)

cli/src/commands/misc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use libp2p_identity::PeerId;
2-
use node::account::AccountSecretKey;
3-
use node::p2p::identity::SecretKey;
2+
use node::{account::AccountSecretKey, p2p::identity::SecretKey};
43

54
#[derive(Debug, clap::Args)]
65
pub struct Misc {

cli/src/commands/node/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ use node::{
1111
use openmina_node_account::AccountPublicKey;
1212
use reqwest::Url;
1313

14-
use node::core::log::inner::Level;
15-
use node::p2p::connection::outgoing::P2pConnectionOutgoingInitOpts;
16-
use node::p2p::identity::SecretKey;
17-
use node::service::Recorder;
18-
use node::SnarkerStrategy;
14+
use node::{
15+
core::log::inner::Level,
16+
p2p::{connection::outgoing::P2pConnectionOutgoingInitOpts, identity::SecretKey},
17+
service::Recorder,
18+
SnarkerStrategy,
19+
};
1920

2021
use openmina_node_native::{archive::config::ArchiveStorageOptions, tracing, NodeBuilder};
2122

cli/src/exit_with_error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use console::style;
2-
use std::fmt::Display;
3-
use std::process;
2+
use std::{fmt::Display, process};
43

54
pub fn exit_with_error<E: Display>(error: E) -> ! {
65
eprintln!("{} {:#}", style("[ERROR]").red().bold(), error,);

cli/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ fn setup_var_from_single_and_only_thread() {
6666
/// We store (+ display) panics in non-main threads, and display them all when the main thread panics.
6767
#[cfg(not(target_family = "wasm"))]
6868
fn new_hook(info: &PanicHookInfo<'_>) {
69-
use std::any::Any;
70-
use std::io::Write;
69+
use std::{any::Any, io::Write};
7170

7271
fn payload_as_str(payload: &dyn Any) -> &str {
7372
if let Some(&s) = payload.downcast_ref::<&'static str>() {

core/src/block/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub mod genesis;
1010

1111
use std::sync::Arc;
1212

13-
pub use mina_p2p_messages::v2::MinaBlockBlockStableV2 as Block;
14-
pub use mina_p2p_messages::v2::MinaBlockHeaderStableV2 as BlockHeader;
15-
pub use mina_p2p_messages::v2::StateHash as BlockHash;
13+
pub use mina_p2p_messages::v2::{
14+
MinaBlockBlockStableV2 as Block, MinaBlockHeaderStableV2 as BlockHeader, StateHash as BlockHash,
15+
};
1616

1717
pub type ArcBlock = Arc<Block>;
1818
pub type ArcBlockWithHash = BlockWithHash<Arc<Block>>;

core/src/chain_id.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use mina_p2p_messages::v2::{
22
MinaBaseProtocolConstantsCheckedValueStableV1, StateHash, UnsignedExtendedUInt32StableV1,
33
};
44
use multihash::{Blake2b256, Hasher};
5-
use time::macros::format_description;
6-
use time::OffsetDateTime;
5+
use time::{macros::format_description, OffsetDateTime};
76

87
use std::{
98
fmt::{self, Debug, Display, Formatter},

0 commit comments

Comments
 (0)