Skip to content

Commit 8200948

Browse files
committed
Enable rustfmt nightly options
1 parent dcbe39e commit 8200948

File tree

16 files changed

+248
-315
lines changed

16 files changed

+248
-315
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"files.associations": {
33
"**/mimex-*.txt": "csv"
44
},
5+
6+
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
7+
58
// "rust-analyzer.cargo.noDefaultFeatures": true,
69
// "rust-analyzer.cargo.features": ["no_std", "serde_alloc"]
710
"rust-analyzer.cargo.features": "all"

rustfmt.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use_field_init_shorthand = true
2+
3+
unstable_features = true
4+
5+
empty_item_single_line = true
6+
group_imports = "StdExternalCrate"
7+
imports_granularity = "Crate"

src/bin/mlogv32.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
#![allow(dead_code)]
22

3-
use std::borrow::Cow;
4-
use std::collections::VecDeque;
5-
use std::io::{Cursor, Read};
6-
use std::sync::mpsc::{self, Receiver, Sender};
7-
use std::thread;
8-
use std::time::Duration;
9-
use std::{error::Error, fmt::Display, fs::File, path::PathBuf, time::Instant};
3+
use std::{
4+
borrow::Cow,
5+
collections::VecDeque,
6+
error::Error,
7+
fmt::Display,
8+
fs::File,
9+
io::{Cursor, Read},
10+
path::PathBuf,
11+
sync::mpsc::{self, Receiver, Sender},
12+
thread,
13+
time::{Duration, Instant},
14+
};
1015

