Skip to content

Commit 9e90bfb

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Prepare for rustfmt 2.0
Summary: Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14). This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade. --- *Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch. --- Reviewed By: zertosh Differential Revision: D23568787 fbshipit-source-id: 4f0a79389143369493564dde4233566d3574c86f
1 parent 7b1c9da commit 9e90bfb

File tree

13 files changed

+57
-49
lines changed

13 files changed

+57
-49
lines changed

resctl/below/dump/src/cgroup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,14 @@ impl Dump for Cgroup {
640640
}
641641

642642
Ok(())
643-
};
643+
}
644644
let json = self.get_opts().output_format == Some(OutputFormat::Json);
645645
let mut jval = json!({});
646646
output_cgroup(&self, &model.cgroup, output, round, json, &mut jval)?;
647647
match (json, comma_flag) {
648648
(true, true) => write!(output, ",{}", jval)?,
649649
(true, false) => write!(output, "{}", jval)?,
650-
_ => (),
650+
_ => {}
651651
};
652652

653653
Ok(IterExecResult::Success)

resctl/below/dump/src/tmain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ where
151151
if e.downcast_ref::<std::io::Error>()
152152
.map_or_else(|| false, |e| e.kind() == std::io::ErrorKind::BrokenPipe) =>
153153
{
154-
return Ok(())
154+
return Ok(());
155155
}
156156
Err(e) => return Err(e),
157157
};

