Skip to content

Commit a248e50

Browse files
authored
Merge pull request #1259 from Manishearth/rustfmt
Run rustfmt
2 parents 7dd3679 + 4d0864b commit a248e50

File tree

7 files changed

+38
-40
lines changed

7 files changed

+38
-40
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ Cargo.lock
2424

2525
# gh pages docs
2626
util/gh-pages/lints.json
27+
28+
# rustfmt backups
29+
*.rs.bk

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ install:
1717
- nvm install stable
1818
- nvm use stable
1919
- npm install remark-cli remark-lint
20+
# || true, because we cache rustfmt and don't want to crash on the next travis run
21+
# due to rustfmt already being installed
22+
- (cargo install rustfmt || true)
2023

2124
script:
2225
- remark -f README.md > /dev/null
2326
- python util/update_lints.py -c
27+
- PATH=$PATH:~/.cargo/bin cargo fmt -- --write-mode=diff
2428
- set -e
2529
- cargo build --features debugging
2630
- cargo test --features debugging

rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ max_width = 120
22
ideal_width = 100
33
fn_args_density = "Compressed"
44
fn_call_width = 80
5-
fn_args_paren_newline = false
5+
fn_args_paren_newline = false
6+
match_block_trailing_comma = true

src/main.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,17 @@ impl ClippyCompilerCalls {
3838
}
3939

4040
impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
41-
fn early_callback(&mut self,
42-
matches: &getopts::Matches,
43-
sopts: &config::Options,
44-
cfg: &ast::CrateConfig,
45-
descriptions: &rustc_errors::registry::Registry,
46-
output: ErrorOutputType)
41+
fn early_callback(&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig,
42+
descriptions: &rustc_errors::registry::Registry, output: ErrorOutputType)
4743
-> Compilation {
4844
self.default.early_callback(matches, sopts, cfg, descriptions, output)
4945
}
50-
fn no_input(&mut self,
51-
matches: &getopts::Matches,
52-
sopts: &config::Options,
53-
cfg: &ast::CrateConfig,
54-
odir: &Option<PathBuf>,
55-
ofile: &Option<PathBuf>,
56-
descriptions: &rustc_errors::registry::Registry)
46+
fn no_input(&mut self, matches: &getopts::Matches, sopts: &config::Options, cfg: &ast::CrateConfig,
47+
odir: &Option<PathBuf>, ofile: &Option<PathBuf>, descriptions: &rustc_errors::registry::Registry)
5748
-> Option<(Input, Option<PathBuf>)> {
5849
self.default.no_input(matches, sopts, cfg, odir, ofile, descriptions)
5950
}
60-
fn late_callback(&mut self,
61-
matches: &getopts::Matches,
62-
sess: &Session,
63-
input: &Input,
64-
odir: &Option<PathBuf>,
51+
fn late_callback(&mut self, matches: &getopts::Matches, sess: &Session, input: &Input, odir: &Option<PathBuf>,
6552
ofile: &Option<PathBuf>)
6653
-> Compilation {
6754
self.default.late_callback(matches, sess, input, odir, ofile)
@@ -73,7 +60,12 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
7360
let old = std::mem::replace(&mut control.after_parse.callback, box |_| {});
7461
control.after_parse.callback = Box::new(move |state| {
7562
{
76-
let mut registry = rustc_plugin::registry::Registry::new(state.session, state.krate.as_ref().expect("at this compilation stage the krate must be parsed").span);
63+
let mut registry = rustc_plugin::registry::Registry::new(state.session,
64+
state.krate
65+
.as_ref()
66+
.expect("at this compilation stage \
67+
the krate must be parsed")
68+
.span);
7769
registry.args_hidden = Some(Vec::new());
7870
clippy_lints::register_plugins(&mut registry);
7971

@@ -153,7 +145,7 @@ pub fn main() {
153145
if env::var("CLIPPY_DOGFOOD").map(|_| true).unwrap_or(false) {
154146
panic!("yummy");
155147
}
156-
148+
157149
// Check for version and help flags even when invoked as 'cargo-clippy'
158150
if std::env::args().any(|a| a == "--help" || a == "-h") {
159151
show_help();
@@ -184,14 +176,16 @@ pub fn main() {
184176

185177
let current_dir = std::env::current_dir();
186178

187-
let package_index = metadata.packages.iter()
179+
let package_index = metadata.packages
180+
.iter()
188181
.position(|package| {
189182
let package_manifest_path = Path::new(&package.manifest_path);
190183
if let Some(ref manifest_path) = manifest_path {
191184
package_manifest_path == manifest_path
192185
} else {
193186
let current_dir = current_dir.as_ref().expect("could not read current directory");
194-
let package_manifest_directory = package_manifest_path.parent().expect("could not find parent directory of package manifest");
187+
let package_manifest_directory = package_manifest_path.parent()
188+
.expect("could not find parent directory of package manifest");
195189
package_manifest_directory == current_dir
196190
}
197191
})
@@ -205,7 +199,8 @@ pub fn main() {
205199
std::process::exit(code);
206200
}
207201
} else if ["bin", "example", "test", "bench"].contains(&&**first) {
208-
if let Err(code) = process(vec![format!("--{}", first), target.name].into_iter().chain(args), &dep_path) {
202+
if let Err(code) = process(vec![format!("--{}", first), target.name].into_iter().chain(args),
203+
&dep_path) {
209204
std::process::exit(code);
210205
}
211206
}
@@ -285,8 +280,10 @@ fn process<P, I>(old_args: I, dep_path: P) -> Result<(), i32>
285280
let exit_status = std::process::Command::new("cargo")
286281
.args(&args)
287282
.env("RUSTC", path)
288-
.spawn().expect("could not run cargo")
289-
.wait().expect("failed to wait for cargo?");
283+
.spawn()
284+
.expect("could not run cargo")
285+
.wait()
286+
.expect("failed to wait for cargo?");
290287

291288
if exit_status.success() {
292289
Ok(())

tests/ice_exacte_size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ impl Iterator for Foo {
1414
}
1515
}
1616

17-
impl ExactSizeIterator for Foo { }
17+
impl ExactSizeIterator for Foo {}

tests/issue-825.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@
55

66
// this should compile in a reasonable amount of time
77
fn rust_type_id(name: String) {
8-
if "bool" == &name[..] ||
9-
"uint" == &name[..] ||
10-
"u8" == &name[..] ||
11-
"u16" == &name[..] ||
12-
"u32" == &name[..] ||
13-
"f32" == &name[..] ||
14-
"f64" == &name[..] ||
15-
"i8" == &name[..] ||
16-
"i16" == &name[..] ||
17-
"i32" == &name[..] ||
18-
"i64" == &name[..] ||
19-
"Self" == &name[..] ||
20-
"str" == &name[..] {
8+
if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] ||
9+
"u32" == &name[..] || "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] ||
10+
"i16" == &name[..] || "i32" == &name[..] || "i64" == &name[..] ||
11+
"Self" == &name[..] || "str" == &name[..] {
2112
unreachable!();
2213
}
2314
}

tests/trim_multiline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn test_single_line() {
1313
}
1414

1515
#[test]
16+
#[cfg_attr(rustfmt, rustfmt_skip)]
1617
fn test_block() {
1718
assert_eq!("\
1819
if x {
@@ -37,6 +38,7 @@ if x {
3738
}
3839

3940
#[test]
41+
#[cfg_attr(rustfmt, rustfmt_skip)]
4042
fn test_empty_line() {
4143
assert_eq!("\
4244
if x {

0 commit comments

Comments
 (0)