Skip to content

Commit

Permalink
Prepare for rustfmt 2.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Sep 8, 2020
1 parent 7b1c9da commit 9e90bfb
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 49 deletions.
4 changes: 2 additions & 2 deletions resctl/below/dump/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,14 @@ impl Dump for Cgroup {
}

Ok(())
};
}
let json = self.get_opts().output_format == Some(OutputFormat::Json);
let mut jval = json!({});
output_cgroup(&self, &model.cgroup, output, round, json, &mut jval)?;
match (json, comma_flag) {
(true, true) => write!(output, ",{}", jval)?,
(true, false) => write!(output, "{}", jval)?,
_ => (),
_ => {}
};

Ok(IterExecResult::Success)
Expand Down
2 changes: 1 addition & 1 deletion resctl/below/dump/src/tmain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where
if e.downcast_ref::<std::io::Error>()
.map_or_else(|| false, |e| e.kind() == std::io::ErrorKind::BrokenPipe) =>
{
return Ok(())
return Ok(());
}
Err(e) => return Err(e),
};
Expand Down
2 changes: 1 addition & 1 deletion resctl/below/src/bpf/exitstat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl ExitstatDriver {
loop {
let ret = perf.poll(Duration::from_millis(100));
match ret {
Ok(()) => (),
Ok(()) => {}
Err(e) => {
bail!("Error polling perf buffer: {}", e);
}
Expand Down
27 changes: 16 additions & 11 deletions resctl/below/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn create_log_dir(path: &PathBuf) -> Result<()> {

if !path.is_dir() {
match fs::create_dir_all(path) {
Ok(()) => (),
Ok(()) => {}
Err(e) => {
bail!(
"Failed to create dir {}: {}\nTry sudo.",
Expand All @@ -198,7 +198,7 @@ fn create_log_dir(path: &PathBuf) -> Result<()> {
if perm.mode() & 0o777 != 0o777 {
perm.set_mode(0o777);
match dir.set_permissions(perm) {
Ok(()) => (),
Ok(()) => {}
Err(e) => {
bail!(
"Failed to set permissions on {}: {}",
Expand All @@ -223,7 +223,7 @@ fn start_exitstat(
let (bpf_err_send, bpf_err_recv) = channel();
thread::spawn(move || {
match exit_driver.drive() {
Ok(_) => (),
Ok(_) => {}
Err(e) => bpf_err_send.send(e).unwrap(),
};
});
Expand All @@ -237,7 +237,7 @@ fn check_for_exitstat_errors(logger: &slog::Logger, receiver: &Receiver<Error>)
// be sure what kind of kernel we're running on and if it's new enough.
match receiver.try_recv() {
Ok(e) => error!(logger, "{}", e),
Err(TryRecvError::Empty) => (),
Err(TryRecvError::Empty) => {}
Err(TryRecvError::Disconnected) => {
warn!(logger, "bpf error channel disconnected");
return true;
Expand Down Expand Up @@ -460,12 +460,17 @@ fn replay(
// this should have no effect.
advance.initialize();
let mut view = match advance.advance(store::Direction::Forward) {
Some(model) => view::View::new_with_advance(model, view::ViewMode::Replay(Rc::new(RefCell::new(advance)))),
None => return Err(anyhow!(
"No initial model could be found!\n\
Some(model) => view::View::new_with_advance(
model,
view::ViewMode::Replay(Rc::new(RefCell::new(advance))),
),
None => {
return Err(anyhow!(
"No initial model could be found!\n\
You may have provided a time in the future or no data was recorded during the provided time.\n\
Please check your input and timezone."
)),
));
}
};
view.register_replay_event();
logutil::set_current_log_target(logutil::TargetLog::File);
Expand Down Expand Up @@ -497,7 +502,7 @@ fn record(
// Anything that comes over the error channel is an error
match errs.try_recv() {
Ok(e) => bail!(e),
Err(TryRecvError::Empty) => (),
Err(TryRecvError::Empty) => {}
Err(TryRecvError::Disconnected) => bail!("error channel disconnected"),
};

Expand Down Expand Up @@ -558,7 +563,7 @@ fn live_local(logger: slog::Logger, interval: Duration, debug: bool, dir: PathBu
&e
);
}
_ => (),
_ => {}
};

let (exit_buffer, bpf_errs) = start_exitstat(logger.clone(), debug);
Expand Down Expand Up @@ -636,7 +641,7 @@ fn live_remote(
if let view::ViewMode::LiveRemote(adv) = view_state.mode.clone() {
match adv.borrow_mut().advance(store::Direction::Forward) {
Some(data) => view_state.update(data),
None => (),
None => {}
}
}
});
Expand Down
9 changes: 6 additions & 3 deletions resctl/below/src/test/test_decorators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ fn test_bdecor_interleave() {
string_lines += line.source();
string_lines += "\n";
}
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");
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"
);
}

#[test]
Expand All @@ -240,7 +243,7 @@ fn compound_decorator() {
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
};
}

struct FakeTermIO(Sender<bool>);
impl io::Write for FakeTermIO {
Expand All @@ -259,7 +262,7 @@ fn compound_decorator() {
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
};
}

let (ftx, frx) = channel::<bool>();
let (ttx, trx) = channel::<bool>();
Expand Down
8 changes: 4 additions & 4 deletions resctl/below/store/src/advance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Advance {
self.last_sample = Some(dataframe.sample);
self.last_sample_time = timestamp;
}
Ok(None) => (),
Ok(None) => {}
Err(e) => {
error!(self.logger, "{}", e.context("Failed to load from store"));
}
Expand All @@ -104,7 +104,7 @@ impl Advance {
self.last_sample_time = SystemTime::now() - Duration::from_secs(1);
match self.advance(crate::Direction::Forward) {
Some(model) => return Some(model),
None => (),
None => {}
}
// Otherwise, we get the previous sample.
self.last_sample_time = SystemTime::now();
Expand All @@ -115,7 +115,7 @@ impl Advance {
self.last_sample_time += duration.into();
match self.advance(Direction::Forward) {
Some(model) => return Some(model),
None => (),
None => {}
}

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

// If sample is not available, get the earlist sample
Expand Down
2 changes: 1 addition & 1 deletion resctl/below/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub fn read_next_sample<P: AsRef<Path>>(
return Err(e).context(format!(
"Failed while opening data file {}",
data_path.display()
))
));
}
};

Expand Down
2 changes: 1 addition & 1 deletion resctl/below/view/src/cgroup_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl CgroupView {
view.get_detail_view().selection(),
) {
(false, Some(selection)) => cmd_palette.set_info(selection.to_string()),
_ => (),
_ => {}
}
}

Expand Down
4 changes: 2 additions & 2 deletions resctl/below/view/src/jump_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn advance_helper(
// This will be unlikely to happen: Only if there's no recorded data.
// But when execution reaches here, there should be at least one sample. So
// silently doing nothing.
None => (),
None => {}
},
(Ok(d), Direction::Reverse) => match adv.borrow_mut().jump_sample_backward(d) {
Some(data) => c
Expand All @@ -57,7 +57,7 @@ fn advance_helper(
// This will be unlikely to happen: Only if there's no recorded data.
// But when execution reaches here, there should be at least one sample. So
// silently doing nothing.
None => (),
None => {}
},
_ => match dateutil::HgTime::parse(input) {
// Jump for absolute time
Expand Down
12 changes: 6 additions & 6 deletions resctl/below/view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl View {
println!("Demacia");
c.add_layer(jump_popup::new(adv, Direction::Forward));
}
_ => (),
_ => {}
}
});

Expand All @@ -274,7 +274,7 @@ impl View {
ViewMode::Pause(adv) | ViewMode::Replay(adv) => {
c.add_layer(jump_popup::new(adv, Direction::Reverse));
}
_ => (),
_ => {}
}
});
}
Expand All @@ -288,7 +288,7 @@ impl View {
let mut adv = adv.borrow_mut();
advance!(c, adv, Direction::Forward);
}
_ => (),
_ => {}
}
});

Expand All @@ -300,7 +300,7 @@ impl View {
let mut adv = adv.borrow_mut();
advance!(c, adv, Direction::Reverse);
}
_ => (),
_ => {}
}
});
self.register_jump_event();
Expand Down Expand Up @@ -332,7 +332,7 @@ impl View {
view_state.mode = ViewMode::LiveRemote(adv.clone());
}
ViewMode::LiveRemote(adv) => view_state.mode = ViewMode::Pause(adv.clone()),
_ => (),
_ => {}
}
refresh(c);
});
Expand Down Expand Up @@ -527,7 +527,7 @@ impl View {
.expect("Failed to find cgroup view");
(*stack.get_mut()).move_to_front(cgroup_pos);
}
MainViewState::Core => (),
MainViewState::Core => {}
}
},
)
Expand Down
2 changes: 1 addition & 1 deletion resctl/below/view/src/process_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl ProcessView {
});
cmd_palette.set_info(cgroup.to_string())
}
_ => (),
_ => {}
}
}

