Skip to content

Commit

Permalink
fix(dprint): Run rustfmt with nightly
Browse files Browse the repository at this point in the history
We must do this if we want `dprint` to respect some of the unstable
options we have configured in our `rustfmt.toml`. This is what we get
if we run `cargo fmt` (as opposed to `cargo +nightly fmt`):

```
Warning: can't set `wrap_comments = true`, unstable features are only available in nightly channel.
Warning: can't set `comment_width = 100`, unstable features are only available in nightly channel.
Warning: can't set `imports_granularity = Item`, unstable features are only available in nightly channel.
Warning: can't set `group_imports = One`, unstable features are only available in nightly channel.
```

After running `dprint fmt` with the new configuration we can see that
the autoformatter consistently applies `group_imports = One` to our
codebase.
  • Loading branch information
luckysori committed Aug 2, 2023
1 parent 1f52d2a commit 5e1d14b
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 30 deletions.
3 changes: 1 addition & 2 deletions coordinator/src/db/user.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::schema::users;
use coordinator_commons::RegisterParams;
use diesel::prelude::*;
use serde::Deserialize;
use serde::Serialize;
use time::OffsetDateTime;

use crate::schema::users;

#[derive(Insertable, Queryable, Identifiable, Debug, Clone, Serialize, Deserialize)]
#[diesel(primary_key(id))]
pub struct User {
Expand Down
3 changes: 1 addition & 2 deletions coordinator/src/orderbook/tests/registration_test.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::str::FromStr;

use crate::db::user;
use crate::db::user::User;
use crate::orderbook::tests::init_tracing;
use crate::orderbook::tests::setup_db;
use crate::orderbook::tests::start_postgres;
use bitcoin::secp256k1::PublicKey;
use coordinator_commons::RegisterParams;
use std::str::FromStr;
use testcontainers::clients::Cli;

#[tokio::test]
Expand Down
3 changes: 1 addition & 2 deletions crates/bitmex-stream/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::tungstenite::http::Method;
use anyhow::Context;
use anyhow::Error;
use async_stream::stream;
use futures::SinkExt;
use futures::Stream;
Expand All @@ -16,8 +17,6 @@ use tokio_tungstenite::tungstenite;
use tracing::Instrument;
use url::Url;

pub use anyhow::Error;

/// Connects to the BitMex websocket API
///
/// It subscribes to the specified topics (comma-separated) and yields all messages.
Expand Down
3 changes: 1 addition & 2 deletions crates/ln-dlc-node/src/node/peer_manager.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::PeerManager;
use anyhow::ensure;
use lightning::ln::msgs::NetAddress;

use crate::PeerManager;

const NODE_COLOR: [u8; 3] = [0; 3];

pub fn broadcast_node_announcement(
Expand Down
6 changes: 2 additions & 4 deletions crates/ln-dlc-node/src/seed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::path::Path;

use anyhow::bail;
use anyhow::Result;
use bdk::bitcoin;
Expand All @@ -9,6 +7,7 @@ use bip39::Mnemonic;
use bitcoin::Network;
use hkdf::Hkdf;
use sha2::Sha256;
use std::path::Path;

#[derive(Clone)]
pub struct Bip39Seed {
Expand Down Expand Up @@ -119,11 +118,10 @@ pub type LightningSeed = [u8; 32];

#[cfg(test)]
mod tests {
use crate::seed::Bip39Seed;
use bip39::Mnemonic;
use std::env::temp_dir;

use crate::seed::Bip39Seed;

#[test]
fn create_bip39_seed() {
let seed = Bip39Seed::new().expect("seed to be generated");
Expand Down
2 changes: 1 addition & 1 deletion crates/orderbook-client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Context;
pub use anyhow::Error;
use anyhow::Error;
use anyhow::Result;
use async_stream::stream;
use futures::SinkExt;
Expand Down
17 changes: 8 additions & 9 deletions crates/tests-e2e/src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
use crate::app::run_app;
use crate::app::AppHandle;
use crate::bitcoind::Bitcoind;
use crate::coordinator::Coordinator;
use crate::fund::fund_app_with_faucet;
use crate::http::init_reqwest;
use crate::logger::init_tracing;
use crate::wait_until;
use bitcoin::Address;
use bitcoin::Amount;
use native::api;
Expand All @@ -8,15 +16,6 @@ use native::trade::position::PositionState;
use std::str::FromStr;
use tokio::task::spawn_blocking;

use crate::app::run_app;
use crate::app::AppHandle;
use crate::bitcoind::Bitcoind;
use crate::coordinator::Coordinator;
use crate::fund::fund_app_with_faucet;
use crate::http::init_reqwest;
use crate::logger::init_tracing;
use crate::wait_until;

pub struct TestSetup {
pub app: AppHandle,
pub coordinator: Coordinator,
Expand Down
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"exec": {
"commands": [
{
"command": "rustfmt",
"command": "rustfmt +nightly",
"exts": [
"rs"
]
Expand Down
9 changes: 4 additions & 5 deletions mobile/native/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ mod event_hub;
pub mod subscriber;

use crate::api::WalletInfo;
use crate::event::event_hub::get;
use crate::event::subscriber::Subscriber;
use crate::health::ServiceUpdate;
use crate::trade::order::Order;
use crate::trade::position::Position;
use coordinator_commons::TradeParams;
use ln_dlc_node::node::rust_dlc_manager::ChannelId;
use orderbook_commons::Prices;
use std::hash::Hash;
use trade::ContractSymbol;

use crate::event::event_hub::get;
use crate::event::subscriber::Subscriber;
use crate::trade::order::Order;
use crate::trade::position::Position;

pub fn subscribe(subscriber: impl Subscriber + 'static + Send + Sync + Clone) {
get().subscribe(subscriber);
}
Expand Down
3 changes: 1 addition & 2 deletions mobile/native/src/trade/order/orderbook_client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::commons::reqwest_client;
use anyhow::bail;
use anyhow::Result;
use orderbook_commons::NewOrder;
use orderbook_commons::OrderResponse;
use reqwest::Url;

use crate::commons::reqwest_client;

pub struct OrderbookClient {
url: Url,
}
Expand Down

0 comments on commit 5e1d14b

Please sign in to comment.