Skip to content

Commit e441d42

Browse files
Merge #1147
1147: Bump clippy and rustfmt r=carols10cents Bump clippy and rustfmt to versions compatible with the latest nightly compiler.
2 parents a659b5a + 69a7d27 commit e441d42

File tree

17 files changed

+70
-50
lines changed

17 files changed

+70
-50
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ matrix:
3939
allow_failures:
4040
- rust: nightly
4141
include:
42-
- rust: nightly-2017-09-20
42+
- rust: nightly-2017-11-07
4343
env: RUSTFMT=YESPLEASE
4444
script:
45-
- cargo install --force rustfmt-nightly --vers 0.2.7
45+
- cargo install --force rustfmt-nightly --vers 0.2.15
4646
- export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
4747
- rustfmt --version
4848
- cargo fmt -- --write-mode=diff
@@ -51,7 +51,7 @@ matrix:
5151
- cargo build
5252
- cargo test
5353
- npm test
54-
- rust: nightly-2017-09-20
54+
- rust: nightly-2017-11-07
5555
env: CLIPPY=YESPLEASE
5656
script:
5757
- cargo check --features "lint"

Cargo.lock

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ diesel_full_text_search = "0.16.0"
5353
serde_json = "1.0.0"
5454
serde_derive = "1.0.0"
5555
serde = "1.0.0"
56-
clippy = { version = "=0.0.162", optional = true }
56+
clippy = { version = "=0.0.169", optional = true }
5757
chrono = { version = "0.4.0", features = ["serde"] }
5858
comrak = { version = "0.2.3", default-features = false }
5959
ammonia = { git = "https://github.com/notriddle/ammonia", rev = "3d4e4073f8cdb7c60203b9036c09f4385a2fdbbd" }

src/badge.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ impl Badge {
107107
delete(badges::table)
108108
.filter(badges::crate_id.eq(krate.id))
109109
.execute(conn)?;
110-
insert_into(badges::table).values(&new_badges).execute(conn)?;
110+
insert_into(badges::table)
111+
.values(&new_badges)
112+
.execute(conn)?;
111113
Ok(invalid_badges)
112114
})
113115
}

src/keyword.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(unused_imports)] // TODO: Remove when rustc 1.23 is stable
12
use std::ascii::AsciiExt;
23

34
use chrono::NaiveDateTime;
@@ -127,7 +128,9 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
127128
query = query.order(keywords::keyword.asc());
128129
}
129130

130-
let data = query.paginate(limit, offset).load::<(Keyword, i64)>(&*conn)?;
131+
let data = query
132+
.paginate(limit, offset)
133+
.load::<(Keyword, i64)>(&*conn)?;
131134
let total = data.get(0).map(|&(_, t)| t).unwrap_or(0);
132135
let kws = data.into_iter()
133136
.map(|(k, _)| k.encodable())

