Skip to content

Commit 2458180

Browse files
committed
Auto merge of #6602 - k-nasa:fix_fmt, r=dwijnand
$cargo fmt --all It is just PR using the rustfmt command. I have nothing to do with this PR, but do not you introduce format checks by clippy or rustfmt into CI?
2 parents e86afe2 + db09895 commit 2458180

File tree

15 files changed

+79
-70
lines changed

15 files changed

+79
-70
lines changed

src/bin/cargo/commands/rustdoc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ the `cargo help pkgid` command.
5050

5151
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5252
let ws = args.workspace(config)?;
53-
let mut compile_opts =
54-
args.compile_options_for_single_package(config, CompileMode::Doc { deps: false }, Some(&ws))?;
53+
let mut compile_opts = args.compile_options_for_single_package(
54+
config,
55+
CompileMode::Doc { deps: false },
56+
Some(&ws),
57+
)?;
5558
let target_args = values(args, "args");
5659
compile_opts.target_rustdoc_args = if target_args.is_empty() {
5760
None

src/cargo/core/source/source_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::fmt::{self, Formatter};
44
use std::hash::{self, Hash};
55
use std::path::Path;
66
use std::ptr;
7-
use std::sync::atomic::Ordering::SeqCst;
87
use std::sync::atomic::AtomicBool;
8+
use std::sync::atomic::Ordering::SeqCst;
99
use std::sync::Mutex;
1010

1111
use log::trace;

src/cargo/ops/cargo_new.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
22
use std::env;
33
use std::fmt;
44
use std::fs;
5-
use std::io::{BufReader, BufRead, ErrorKind};
5+
use std::io::{BufRead, BufReader, ErrorKind};
66
use std::path::{Path, PathBuf};
77

88
use git2::Config as GitConfig;
@@ -410,7 +410,6 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
410410
Ok(())
411411
}
412412

413-
414413
/// IgnoreList
415414
struct IgnoreList {
416415
/// git like formatted entries
@@ -428,7 +427,7 @@ impl IgnoreList {
428427
}
429428
}
430429