resctl/below/src/bpf/exitstat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl ExitstatDriver {
159159
loop {
160160
let ret = perf.poll(Duration::from_millis(100));
161161
match ret {
162-
Ok(()) => (),
162+
Ok(()) => {}
163163
Err(e) => {
164164
bail!("Error polling perf buffer: {}", e);
165165
}

resctl/below/src/main.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn create_log_dir(path: &PathBuf) -> Result<()> {
181181

182182
if !path.is_dir() {
183183
match fs::create_dir_all(path) {
184-
Ok(()) => (),
184+
Ok(()) => {}
185185
Err(e) => {
186186
bail!(
187187
"Failed to create dir {}: {}\nTry sudo.",
@@ -198,7 +198,7 @@ fn create_log_dir(path: &PathBuf) -> Result<()> {
198198
if perm.mode() & 0o777 != 0o777 {
199199
perm.set_mode(0o777);
200200
match dir.set_permissions(perm) {
201-
Ok(()) => (),
201+
Ok(()) => {}
202202
Err(e) => {
203203
bail!(
204204
"Failed to set permissions on {}: {}",
@@ -223,7 +223,7 @@ fn start_exitstat(
223223
let (bpf_err_send, bpf_err_recv) = channel();
224224
thread::spawn(move || {
225225
match exit_driver.drive() {
226-
Ok(_) => (),
226+
Ok(_) => {}
227227
Err(e) => bpf_err_send.send(e).unwrap(),
228228
};
229229
});
@@ -237,7 +237,7 @@ fn check_for_exitstat_errors(logger: &slog::Logger, receiver: &Receiver<Error>)
237237
// be sure what kind of kernel we're running on and if it's new enough.
238238
match receiver.try_recv() {
239239
Ok(e) => error!(logger, "{}", e),
240-
Err(TryRecvError::Empty) => (),
240+
Err(TryRecvError::Empty) => {}
241241
Err(TryRecvError::Disconnected) => {
242242
warn!(logger, "bpf error channel disconnected");
243243
return true;
@@ -460,12 +460,17 @@ fn replay(
460460
// this should have no effect.
461461
advance.initialize();
462462
let mut view = match advance.advance(store::Direction::Forward) {
463-
Some(model) => view::View::new_with_advance(model, view::ViewMode::Replay(Rc::new(RefCell::new(advance)))),
464-
None => return Err(anyhow!(
465-
"No initial model could be found!\n\
463+
Some(model) => view::View::new_with_advance(
464+
model,
465+
view::ViewMode::Replay(Rc::new(RefCell::new(advance))),
466+
),
467+
None => {
468+
return Err(anyhow!(
469+
"No initial model could be found!\n\
466470
You may have provided a time in the future or no data was recorded during the provided time.\n\
467471
Please check your input and timezone."
468-
)),
472+
));
473+
}
469474
};
470475
view.register_replay_event();
471476
logutil::set_current_log_target(logutil::TargetLog::File);
@@ -497,7 +502,7 @@ fn record(
497502
// Anything that comes over the error channel is an error
498503
match errs.try_recv() {
499504
Ok(e) => bail!(e),
500-
Err(TryRecvError::Empty) => (),
505+
Err(TryRecvError::Empty) => {}
501506
Err(TryRecvError::Disconnected) => bail!("error channel disconnected"),
502507
};
503508

@@ -558,7 +563,7 @@ fn live_local(logger: slog::Logger, interval: Duration, debug: bool, dir: PathBu
558563
&e
559564
);
560565
}
561-
_ => (),
566+
_ => {}
562567
};
563568

564569
let (exit_buffer, bpf_errs) = start_exitstat(logger.clone(), debug);
@@ -636,7 +641,7 @@ fn live_remote(
636641
if let view::ViewMode::LiveRemote(adv) = view_state.mode.clone() {
637642
match adv.borrow_mut().advance(store::Direction::Forward) {
638643
Some(data) => view_state.update(data),
639-
None => (),
644+
None => {}
640645
}
641646
}
642647
});

resctl/below/src/test/test_decorators.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ fn test_bdecor_interleave() {
214214
string_lines += line.source();
215215
string_lines += "\n";
216216
}
217-
assert_eq!(string_lines, "Usage : 12.6% \nUser : 1.1% \nSystem : 2.2% \nL1 Cach: -->10\nField A: 1.1 \nField B : 2.2 \nAggr : 3.30 \n");
217+
assert_eq!(
218+
string_lines,
219+
"Usage : 12.6% \nUser : 1.1% \nSystem : 2.2% \nL1 Cach: -->10\nField A: 1.1 \nField B : 2.2 \nAggr : 3.30 \n"
220+
);
218221
}
219222

220223
#[test]
@@ -240,7 +243,7 @@ fn compound_decorator() {
240243
fn flush(&mut self) -> io::Result<()> {
241244
Ok(())
242245
}
243-
};
246+
}
244247

245248
struct FakeTermIO(Sender<bool>);
246249
impl io::Write for FakeTermIO {
@@ -259,7 +262,7 @@ fn compound_decorator() {
259262
fn flush(&mut self) -> io::Result<()> {
260263
Ok(())
261264
}
262-
};
265+
}
263266

264267
let (ftx, frx) = channel::<bool>();
265268
let (ttx, trx) = channel::<bool>();

resctl/below/store/src/advance.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Advance {
7878
self.last_sample = Some(dataframe.sample);
7979
self.last_sample_time = timestamp;
8080
}
81-
Ok(None) => (),
81+
Ok(None) => {}
8282
Err(e) => {
8383
error!(self.logger, "{}", e.context("Failed to load from store"));
8484
}
@@ -104,7 +104,7 @@ impl Advance {
104104
self.last_sample_time = SystemTime::now() - Duration::from_secs(1);
105105
match self.advance(crate::Direction::Forward) {
106106
Some(model) => return Some(model),
107-
None => (),
107+
None => {}
108108
}
109109
// Otherwise, we get the previous sample.
110110
self.last_sample_time = SystemTime::now();
@@ -115,7 +115,7 @@ impl Advance {
115115
self.last_sample_time += duration.into();
116116
match self.advance(Direction::Forward) {
117117
Some(model) => return Some(model),
118-
None => (),
118+
None => {}
119119
}
120120

121121
// If sample is not available, get the latest sample
@@ -127,7 +127,7 @@ impl Advance {
127127
self.last_sample_time -= duration.into();
128128
match self.advance(Direction::Reverse) {
129129
Some(model) => return Some(model),
130-
None => (),
130+
None => {}
131131
}
132132

133133
// If sample is not available, get the earlist sample

resctl/below/store/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub fn read_next_sample<P: AsRef<Path>>(
408408
return Err(e).context(format!(
409409
"Failed while opening data file {}",
410410
data_path.display()
411-
))
411+
));
412412
}
413413
};
414414

resctl/below/view/src/cgroup_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl CgroupView {
230230
view.get_detail_view().selection(),
231231
) {
232232
(false, Some(selection)) => cmd_palette.set_info(selection.to_string()),
233-
_ => (),
233+
_ => {}
234234
}
235235
}
236236

resctl/below/view/src/jump_popup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn advance_helper(
4747
// This will be unlikely to happen: Only if there's no recorded data.
4848
// But when execution reaches here, there should be at least one sample. So
4949
// silently doing nothing.
50-
None => (),
50+
None => {}
5151
},
5252
(Ok(d), Direction::Reverse) => match adv.borrow_mut().jump_sample_backward(d) {
5353
Some(data) => c
@@ -57,7 +57,7 @@ fn advance_helper(
5757
// This will be unlikely to happen: Only if there's no recorded data.
5858
// But when execution reaches here, there should be at least one sample. So
5959
// silently doing nothing.
60-
None => (),
60+
None => {}
6161
},
6262
_ => match dateutil::HgTime::parse(input) {
6363
// Jump for absolute time

resctl/below/view/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl View {
259259
println!("Demacia");
260260
c.add_layer(jump_popup::new(adv, Direction::Forward));
261261
}
262-
_ => (),
262+
_ => {}
263263
}
264264
});
265265

@@ -274,7 +274,7 @@ impl View {
274274
ViewMode::Pause(adv) | ViewMode::Replay(adv) => {
275275
c.add_layer(jump_popup::new(adv, Direction::Reverse));
276276
}
277-
_ => (),
277+
_ => {}
278278
}
279279
});
280280
}
@@ -288,7 +288,7 @@ impl View {
288288
let mut adv = adv.borrow_mut();
289289
advance!(c, adv, Direction::Forward);
290290
}
291-
_ => (),
291+
_ => {}
292292
}
293293
});
294294

@@ -300,7 +300,7 @@ impl View {
300300
let mut adv = adv.borrow_mut();
301301
advance!(c, adv, Direction::Reverse);
302302
}
303-
_ => (),
303+
_ => {}
304304
}
305305
});
306306
self.register_jump_event();
@@ -332,7 +332,7 @@ impl View {
332332
view_state.mode = ViewMode::LiveRemote(adv.clone());
333333
}
334334
ViewMode::LiveRemote(adv) => view_state.mode = ViewMode::Pause(adv.clone()),
335-
_ => (),
335+
_ => {}
336336
}
337337
refresh(c);
338338
});
@@ -527,7 +527,7 @@ impl View {
527527
.expect("Failed to find cgroup view");
528528
(*stack.get_mut()).move_to_front(cgroup_pos);
529529
}
530-
MainViewState::Core => (),
530+
MainViewState::Core => {}
531531
}
532532
},
533533
)

