Skip to content

Commit 6321ae2

Browse files
Merge #1570
1570: Prepare for clippy and rustfmt in rust-2018 r=jtgeibel a=jtgeibel The first commit includes minor updates recommended by the clippy version which will be released with rust stable tomorrow. In particular it uses the new lint attribute syntax like `#[allow(clippy::too_many_arguments)]`. The second commit applies rustfmt changes. This PR will fail on CI for now, but can be merged after the new stable release is published. Co-authored-by: Justin Geibel <[email protected]>
2 parents 19e1c14 + 854000c commit 6321ae2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+316
-291
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ matrix:
5454
- rustup component add clippy-preview
5555
script:
5656
- cargo fmt -- --check
57-
# TODO: Once clippy:: lint syntax is stable, remove everything after the -- below
58-
- cargo clippy --all-targets -- -A renamed_and_removed_lints
57+
- cargo clippy --all-targets --all-features --all
5958
- cargo build
6059
- cargo test
6160
- npm install

src/bin/delete-crate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
conn.transaction::<_, diesel::result::Error, _>(|| {
2424
delete(&conn);
2525
Ok(())
26-
}).unwrap()
26+
})
27+
.unwrap()
2728
}
2829

2930
fn delete(conn: &PgConnection) {

src/bin/delete-version.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
conn.transaction::<_, diesel::result::Error, _>(|| {
2424
delete(&conn);
2525
Ok(())
26-
}).unwrap()
26+
})
27+
.unwrap()
2728
}
2829

2930
fn delete(conn: &PgConnection) {

src/bin/on_call/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl Event {
3939
.json(&FullEvent {
4040
service_key,
4141
event: self,
42-
}).send()?;
42+
})
43+
.send()?;
4344

4445
match response.status() {
4546
s if s.is_success() => Ok(()),

src/bin/populate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ fn update(conn: &PgConnection) -> QueryResult<()> {
3939
version_downloads::version_id.eq(id),
4040
version_downloads::downloads.eq(dls),
4141
version_downloads::date.eq(date(now - day.days())),
42-
)).execute(conn)?;
42+
))
43+
.execute(conn)?;
4344
}
4445
}
4546
Ok(())

src/bin/render-readmes.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ fn main() {
8181
readme_renderings::rendered_at
8282
.lt(older_than)
8383
.or(readme_renderings::version_id.is_null()),
84-
).select(versions::id)
84+
)
85+
.select(versions::id)
8586
.into_boxed();
8687

8788
if let Some(crate_name) = args.flag_crate {
@@ -150,7 +151,8 @@ fn main() {
150151
&readme_path,
151152
readme.into_bytes(),
152153
"text/html",
153-
).unwrap_or_else(|_| {
154+
)
155+
.unwrap_or_else(|_| {
154156
panic!(
155157
"[{}-{}] Couldn't upload file to S3",
156158
krate_name, version.num
@@ -227,7 +229,8 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
227229
.as_ref()
228230
.map_or("README.md", |e| &**e),
229231
manifest.package.repository.as_ref().map(|e| &**e),
230-
).unwrap_or_else(|_| panic!("[{}-{}] Couldn't render README", krate_name, version.num))
232+
)
233+
.unwrap_or_else(|_| panic!("[{}-{}] Couldn't render README", krate_name, version.num))
231234
};
232235
return Some(rendered);
233236

@@ -261,14 +264,16 @@ fn find_file_by_path<R: Read>(
261264
};
262265
filepath == path
263266
}
264-
}).unwrap_or_else(|| {
267+
})
268+
.unwrap_or_else(|| {
265269
panic!(
266270
"[{}-{}] couldn't open file: {}",
267271
krate_name,
268272
version.num,
269273
path.display()
270274
)
271-
}).unwrap_or_else(|_| {
275+
})
276+
.unwrap_or_else(|_| {
272277
panic!(
273278
"[{}-{}] file is not present: {}",
274279
krate_name,

src/bin/transfer-crates.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ fn main() {
2121
conn.transaction::<_, diesel::result::Error, _>(|| {
2222
transfer(&conn);
2323
Ok(())
24-
}).unwrap()
24+
})
25+
.unwrap()
2526
}
2627

2728
fn transfer(conn: &PgConnection) {

src/bin/update-downloads.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ fn collect(conn: &PgConnection, rows: &[VersionDownload]) -> QueryResult<()> {
9292
crate_downloads::crate_id.eq(crate_id),
9393
crate_downloads::downloads.eq(amt),
9494
crate_downloads::date.eq(download.date),
95-
)).on_conflict(crate_downloads::table.primary_key())
95+
))
96+
.on_conflict(crate_downloads::table.primary_key())
9697
.do_update()
9798
.set(crate_downloads::downloads.eq(crate_downloads::downloads + amt))
9899
.execute(conn)?;
@@ -136,7 +137,8 @@ mod test {
136137
let krate = NewCrate {
137138
name: "foo",
138139
..Default::default()
139-
}.create_or_update(&conn, None, user_id)
140+
}
141+
.create_or_update(&conn, None, user_id)
140142
.unwrap();
141143
let version = NewVersion::new(
142144
krate.id,
@@ -145,7 +147,8 @@ mod test {
145147
None,
146148
None,
147149
0,
148-
).unwrap();
150+
)
151+
.unwrap();
149152
let version = version.save(&conn, &[]).unwrap();
150153
(krate, version)
151154
}
@@ -176,7 +179,8 @@ mod test {
176179
version_downloads::version_id.eq(version.id),
177180
version_downloads::date.eq(date(now - 1.day())),
178181
version_downloads::processed.eq(true),
179-
)).execute(&conn)
182+
))
183+
.execute(&conn)
180184
.unwrap();
181185