431-
/// add a new entry to the ignore list. Requires two arguments with the
430+
/// add a new entry to the ignore list. Requires two arguments with the
432431
/// entry in two different formats. One for "git style" entries and one for
433432
/// "mercurial like" entries.
434433
fn push(&mut self, ignore: &str, hg_ignore: &str) {
@@ -451,23 +450,23 @@ impl IgnoreList {
451450
/// file.
452451
fn format_existing<T: BufRead>(&self, existing: T, vcs: VersionControl) -> String {
453452
// TODO: is unwrap safe?
454-
let existing_items = existing.lines().collect::<Result<Vec<_>, _>>().unwrap();
453+
let existing_items = existing.lines().collect::<Result<Vec<_>, _>>().unwrap();
455454

456-
let ignore_items = match vcs {
457-
VersionControl::Hg => &self.hg_ignore,
458-
_ => &self.ignore,
455+
let ignore_items = match vcs {
456+
VersionControl::Hg => &self.hg_ignore,
457+
_ => &self.ignore,
459458
};
460459

461460
let mut out = "\n\n#Added by cargo\n\
462-
#\n\
463-
#already existing elements are commented out\n".
464-
to_string();
461+
#\n\
462+
#already existing elements are commented out\n"
463+
.to_string();
465464

466465
for item in ignore_items {
467466
out.push('\n');
468467
if existing_items.contains(item) {
469468
out.push('#');
470-
}
469+
}
471470
out.push_str(item)
472471
}
473472

@@ -478,25 +477,25 @@ impl IgnoreList {
478477
/// write the ignore file to the given directory. If the ignore file for the
479478
/// given vcs system already exists, its content is read and duplicate ignore
480479
/// file entries are filtered out.
481-
fn write_ignore_file(base_path: &Path, list: &IgnoreList, vcs: VersionControl) -> CargoResult<String>{
480+
fn write_ignore_file(
481+
base_path: &Path,
482+
list: &IgnoreList,
483+
vcs: VersionControl,
484+
) -> CargoResult<String> {
482485
let fp_ignore = match vcs {
483486
VersionControl::Git => base_path.join(".gitignore"),
484-
VersionControl::Hg => base_path.join(".hgignore"),
485-
VersionControl::Pijul => base_path.join(".ignore"),
487+
VersionControl::Hg => base_path.join(".hgignore"),
488+
VersionControl::Pijul => base_path.join(".ignore"),
486489
VersionControl::Fossil => return Ok("".to_string()),
487-
VersionControl::NoVcs => return Ok("".to_string()),
490+
VersionControl::NoVcs => return Ok("".to_string()),
488491
};
489492

490493
let ignore: String = match fs::File::open(&fp_ignore) {
491-
Err(why) => {
492-
match why.kind() {
493-
ErrorKind::NotFound => list.format_new(vcs),
494-
_ => return Err(failure::format_err!("{}", why)),
495-
}
496-
},
497-
Ok(file) => {
498-
list.format_existing(BufReader::new(file), vcs)
494+
Err(why) => match why.kind() {
495+
ErrorKind::NotFound => list.format_new(vcs),
496+
_ => return Err(failure::format_err!("{}", why)),
499497
},
498+
Ok(file) => list.format_existing(BufReader::new(file), vcs),
500499
};
501500

502501
paths::append(&fp_ignore, ignore.as_bytes())?;
@@ -540,7 +539,6 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
540539
let name = opts.name;
541540
let cfg = global_config(config)?;
542541

543-
544542
// using the push method with two arguments ensures that the entries for
545543
// both ignore and hgignore are in sync.
546544
let mut ignore = IgnoreList::new();
@@ -562,7 +560,6 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
562560
init_vcs(path, vcs, config)?;
563561
write_ignore_file(path, &ignore, vcs)?;
564562

565-
566563
let (author_name, email) = discover_author()?;
567564
// Hoo boy, sure glad we've got exhaustiveness checking behind us.
568565
let author = match (cfg.name, cfg.email, author_name, email) {

src/cargo/util/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ pub fn process_error(
337337

338338
#[cfg(windows)]
339339
fn status_to_string(status: ExitStatus) -> String {
340-
use winapi::um::winnt::*;
341340
use winapi::shared::minwindef::DWORD;
341+
use winapi::um::winnt::*;
342342

343343
let mut base = status.to_string();
344344
let extra = match status.code().unwrap() as DWORD {

src/cargo/util/process_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct ProcessBuilder {
2828
/// [jobserver_docs]: https://docs.rs/jobserver/0.1.6/jobserver/
2929
jobserver: Option<Client>,
3030
/// Whether to include environment variable in display
31-
display_env_vars: bool
31+
display_env_vars: bool,
3232
}
3333

3434
impl fmt::Display for ProcessBuilder {

src/cargo/util/toml/targets.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ fn toml_targets_and_inferred(
661661

662662
let autodiscover = match autodiscover {
663663
Some(autodiscover) => autodiscover,
664-
None =>
664+
None => {
665665
if edition == Edition::Edition2015 {
666666
if !rem_targets.is_empty() {
667667
let mut rem_targets_str = String::new();
@@ -696,6 +696,7 @@ https://github.com/rust-lang/cargo/issues/5330",
696696
} else {
697697
true
698698
}
699+
}
699700
};
700701

701702
if autodiscover {

tests/testsuite/alt_registry.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,9 +1118,7 @@ fn unknown_registry() {
11181118
.file("src/main.rs", "fn main() {}")
11191119
.build();
11201120

1121-
Package::new("baz", "0.0.1")
1122-
.alternative(true)
1123-
.publish();
1121+
Package::new("baz", "0.0.1").alternative(true).publish();
11241122
Package::new("bar", "0.0.1")
11251123
.registry_dep("baz", "0.0.1")
11261124
.publish();
@@ -1134,16 +1132,15 @@ fn unknown_registry() {
11341132
config.insert(start + start_index, '#');
11351133
fs::write(&cfg_path, config).unwrap();
11361134

1137-
p.cargo("build")
1138-
.masquerade_as_nightly_cargo()
1139-
.run();
1135+
p.cargo("build").masquerade_as_nightly_cargo().run();
11401136

11411137
// Important parts:
11421138
// foo -> bar registry = null
11431139
// bar -> baz registry = alternate
11441140
p.cargo("metadata --format-version=1")
11451141
.masquerade_as_nightly_cargo()
1146-
.with_json(r#"
1142+
.with_json(
1143+
r#"
11471144
{
11481145
"packages": [
11491146
{
@@ -1244,6 +1241,7 @@ fn unknown_registry() {
12441241
"version": 1,
12451242
"workspace_root": "[..]/foo"
12461243
}
1247-
"#)
1244+
"#,
1245+
)
12481246
.run();
12491247
}

tests/testsuite/build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,11 +1584,10 @@ fn vv_prints_rustc_env_vars() {
15841584
r#"[RUNNING] `[..]set CARGO_PKG_AUTHORS="escape='\"@example.com"&& [..]rustc [..]`"#
15851585
)
15861586
} else {
1587-
b.with_stderr_contains(
1588-
"[RUNNING] `[..]CARGO_PKG_NAME=foo [..]rustc [..]`"
1589-
).with_stderr_contains(
1590-
r#"[RUNNING] `[..]CARGO_PKG_AUTHORS='escape='\''"@example.com' [..]rustc [..]`"#
1591-
)
1587+
b.with_stderr_contains("[RUNNING] `[..]CARGO_PKG_NAME=foo [..]rustc [..]`")
1588+
.with_stderr_contains(
1589+
r#"[RUNNING] `[..]CARGO_PKG_AUTHORS='escape='\''"@example.com' [..]rustc [..]`"#,
1590+
)
15921591
};
15931592

15941593
b.run();

tests/testsuite/fix.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,14 @@ fn fix_to_broken_code() {
12631263
fn fix_with_common() {
12641264
let p = project()
12651265
.file("src/lib.rs", "")
1266-
.file("tests/t1.rs", "mod common; #[test] fn t1() { common::try(); }")
1267-
.file("tests/t2.rs", "mod common; #[test] fn t2() { common::try(); }")
1266+
.file(
1267+
"tests/t1.rs",
1268+
"mod common; #[test] fn t1() { common::try(); }",
1269+
)
1270+
.file(
1271+
"tests/t2.rs",
1272+
"mod common; #[test] fn t2() { common::try(); }",
1273+
)
12681274
.file("tests/common/mod.rs", "pub fn try() {}")
12691275
.build();
12701276

tests/testsuite/init.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ fn simple_git_ignore_exists() {
4949
// write a .gitignore file with one entry
5050
fs::create_dir_all(paths::root().join("foo")).unwrap();
5151
let mut ignore_file = File::create(paths::root().join("foo/.gitignore")).unwrap();
52-
ignore_file.write("/target\n**/some.file".as_bytes()).unwrap();
52+
ignore_file
53+
.write("/target\n**/some.file".as_bytes())
54+
.unwrap();
5355

5456
cargo_process("init --lib foo --edition 2015")
5557
.env("USER", "foo")
@@ -70,14 +72,14 @@ fn simple_git_ignore_exists() {
7072
assert_eq!(
7173
contents,
7274
"/target\n\
73-
**/some.file\n\n\
74-
#Added by cargo\n\
75-
#\n\
76-
#already existing elements are commented out\n\
77-
\n\
78-
#/target\n\
79-
**/*.rs.bk\n\
80-
Cargo.lock",
75+
**/some.file\n\n\
76+
#Added by cargo\n\
77+
#\n\
78+
#already existing elements are commented out\n\
79+
\n\
80+
#/target\n\
81+
**/*.rs.bk\n\
82+
Cargo.lock",
8183
);
8284

8385
cargo_process("build").cwd(&paths::root().join("foo")).run();

0 commit comments

Comments
 (0)