resctl/below/view/src/process_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl ProcessView {
217217
});
218218
cmd_palette.set_info(cgroup.to_string())
219219
}
220-
_ => (),
220+
_ => {}
221221
}
222222
}
223223

resctl/common/cgroupfs/src/test.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn test_memory_current_parse_failure() {
9393
.read_memory_current()
9494
.expect_err("Did not fail to read memory.current");
9595
match err {
96-
Error::UnexpectedLine(_, _) => (),
96+
Error::UnexpectedLine(_, _) => {}
9797
_ => panic!("Got unexpected error type {}", err),
9898
}
9999
}
@@ -108,7 +108,7 @@ fn test_memory_current_invalid_format() {
108108
.read_memory_current()
109109
.expect_err("Did not fail to read memory.current");
110110
match err {
111-
Error::InvalidFileFormat(_) => (),
111+
Error::InvalidFileFormat(_) => {}
112112
_ => panic!("Got unexpected error type {}", err),
113113
}
114114
}
@@ -202,7 +202,7 @@ fn test_memory_stat_parse_failure() {
202202
.read_memory_stat()
203203
.expect_err("Did not fail to read memory.stat");
204204
match err {
205-
Error::UnexpectedLine(_, _) => (),
205+
Error::UnexpectedLine(_, _) => {}
206206
_ => panic!("Got unexpected error type {}", err),
207207
}
208208
}
@@ -217,7 +217,7 @@ fn test_memory_stat_invalid_format() {
217217
.read_memory_stat()
218218
.expect_err("Did not fail to read memory.stat");
219219
match err {
220-
Error::InvalidFileFormat(_) => (),
220+
Error::InvalidFileFormat(_) => {}
221221
_ => panic!("Got unexpected error type: {}", err),
222222
}
223223
}
@@ -247,7 +247,7 @@ fn test_cpu_stat_parse_failure() {
247247
.read_cpu_stat()
248248
.expect_err("Did not fail to read cpu.stat");
249249
match err {
250-
Error::UnexpectedLine(_, _) => (),
250+
Error::UnexpectedLine(_, _) => {}
251251
_ => panic!("Got unexpected error type {}", err),
252252
}
253253
}
@@ -262,7 +262,7 @@ fn test_cpu_stat_invalid_format() {
262262
.read_cpu_stat()
263263
.expect_err("Did not fail to read cpu.stat");
264264
match err {
265-
Error::InvalidFileFormat(_) => (),
265+
Error::InvalidFileFormat(_) => {}
266266
_ => panic!("Got unexpected error type: {}", err),
267267
}
268268
}
@@ -298,7 +298,7 @@ fn test_io_stat_parse_failure() {
298298
.read_io_stat()
299299
.expect_err("Did not fail to read io.stat");
300300
match err {
301-
Error::InvalidFileFormat(_) => (),
301+
Error::InvalidFileFormat(_) => {}
302302
_ => panic!("Got unexpected error type {}", err),
303303
}
304304
}
@@ -343,7 +343,7 @@ fn test_cpu_pressure_empty_file() {
343343
.read_cpu_pressure()
344344
.expect_err("Did not fail to read cpu.pressure");
345345
match err {
346-
Error::InvalidFileFormat(_) => (),
346+
Error::InvalidFileFormat(_) => {}
347347
_ => panic!("Got unexpected error type: {}", err),
348348
}
349349
}
@@ -377,7 +377,7 @@ fn test_io_pressure_empty_file() {
377377
.read_io_pressure()
378378
.expect_err("Did not fail to read io.pressure");
379379
match err {
380-
Error::InvalidFileFormat(_) => (),
380+
Error::InvalidFileFormat(_) => {}
381381
_ => panic!("Got unexpected error type: {}", err),
382382
}
383383
}
@@ -411,7 +411,7 @@ fn test_memory_pressure_empty_file() {
411411
.read_memory_pressure()
412412
.expect_err("Did not fail to read memory.pressure");
413413
match err {
414-
Error::InvalidFileFormat(_) => (),
414+
Error::InvalidFileFormat(_) => {}
415415
_ => panic!("Got unexpected error type: {}", err),
416416
}
417417
}

0 commit comments

Comments
 (0)