Skip to content

Commit 7f91ecd

Browse files
authored
chore: format all code ready for adding cargo format check point in G… (#119)
chore: format all code ready for adding cargo format check point in Github actions.
1 parent 844dd15 commit 7f91ecd

File tree

19 files changed

+125
-97
lines changed

19 files changed

+125
-97
lines changed

kclvm/3rdparty/rustc_data_structures/src/base_n.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
/// Bases up to and including 36 can be used for case-insensitive things.
33
use std::str;
44

5-
#[cfg(test)]
6-
mod tests;
7-
85
pub const MAX_BASE: usize = 64;
96
pub const ALPHANUMERIC_ONLY: usize = 62;
107
pub const CASE_INSENSITIVE: usize = 36;

kclvm/3rdparty/rustc_data_structures/src/stable_map.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ where
5454
K: Eq + Hash,
5555
{
5656
pub fn new() -> StableMap<K, V> {
57-
StableMap { base: FxHashMap::default() }
57+
StableMap {
58+
base: FxHashMap::default(),
59+
}
5860
}
5961

6062
pub fn into_sorted_vector(self) -> Vec<(K, V)>

kclvm/3rdparty/rustc_data_structures/src/stable_set.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ impl<T> Eq for StableSet<T> where T: Eq + Hash {}
4343

4444
impl<T: Hash + Eq> StableSet<T> {
4545
pub fn new() -> StableSet<T> {
46-
StableSet { base: FxHashSet::default() }
46+
StableSet {
47+
base: FxHashSet::default(),
48+
}
4749
}
4850

4951
pub fn into_sorted_vector(self) -> Vec<T>

kclvm/3rdparty/rustc_data_structures/src/sync.rs

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@ use std::hash::{BuildHasher, Hash};
2323
pub use std::sync::atomic::Ordering;
2424
pub use std::sync::atomic::Ordering::SeqCst;
2525

26-
pub use std::marker::Send as Send;
27-
pub use std::marker::Sync as Sync;
26+
pub use std::marker::Send;
27+
pub use std::marker::Sync;
2828

29-
pub use parking_lot::RwLockReadGuard as ReadGuard;
30-
pub use parking_lot::MappedRwLockReadGuard as MappedReadGuard;
31-
pub use parking_lot::RwLockWriteGuard as WriteGuard;
32-
pub use parking_lot::MappedRwLockWriteGuard as MappedWriteGuard;
29+
pub use parking_lot::MappedRwLockReadGuard as MappedReadGuard;
30+
pub use parking_lot::MappedRwLockWriteGuard as MappedWriteGuard;
31+
pub use parking_lot::RwLockReadGuard as ReadGuard;
32+
pub use parking_lot::RwLockWriteGuard as WriteGuard;
3333

34-
pub use parking_lot::MutexGuard as LockGuard;
35-
pub use parking_lot::MappedMutexGuard as MappedLockGuard;
34+
pub use parking_lot::MappedMutexGuard as MappedLockGuard;
35+
pub use parking_lot::MutexGuard as LockGuard;
3636

37-
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
37+
pub use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicUsize};
3838

39-
pub use std::sync::Arc as Lrc;
40-
pub use std::sync::Weak as Weak;
39+
pub use std::sync::Arc as Lrc;
40+
pub use std::sync::Weak;
4141

42-
pub type MTRef<'a, T> = &'a T;
42+
pub type MTRef<'a, T> = &'a T;
4343

44-
pub use rayon::{join, scope};
44+
pub use rayon::{join, scope};
4545

46-
/// Runs a list of blocks in parallel. The first block is executed immediately on
47-
/// the current thread. Use that for the longest running block.
48-
#[macro_export]
49-
macro_rules! parallel {
46+
/// Runs a list of blocks in parallel. The first block is executed immediately on
47+
/// the current thread. Use that for the longest running block.
48+
#[macro_export]
49+
macro_rules! parallel {
5050
(impl $fblock:tt [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
5151
parallel!(impl $fblock [$block, $($c,)*] [$($rest),*])
5252
};
@@ -66,31 +66,27 @@ pub use std::sync::atomic::Ordering::SeqCst;
6666
};
6767
}
6868

69-
pub use rayon_core::WorkerLocal;
69+
pub use rayon_core::WorkerLocal;
7070

71-
pub use rayon::iter::ParallelIterator;
72-
use rayon::iter::IntoParallelIterator;
71+
use rayon::iter::IntoParallelIterator;
72+
pub use rayon::iter::ParallelIterator;
7373

74-
pub fn par_iter<T: IntoParallelIterator>(t: T) -> T::Iter {
75-
t.into_par_iter()
76-
}
77-
78-
pub fn par_for_each_in<T: IntoParallelIterator>(
79-
t: T,
80-
for_each: impl Fn(T::Item) + Sync + Send,
81-
) {
82-
t.into_par_iter().for_each(for_each)
83-
}
74+
pub fn par_iter<T: IntoParallelIterator>(t: T) -> T::Iter {
75+
t.into_par_iter()
76+
}
8477

85-
#[macro_export]
86-
macro_rules! rustc_erase_owner {
87-
($v:expr) => {{
88-
let v = $v;
89-
::rustc_data_structures::sync::assert_send_val(&v);
90-
v.erase_send_sync_owner()
91-
}}
92-
}
78+
pub fn par_for_each_in<T: IntoParallelIterator>(t: T, for_each: impl Fn(T::Item) + Sync + Send) {
79+
t.into_par_iter().for_each(for_each)
80+
}
9381

82+
#[macro_export]
83+
macro_rules! rustc_erase_owner {
84+
($v:expr) => {{
85+
let v = $v;
86+
::rustc_data_structures::sync::assert_send_val(&v);
87+
v.erase_send_sync_owner()
88+
}};
89+
}
9490

9591
pub fn assert_sync<T: ?Sized + Sync>() {}
9692
pub fn assert_send<T: ?Sized + Send>() {}
@@ -105,6 +101,8 @@ pub trait HashMapExt<K, V> {
105101

106102
impl<K: Eq + Hash, V: Eq, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S> {
107103
fn insert_same(&mut self, key: K, value: V) {
108-
self.entry(key).and_modify(|old| assert!(*old == value)).or_insert(value);
104+
self.entry(key)
105+
.and_modify(|old| assert!(*old == value))
106+
.or_insert(value);
109107
}
110108
}

kclvm/3rdparty/rustc_data_structures/src/temp_dir.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ impl AsRef<Path> for MaybeTempDir {
2929

3030
impl MaybeTempDir {
3131
pub fn new(dir: TempDir, keep_on_drop: bool) -> MaybeTempDir {
32-
MaybeTempDir { dir: ManuallyDrop::new(dir), keep: keep_on_drop }
32+
MaybeTempDir {
33+
dir: ManuallyDrop::new(dir),
34+
keep: keep_on_drop,
35+
}
3336
}
3437
}

kclvm/ast/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::ast;
33
/// Try get a config expr mut ref from a expr if the expr is a schema or a config.
44
/// If not, return [None].
55
/// TODO: use [TryInto]?
6-
///
6+
///
77
/// # Examples
88
///
99
/// ```
@@ -29,6 +29,6 @@ pub fn try_get_config_expr_mut(expr: &mut ast::Expr) -> Option<&mut ast::ConfigE
2929
}
3030
}
3131
ast::Expr::Config(config_expr) => Some(config_expr),
32-
_ => None
32+
_ => None,
3333
}
3434
}

kclvm/config/src/cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ pub fn write_info_cache(
155155
let mut cache = read_info_cache(root, cache_name);
156156
cache.insert(relative_path, cache_info);
157157
let mut file = File::create(&tmp_filename).unwrap();
158-
file.write_all(&ron::ser::to_string(&cache).unwrap().as_bytes()).unwrap();
158+
file.write_all(&ron::ser::to_string(&cache).unwrap().as_bytes())
159+
.unwrap();
159160
std::fs::rename(&tmp_filename, &dst_filename).unwrap();
160161
lock_file.unlock().unwrap();
161162
Ok(())

kclvm/parser/src/lexer/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,16 @@ impl<'a> Lexer<'a> {
242242
kclvm_lexer::TokenKind::Minus => {
243243
let head = start + BytePos::from_u32(1);
244244
let tail = start + BytePos::from_u32(2);
245-
if self.has_next_token(head, tail){
246-
let next_tkn =
247-
self.str_from_to(head, tail);
245+
if self.has_next_token(head, tail) {
246+
let next_tkn = self.str_from_to(head, tail);
248247
if next_tkn == ">" {
249248
// waste '>' token
250249
self.pos = self.pos + BytePos::from_usize(1);
251250
token::RArrow
252251
} else {
253-
token::BinOp(token::Minus)
252+
token::BinOp(token::Minus)
254253
}
255-
}else{
254+
} else {
256255
token::BinOp(token::Minus)
257256
}
258257
}
@@ -546,8 +545,12 @@ impl<'a> Lexer<'a> {
546545
&self.src[self.src_index(start)..self.src_index(end)]
547546
}
548547

549-
fn has_next_token(&self, start: BytePos, end: BytePos) -> bool{
550-
if self.src_index(start) > self.src_index(end) || self.src_index(end) > self.src.len(){ false }else{ true }
548+
fn has_next_token(&self, start: BytePos, end: BytePos) -> bool {
549+
if self.src_index(start) > self.src_index(end) || self.src_index(end) > self.src.len() {
550+
false
551+
} else {
552+
true
553+
}
551554
}
552555

553556
fn symbol_from_to(&self, start: BytePos, end: BytePos) -> Symbol {

kclvm/parser/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn parse_file(filename: &str, code: Option<String>) -> Result<ast::Module, S
9090
}
9191

9292
/// Parse a source string to a expression. When input empty string, it will return [None].
93-
///
93+
///
9494
/// # Examples
9595
/// ```
9696
/// use kclvm_ast::ast;
@@ -108,7 +108,7 @@ pub fn parse_expr(src: &str) -> Option<ast::NodeRef<ast::Expr>> {
108108
let sm = SourceMap::new(FilePathMapping::empty());
109109
sm.new_source_file(PathBuf::from("").into(), src.to_string());
110110
let sess = &ParseSession::with_source_map(Arc::new(sm));
111-
111+
112112
Some(create_session_globals_then(|| {
113113
let stream = parse_token_streams(sess, src, BytePos::from_u32(0));
114114
let mut parser = Parser::new(sess, stream);

kclvm/parser/src/parser/expr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,8 @@ impl<'a> Parser<'a> {
19921992
let value = match result {
19931993
Some(value) => value,
19941994
None => {
1995-
self.sess.struct_token_error(&[token::LitKind::Integer.into()], token);
1995+
self.sess
1996+
.struct_token_error(&[token::LitKind::Integer.into()], token);
19961997
}
19971998
};
19981999
match lk.suffix {
@@ -2005,7 +2006,8 @@ impl<'a> Parser<'a> {
20052006
let value = match result {
20062007
Ok(value) => value,
20072008
_ => {
2008-
self.sess.struct_token_error(&[token::LitKind::Float.into()], token);
2009+
self.sess
2010+
.struct_token_error(&[token::LitKind::Float.into()], token);
20092011
}
20102012
};
20112013
(None, NumberLitValue::Float(value))

0 commit comments

Comments
 (0)