Skip to content

Commit

Permalink
fix: trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Millione committed Aug 9, 2023
1 parent 32b720e commit bd18043
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pilota-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-build"
version = "0.8.1"
version = "0.8.2"
edition = "2021"
description = "Compile thrift and protobuf idl into rust code at compile-time."
documentation = "https://docs.rs/pilota-build"
Expand Down
11 changes: 6 additions & 5 deletions pilota-build/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use itertools::Itertools;
use normpath::PathExt;
use pkg_tree::PkgNode;
use quote::quote;
use rayon::prelude::IntoParallelRefIterator;
use rayon::{
prelude::{IntoParallelRefIterator, ParallelIterator},
str::ParallelString,
};
use traits::CodegenBackend;

use self::workspace::Workspace;
Expand Down Expand Up @@ -429,8 +432,6 @@ where
where
B: Send,
{
use rayon::iter::ParallelIterator;

let mods = items.into_group_map_by(|CodegenItem { def_id, .. }| {
let path = Arc::from_iter(self.mod_path(*def_id).iter().map(|s| s.0.clone()));
tracing::debug!("ths path of {:?} is {:?}", def_id, path);
Expand Down Expand Up @@ -504,9 +505,9 @@ where
#![allow(warnings, clippy::all)]
{stream}
}}"#};

let stream = stream.lines().map(|s| s.trim_end()).join("\n");
let mut file = std::io::BufWriter::new(std::fs::File::create(&file_name).unwrap());
file.write_all(stream.to_string().as_bytes()).unwrap();
file.write_all(stream.as_bytes()).unwrap();
file.flush().unwrap();
fmt_file(file_name)
}
Expand Down
4 changes: 2 additions & 2 deletions pilota-build/src/codegen/thrift/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl ThriftBackend {
{record_ptr}
let field_ident = {read_field_begin};
if field_ident.field_type == ::pilota::thrift::TType::Stop {{
{field_stop_len}
{field_stop_len}
break;
}} else {{
{field_begin_len}
Expand Down Expand Up @@ -685,7 +685,7 @@ impl CodegenBackend for ThriftBackend {
{record_ptr}
let field_ident = {read_field_begin};
if field_ident.field_type == ::pilota::thrift::TType::Stop {{
{field_stop_len}
{field_stop_len}
break;
}} else {{
{field_begin_len}
Expand Down
7 changes: 6 additions & 1 deletion pilota-build/src/codegen/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use anyhow::bail;
use faststr::FastStr;
use fxhash::FxHashMap;
use itertools::Itertools;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use rayon::{
prelude::{IntoParallelRefIterator, ParallelIterator},
str::ParallelString,
};

use super::CodegenItem;
use crate::{
Expand Down Expand Up @@ -287,6 +290,8 @@ where
stream.push_str(&format!("pub use {}::*;", main_mod_path.join("::")));
}

let stream = stream.lines().map(|s| s.trim_end()).join("\n");

let src_file = base_dir.as_ref().join(&*info.name).join("src/lib.rs");

std::fs::write(&src_file, stream)?;
Expand Down
2 changes: 1 addition & 1 deletion pilota-build/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Plugin for ImplDefaultPlugin {
if !fields.is_empty() {
fields.push_str(",\n");
}
fields.push_str("unknown_fields: ::pilota::Bytes::new()");
fields.push_str("_unknown_fields: ::pilota::LinkedBytes::new()");
}

cx.with_adjust_mut(def_id, |adj| {
Expand Down
1 change: 1 addition & 0 deletions pilota-build/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ fn test_unknown_fields() {
crate::Builder::thrift()
.ignore_unused(false)
.keep_unknown_fields([source.into()])
.plugin(SerdePlugin)
.compile_with_config(
vec![IdlService::from_path(source.to_path_buf())],
crate::Output::File(target.into()),
Expand Down
Loading

0 comments on commit bd18043

Please sign in to comment.