1116
use binrw::{BinRead, BinWrite};
1217
use clap::Parser;
13-
use cursive::theme::Theme;
14-
use cursive::view::{Margins, Nameable, Resizable, ScrollStrategy, SizeConstraint};
15-
use cursive::views::{
16-
Checkbox, EditView, LinearLayout, ListView, PaddedView, Panel, ResizedView, ScrollView,
17-
SliderView, TextContent, TextView,
18+
use cursive::{
19+
theme::Theme,
20+
view::{Margins, Nameable, Resizable, ScrollStrategy, SizeConstraint},
21+
views::{
22+
Checkbox, EditView, LinearLayout, ListView, PaddedView, Panel, ResizedView, ScrollView,
23+
SliderView, TextContent, TextView,
24+
},
1825
};
1926
use indicatif::ProgressIterator;
2027
use itertools::Itertools;
2128
use mindustry_rs::{
22-
types::{Object, PackedPoint2, ProcessorConfig, schematics::Schematic},
29+
types::{Object, PackedPoint2, ProcessorConfig, Schematic},
2330
vm::{
2431
Building, BuildingData, LObject, LValue, LVar, LogicVM, LogicVMBuilder, MEMORY_BANK,
2532
MESSAGE, MICRO_PROCESSOR, SWITCH, WORLD_PROCESSOR,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![no_std]
22

33
extern crate alloc;
4-
54
#[cfg(feature = "std")]
65
extern crate std;
76

src/parser/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloc::{string::String, vec::Vec};
2+
23
use serde::{Deserialize, Serialize};
34

45
use crate::types::{ContentType, LAccess};

src/parser/grammar.lalrpop

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use alloc::{string::String, vec::Vec};
44

55
use super::{ast::*, grammar_util::*};
6-
use crate::types::{colors::{COLORS, to_double_bits}, ContentType, LAccess};
6+
use crate::types::{
7+
ContentType, LAccess,
8+
colors::{COLORS, to_double_bits},
9+
};
710

811
grammar;
912

src/parser/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
pub mod ast;
2-
#[cfg(feature = "std")]
3-
mod grammar_util;
4-
5-
#[cfg(feature = "std")]
6-
lalrpop_util::lalrpop_mod!(
7-
#[allow(deprecated)]
8-
grammar,
9-
"/logic/grammar.rs"
10-
);
11-
12-
#[cfg(feature = "std")]
13-
pub use grammar::LogicParser;
14-
151
#[cfg(feature = "serde_alloc")]
162
use alloc::vec::Vec;
173
#[cfg(feature = "serde_alloc")]
184
use core::error::Error;
195
#[cfg(feature = "std")]
206
use std::{boxed::Box, string::ToString};
217

8+
#[cfg(feature = "std")]
9+
pub use self::grammar::LogicParser;
2210
#[cfg(feature = "std")]
2311
use crate::{
2412
types::{PackedPoint2, content},
2513
vm::{Building, LogicVMBuilder, ProcessorBuilder},
2614
};
2715

16+
pub mod ast;
17+
#[cfg(feature = "std")]
18+
mod grammar_util;
19+
20+
#[cfg(feature = "std")]
21+
lalrpop_util::lalrpop_mod!(
22+
#[allow(deprecated)]
23+
grammar,
24+
"/logic/grammar.rs"
25+
);
26+
2827
#[cfg(feature = "std")]
2928
pub fn parse_and_serialize_ast(
3029
parser: &LogicParser,

src/types/enums.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
use alloc::{format, vec, vec::Vec};
44
use core::hash::Hash;
5-
use serde::{Deserialize, Serialize};
65

76
use binrw::prelude::*;
87
use lazy_static::lazy_static;
8+
use serde::{Deserialize, Serialize};
99
use strum::VariantArray;
1010
use strum_macros::{AsRefStr, IntoStaticStr, VariantArray};
1111
use widestring::{U16Str, U16String};
1212

13-
use crate::utils::leak_u16string;
14-
1513
use super::colors;
14+
use crate::utils::leak_u16string;
1615

1716
#[binrw]
1817
#[brw(big, repr = i8)]

src/types/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
#![allow(deprecated)]
1+
#[cfg(feature = "std")]
2+
pub use self::schematics::*;
3+
pub use self::{enums::*, java::*, logic::*, math::*, type_io::*};
24

35
pub mod colors;
46
pub mod content;
5-
#[cfg(feature = "std")]
6-
pub mod schematics;
7-
87
mod enums;
98
mod java;
109
mod logic;
1110
mod math;
11+
#[cfg(feature = "std")]
12+
mod schematics;
1213
mod type_io;
13-
14-
pub use enums::*;
15-
pub use java::*;
16-
pub use logic::*;
17-
pub use math::*;
18-
pub use type_io::*;

src/types/schematics.rs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,8 @@ mod tests {
201201

202202
use velcro::map_iter_from;
203203

204-
use crate::types::{ContentID, ContentType};
205-
206204
use super::*;
205+
use crate::types::{ContentID, ContentType};
207206

208207
type TestResult = Result<(), Box<dyn Error>>;
209208

@@ -359,15 +358,12 @@ mod tests {
359358
let mut cur = Cursor::new(vec![]);
360359
schem.write(&mut cur)?;
361360
cur.set_position(0);
362-
assert_eq!(
363-
Schematic::read(&mut cur)?,
364-
Schematic {
365-
tags: map_iter_from! { "labels": "[]" }.collect(),
366-
width: 1,
367-
height: 1,
368-
..schem
369-
}
370-
);
361+
assert_eq!(Schematic::read(&mut cur)?, Schematic {
362+
tags: map_iter_from! { "labels": "[]" }.collect(),
363+
width: 1,
364+
height: 1,
365+
..schem
366+
});
371367
Ok(())
372368
}
373369

@@ -384,15 +380,12 @@ mod tests {
384380
let mut cur = Cursor::new(vec![]);
385381
schem.write(&mut cur)?;
386382
cur.set_position(0);
387-
assert_eq!(
388-
Schematic::read(&mut cur)?,
389-
Schematic {
390-
tags: map_iter_from! { "labels": "[]" }.collect(),
391-
width: 1,
392-
height: 1,
393-
..schem
394-
}
395-
);
383+
assert_eq!(Schematic::read(&mut cur)?, Schematic {
384+
tags: map_iter_from! { "labels": "[]" }.collect(),
385+
width: 1,
386+
height: 1,
387+
..schem
388+
});
396389
Ok(())
397390
}
398391

@@ -429,15 +422,12 @@ mod tests {
429422
let mut cur = Cursor::new(vec![]);
430423
schem.write(&mut cur)?;
431424
cur.set_position(0);
432-
assert_eq!(
433-
Schematic::read(&mut cur)?,
434-
Schematic {
435-
tags: map_iter_from! { "labels": "[]" }.collect(),
436-
width: 3,
437-
height: 1,
438-
..schem
439-
}
440-
);
425+
assert_eq!(Schematic::read(&mut cur)?, Schematic {
426+
tags: map_iter_from! { "labels": "[]" }.collect(),
427+
width: 3,
428+
height: 1,
429+
..schem
430+
});
441431
Ok(())
442432
}
443433
}

0 commit comments

Comments
 (0)