src/krate/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn summary(req: &mut Request) -> CargoResult<Response> {
4141
.map(|versions| Version::max(versions.into_iter().map(|v| v.num)))
4242
.zip(krates)
4343
.map(|(max_version, krate)| {
44-
Ok(krate.minimal_encodable(max_version, None, false, None))
44+
Ok(krate.minimal_encodable(&max_version, None, false, None))
4545
})
4646
.collect()
4747
};
@@ -153,7 +153,7 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
153153
Ok(
154154
req.json(&R {
155155
krate: krate.clone().encodable(
156-
max_version,
156+
&max_version,
157157
Some(ids),
158158
Some(&kws),
159159
Some(&cats),

src/krate/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(unused_imports)] // TODO: Remove when rustc 1.23 is stable
12
use std::ascii::AsciiExt;
23

34
use chrono::{NaiveDate, NaiveDateTime};
@@ -26,7 +27,7 @@ pub mod metadata;
2627

2728
/// Hosts in this blacklist are known to not be hosting documentation,
2829
/// and are possibly of malicious intent e.g. ad tracking networks, etc.
29-
const DOCUMENTATION_BLACKLIST: [&'static str; 1] = ["rust-ci.org"];
30+
const DOCUMENTATION_BLACKLIST: [&str; 1] = ["rust-ci.org"];
3031

3132
#[derive(Debug, Insertable, Queryable, Identifiable, Associations, AsChangeset, Clone, Copy)]
3233
#[belongs_to(Crate)]
@@ -315,7 +316,7 @@ impl Crate {
315316

316317
pub fn minimal_encodable(
317318
self,
318-
max_version: semver::Version,
319+
max_version: &semver::Version,
319320
badges: Option<Vec<Badge>>,
320321
exact_match: bool,
321322
recent_downloads: Option<i64>,
@@ -334,7 +335,7 @@ impl Crate {
334335
#[cfg_attr(feature = "clippy", allow(too_many_arguments))]
335336
pub fn encodable(
336337
self,
337-
max_version: semver::Version,
338+
max_version: &semver::Version,
338339
versions: Option<Vec<i32>>,
339340
keywords: Option<&[Keyword]>,
340341
categories: Option<&[Category]>,

src/krate/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {
181181
warnings: Warnings<'a>,
182182
}
183183
Ok(req.json(&R {
184-
krate: krate.minimal_encodable(max_version, None, false, None),
184+
krate: krate.minimal_encodable(&max_version, None, false, None),
185185
warnings: warnings,
186186
}))
187187
})

src/krate/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub fn search(req: &mut Request) -> CargoResult<Response> {
201201
.filter(badges::crate_id.eq(krate.id))
202202
.load::<Badge>(&*conn)?;
203203
Ok(krate.minimal_encodable(
204-
max_version,
204+
&max_version,
205205
Some(badges),
206206
perfect_match,
207207
Some(recent_downloads),

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This crate implements the backend server for https://crates.io/
1+
//! This crate implements the backend server for <https://crates.io/>
22
//!
33
//! All implemented routes are defined in the [middleware](fn.middleware.html) function and
44
//! implemented in the [category](category/index.html), [keyword](keyword/index.html),

src/render.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ mod tests {
270270

271271
#[test]
272272
fn text_with_inline_javascript() {
273-
let text = r#"foo_readme\n\n<a href="https://crates.io/crates/cargo-registry" onclick="window.alert('Got you')">Crate page</a>"#;
273+
let text =
274+
r#"foo_readme\n\n<a href="https://crates.io/crates/cargo-registry" onclick="window.alert('Got you')">Crate page</a>"#;
274275
let result = markdown_to_html(text, None).unwrap();
275276
assert_eq!(
276277
result,
@@ -345,7 +346,8 @@ mod tests {
345346

346347
#[test]
347348
fn absolute_links_dont_get_resolved() {
348-
let readme_text = "[![Crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)";
349+
let readme_text =
350+
"[![Crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)";
349351
let repository = "https://github.com/kbknapp/clap-rs/";
350352
let result = markdown_to_html(readme_text, Some(&repository)).unwrap();
351353

@@ -387,7 +389,8 @@ mod tests {
387389

388390
#[test]
389391
fn manual_anchor_is_sanitized() {
390-
let text = "<h1><a href=\"#my-crate\" id=\"my-crate\"></a>My crate</h1>\n<p>Hello, world!</p>\n";
392+
let text =
393+
"<h1><a href=\"#my-crate\" id=\"my-crate\"></a>My crate</h1>\n<p>Hello, world!</p>\n";
391394
let result = markdown_to_html(text, None).unwrap();
392395
assert_eq!(
393396
result,

src/tests/all.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ impl<'a> CrateBuilder<'a> {
408408
fn build(mut self, connection: &PgConnection) -> CargoResult<Crate> {
409409
use diesel::{insert_into, update};
410410

411-
let mut krate = self.krate.create_or_update(connection, None, self.owner_id)?;
411+
let mut krate = self.krate
412+
.create_or_update(connection, None, self.owner_id)?;
412413

413414
// Since we are using `NewCrate`, we can't set all the
414415
// crate properties in a single DB call.

src/tests/user.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ fn test_github_login_does_not_overwrite_email() {
381381
assert_eq!(r.user.email, None);
382382
assert_eq!(r.user.login, "apricot");
383383

384-
let body = r#"{"user":{"email":"[email protected]","name":"Apricot Apricoto","login":"apricot","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/apricot","kind":null}}"#;
384+
let body =
385+
r#"{"user":{"email":"[email protected]","name":"Apricot Apricoto","login":"apricot","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/apricot","kind":null}}"#;
385386
let mut response = ok_resp!(
386387
middle.call(
387388
req.with_path(&format!("/api/v1/users/{}", user.id))
@@ -440,7 +441,8 @@ fn test_email_get_and_put() {
440441
assert_eq!(r.user.email, None);
441442
assert_eq!(r.user.login, "mango");
442443

443-
let body = r#"{"user":{"email":"[email protected]","name":"Mango McMangoface","login":"mango","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/mango","kind":null}}"#;
444+
let body =
445+
r#"{"user":{"email":"[email protected]","name":"Mango McMangoface","login":"mango","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/mango","kind":null}}"#;
444446
let mut response = ok_resp!(
445447
middle.call(
446448
req.with_path(&format!("/api/v1/users/{}", user.id))
@@ -479,7 +481,8 @@ fn test_empty_email_not_added() {
479481
user
480482
};
481483

482-
let body = r#"{"user":{"email":"","name":"Papayo Papaya","login":"papaya","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/papaya","kind":null}}"#;
484+
let body =
485+
r#"{"user":{"email":"","name":"Papayo Papaya","login":"papaya","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/papaya","kind":null}}"#;
483486
let json = bad_resp!(
484487
middle.call(
485488
req.with_path(&format!("/api/v1/users/{}", user.id))
@@ -494,7 +497,8 @@ fn test_empty_email_not_added() {
494497
json.errors
495498
);
496499

497-
let body = r#"{"user":{"email":null,"name":"Papayo Papaya","login":"papaya","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/papaya","kind":null}}"#;
500+
let body =
501+
r#"{"user":{"email":null,"name":"Papayo Papaya","login":"papaya","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/papaya","kind":null}}"#;
498502
let json = bad_resp!(
499503
middle.call(
500504
req.with_path(&format!("/api/v1/users/{}", user.id))
@@ -531,7 +535,8 @@ fn test_this_user_cannot_change_that_user_email() {
531535
unsigned_user
532536
};
533537

534-
let body = r#"{"user":{"email":"[email protected]","name":"Pine Apple","login":"pineapple","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/pineapple","kind":null}}"#;
538+
let body =
539+
r#"{"user":{"email":"[email protected]","name":"Pine Apple","login":"pineapple","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/pineapple","kind":null}}"#;
535540

536541
let json = bad_resp!(
537542
middle.call(
@@ -642,7 +647,8 @@ fn test_insert_into_email_table_with_email_change() {
642647
assert!(!r.user.email_verified);
643648
assert!(r.user.email_verification_sent);
644649

645-
let body = r#"{"user":{"email":"[email protected]","name":"potato","login":"potato","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/potato","kind":null}}"#;
650+
let body =
651+
r#"{"user":{"email":"[email protected]","name":"potato","login":"potato","avatar":"https://avatars0.githubusercontent.com","url":"https://github.com/potato","kind":null}}"#;
646652
let mut response = ok_resp!(
647653
middle.call(
648654
req.with_path(&format!("/api/v1/users/{}", user.id))

src/uploaders.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl Uploader {
191191
}
192192

193193
/// Deletes an uploaded file.
194-
fn delete(&self, app: Arc<App>, path: &str) -> CargoResult<()> {
194+
fn delete(&self, app: &Arc<App>, path: &str) -> CargoResult<()> {
195195
match *self {
196196
Uploader::S3 { ref bucket, .. } => {
197197
let mut handle = app.handle();
@@ -217,7 +217,7 @@ pub struct Bomb {
217217
impl Drop for Bomb {
218218
fn drop(&mut self) {
219219
if let Some(ref path) = self.path {
220-
if let Err(e) = self.app.config.uploader.delete(Arc::clone(&self.app), path) {
220+
if let Err(e) = self.app.config.uploader.delete(&self.app, path) {
221221
println!("unable to delete {}, {:?}", path, e);
222222
}
223223
}

src/user/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl User {
243243
/// This route will return an authorization URL for the GitHub OAuth flow including the crates.io
244244
/// `client_id` and a randomly generated `state` secret.
245245
///
246-
/// see https://developer.github.com/v3/oauth/#redirect-users-to-request-github-access
246+
/// see <https://developer.github.com/v3/oauth/#redirect-users-to-request-github-access>
247247
///
248248
/// ## Response Body Example
249249
///
@@ -279,7 +279,7 @@ pub fn github_authorize(req: &mut Request) -> CargoResult<Response> {
279279
/// to exchange the temporary `code` for an API token. The API token is returned together with
280280
/// the corresponding user information.
281281
///
282-
/// see https://developer.github.com/v3/oauth/#github-redirects-back-to-your-site
282+
/// see <https://developer.github.com/v3/oauth/#github-redirects-back-to-your-site>
283283
///
284284
/// ## Query Parameters
285285
///

src/util/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn human<S: ToString + ?Sized>(error: &S) -> Box<CargoError> {
342342

343343
/// This is intended to be used for errors being sent back to the Ember
344344
/// frontend, not to cargo as cargo does not handle non-200 response codes well
345-
/// (see https://github.com/rust-lang/cargo/issues/3995), but Ember requires
345+
/// (see <https://github.com/rust-lang/cargo/issues/3995>), but Ember requires
346346
/// non-200 response codes for its stores to work properly.
347347
///
348348
/// Since this is going back to the UI these errors are treated the same as

src/version/deprecated.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
2424
// Extract all ids requested.
2525
let query = url::form_urlencoded::parse(req.query_string().unwrap_or("").as_bytes());
2626
let ids = query
27-
.filter_map(|(ref a, ref b)| if *a == "ids[]" {
28-
b.parse().ok()
29-
} else {
30-
None
31-
})
27+
.filter_map(|(ref a, ref b)| if *a == "ids[]" { b.parse().ok() } else { None })
3228
.collect::<Vec<i32>>();
3329

3430
let versions = versions::table

0 commit comments

Comments
 (0)