Skip to content

Commit

Permalink
[num-format-dev] Remove automatic running of rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmyers committed Oct 9, 2022
1 parent 829c599 commit b4e8067
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 51 deletions.
4 changes: 0 additions & 4 deletions num-format-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ anyhow = "1.0.65"
indexmap = "1.9.1"
proc-macro2 = "1.0.46"
quote = "1.0.21"
rustfmt-nightly = { version = "1.4.21", optional = true }
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.85"
walkdir = "2.3.2"

[features]
nightly = ["rustfmt-nightly"]
21 changes: 2 additions & 19 deletions num-format-dev/src/create_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@ use indexmap::IndexMap;
use proc_macro2::{Delimiter, Group, Ident, Literal, Span};
use quote::quote;

#[cfg(feature = "nightly")]
use crate::rustfmt::rustfmt;
use crate::utils::Format;

#[cfg(feature = "nightly")]
/// Takes the map returned from `parse_data` and turns it into a rust module.
pub fn create_module(data: &IndexMap<String, Format>) -> Result<String, anyhow::Error> {
let s = _create_module(data)?;
let s = rustfmt(s)?;
Ok(s)
}

#[cfg(not(feature = "nightly"))]
/// Takes the map returned from `parse_data` and turns it into a rust module.
pub fn create_module(data: &IndexMap<String, Format>) -> Result<String, anyhow::Error> {
let s = _create_module(data)?;
Ok(s)
}

/// Takes the map returned from `parse_data` and turns it into a rust module.
fn _create_module(data: &IndexMap<String, Format>) -> Result<String, anyhow::Error> {
let variant_names = data.keys().map(|s| Ident::new(s, Span::call_site()));

let mut decimals = Vec::new();
Expand Down Expand Up @@ -119,8 +102,8 @@ fn _create_module(data: &IndexMap<String, Format>) -> Result<String, anyhow::Err
);
from_strs.push(group);
// from_strs: support both - and _ as locale separators (i.e. both de-DE and de_DE)
if format.identifier.contains("-") {
let key2 = Literal::string(&format.identifier.replace("-", "_"));
if format.identifier.contains('-') {
let key2 = Literal::string(&format.identifier.replace('-', "_"));
let group = Group::new(
Delimiter::None,
quote! {
Expand Down
4 changes: 0 additions & 4 deletions num-format-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

mod create_module;
mod parse_data;
#[cfg(feature = "nightly")]
mod rustfmt;
mod utils;

pub use self::create_module::create_module;
pub use self::parse_data::parse_data;
#[cfg(feature = "nightly")]
pub use self::rustfmt::rustfmt;
24 changes: 0 additions & 24 deletions num-format-dev/src/rustfmt.rs

This file was deleted.

0 comments on commit b4e8067

Please sign in to comment.