182186
::update(&conn).unwrap();
@@ -213,7 +217,8 @@ mod test {
213217
version_downloads::counted.eq(2),
214218
version_downloads::date.eq(date(now - 2.days())),
215219
version_downloads::processed.eq(false),
216-
)).execute(&conn)
220+
))
221+
.execute(&conn)
217222
.unwrap();
218223
::update(&conn).unwrap();
219224
let processed = version_downloads::table
@@ -236,7 +241,8 @@ mod test {
236241
version_downloads::counted.eq(2),
237242
version_downloads::date.eq(date(now)),
238243
version_downloads::processed.eq(false),
239-
)).execute(&conn)
244+
))
245+
.execute(&conn)
240246
.unwrap();
241247
::update(&conn).unwrap();
242248
let processed = version_downloads::table
@@ -269,13 +275,15 @@ mod test {
269275
version_downloads::counted.eq(1),
270276
version_downloads::date.eq(date(now)),
271277
version_downloads::processed.eq(false),
272-
)).execute(&conn)
278+
))
279+
.execute(&conn)
273280
.unwrap();
274281
insert_into(version_downloads::table)
275282
.values((
276283
version_downloads::version_id.eq(version.id),
277284
version_downloads::date.eq(date(now - 1.day())),
278-
)).execute(&conn)
285+
))
286+
.execute(&conn)
279287
.unwrap();
280288

281289
let version_before = versions::table
@@ -331,7 +339,8 @@ mod test {
331339
version_downloads::counted.eq(2),
332340
version_downloads::date.eq(date(now - 2.days())),
333341
version_downloads::processed.eq(false),
334-
)).execute(&conn)
342+
))
343+
.execute(&conn)
335344
.unwrap();
336345

337346
::update(&conn).unwrap();

src/boot/categories.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ pub fn sync_with_connection(toml_str: &str, conn: &PgConnection) -> CargoResult<
107107
category.eq(c.name),
108108
description.eq(c.description),
109109
)
110-
}).collect::<Vec<_>>();
110+
})
111+
.collect::<Vec<_>>();
111112

112113
conn.transaction(|| {
113114
let slugs = diesel::insert_into(categories)
@@ -117,7 +118,8 @@ pub fn sync_with_connection(toml_str: &str, conn: &PgConnection) -> CargoResult<
117118
.set((
118119
category.eq(excluded(category)),
119120
description.eq(excluded(description)),
120-
)).returning(slug)
121+
))
122+
.returning(slug)
121123
.get_results::<String>(&*conn)?;
122124

123125
diesel::delete(categories)

src/controllers/crate_owner_invitation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ fn accept_invite(
7171
owner_id: user_id,
7272
created_by: pending_crate_owner.invited_by_user_id,
7373
owner_kind: OwnerKind::User as i32,
74-
}).on_conflict(crate_owners::table.primary_key())
74+
})
75+
.on_conflict(crate_owners::table.primary_key())
7576
.do_update()
7677
.set(crate_owners::deleted.eq(false))
7778
.execute(conn)?;

0 commit comments

Comments
 (0)