Expand Down
20 changes: 10 additions & 10 deletions resctl/common/cgroupfs/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn test_memory_current_parse_failure() {
.read_memory_current()
.expect_err("Did not fail to read memory.current");
match err {
Error::UnexpectedLine(_, _) => (),
Error::UnexpectedLine(_, _) => {}
_ => panic!("Got unexpected error type {}", err),
}
}
Expand All @@ -108,7 +108,7 @@ fn test_memory_current_invalid_format() {
.read_memory_current()
.expect_err("Did not fail to read memory.current");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type {}", err),
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ fn test_memory_stat_parse_failure() {
.read_memory_stat()
.expect_err("Did not fail to read memory.stat");
match err {
Error::UnexpectedLine(_, _) => (),
Error::UnexpectedLine(_, _) => {}
_ => panic!("Got unexpected error type {}", err),
}
}
Expand All @@ -217,7 +217,7 @@ fn test_memory_stat_invalid_format() {
.read_memory_stat()
.expect_err("Did not fail to read memory.stat");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type: {}", err),
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ fn test_cpu_stat_parse_failure() {
.read_cpu_stat()
.expect_err("Did not fail to read cpu.stat");
match err {
Error::UnexpectedLine(_, _) => (),
Error::UnexpectedLine(_, _) => {}
_ => panic!("Got unexpected error type {}", err),
}
}
Expand All @@ -262,7 +262,7 @@ fn test_cpu_stat_invalid_format() {
.read_cpu_stat()
.expect_err("Did not fail to read cpu.stat");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type: {}", err),
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ fn test_io_stat_parse_failure() {
.read_io_stat()
.expect_err("Did not fail to read io.stat");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type {}", err),
}
}
Expand Down Expand Up @@ -343,7 +343,7 @@ fn test_cpu_pressure_empty_file() {
.read_cpu_pressure()
.expect_err("Did not fail to read cpu.pressure");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type: {}", err),
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ fn test_io_pressure_empty_file() {
.read_io_pressure()
.expect_err("Did not fail to read io.pressure");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type: {}", err),
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ fn test_memory_pressure_empty_file() {
.read_memory_pressure()
.expect_err("Did not fail to read memory.pressure");
match err {
Error::InvalidFileFormat(_) => (),
Error::InvalidFileFormat(_) => {}
_ => panic!("Got unexpected error type: {}", err),
}
}
Expand Down
Loading

0 comments on commit 9e90bfb

Please sign in to comment.