Skip to content

Bump clippy and address new findings #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ matrix:
allow_failures:
- rust: nightly
include:
- rust: nightly-2018-02-13
- rust: nightly-2018-03-31
script:
- cargo install --force clippy --vers 0.0.186
- cargo install --force clippy --vers 0.0.191
- cargo clippy
- rust: stable
script:
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl App {

App {
diesel_database: db::diesel_pool(&config.db_url, diesel_db_config),
github: github,
github,
session_key: config.session_key.clone(),
git_repo: Mutex::new(repo),
git_repo_checkout: config.git_repo_checkout.clone(),
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Default for Config {
}
};
Config {
uploader: uploader,
uploader,
session_key: env("SESSION_KEY"),
git_repo_checkout: checkout,
gh_client_id: env("GH_CLIENT_ID"),
Expand All @@ -134,8 +134,8 @@ impl Default for Config {
env: cargo_env,
max_upload_size: 10 * 1024 * 1024, // 10 MB default file upload size limit
max_unpack_size: 512 * 1024 * 1024, // 512 MB max when decompressed
mirror: mirror,
api_protocol: api_protocol,
mirror,
api_protocol,
}
}
}
4 changes: 2 additions & 2 deletions src/controllers/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
}

Ok(req.json(&R {
categories: categories,
meta: Meta { total: total },
categories,
meta: Meta { total },
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {

Ok(req.json(&R {
keywords: kws,
meta: Meta { total: total },
meta: Meta { total },
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/krate/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
};
Ok(req.json(&R {
version_downloads: downloads,
meta: meta,
meta,
}))
}
6 changes: 2 additions & 4 deletions src/controllers/krate/follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn follow_target(req: &mut Request) -> CargoResult<Follow> {
let crate_id = Crate::by_name(crate_name).select(crates::id).first(&*conn)?;
Ok(Follow {
user_id: user.id,
crate_id: crate_id,
crate_id,
})
}

Expand Down Expand Up @@ -51,7 +51,5 @@ pub fn following(req: &mut Request) -> CargoResult<Response> {
struct R {
following: bool,
}
Ok(req.json(&R {
following: following,
}))
Ok(req.json(&R { following }))
}
12 changes: 6 additions & 6 deletions src/controllers/krate/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ pub fn summary(req: &mut Request) -> CargoResult<Response> {
popular_categories: Vec<EncodableCategory>,
}
Ok(req.json(&R {
num_downloads: num_downloads,
num_crates: num_crates,
num_downloads,
num_crates,
new_crates: encode_crates(new_crates)?,
most_downloaded: encode_crates(most_downloaded)?,
most_recently_downloaded: encode_crates(most_recently_downloaded)?,
just_updated: encode_crates(just_updated)?,
popular_keywords: popular_keywords,
popular_categories: popular_categories,
popular_keywords,
popular_categories,
}))
}

Expand Down Expand Up @@ -200,7 +200,7 @@ pub fn versions(req: &mut Request) -> CargoResult<Response> {
struct R {
versions: Vec<EncodableVersion>,
}
Ok(req.json(&R { versions: versions }))
Ok(req.json(&R { versions }))
}

/// Handles the `GET /crates/:crate_id/reverse_dependencies` route.
Expand Down Expand Up @@ -241,6 +241,6 @@ pub fn reverse_dependencies(req: &mut Request) -> CargoResult<Response> {
Ok(req.json(&R {
dependencies: rev_deps,
versions,
meta: Meta { total: total },
meta: Meta { total },
}))
}
6 changes: 3 additions & 3 deletions src/controllers/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {
conn.transaction(|| {
// Persist the new crate, if it doesn't already exist
let persist = NewCrate {
name: name,
name,
description: new_crate.description.as_ref().map(|s| &**s),
homepage: new_crate.homepage.as_ref().map(|s| &**s),
documentation: new_crate.documentation.as_ref().map(|s| &**s),
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {
name: name.to_string(),
vers: vers.to_string(),
cksum: hex_cksum,
features: features,
features,
deps: git_deps,
yanked: Some(false),
links,
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {
}
Ok(req.json(&R {
krate: krate.minimal_encodable(&max_version, None, false, None),
warnings: warnings,
warnings,
}))
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/krate/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn search(req: &mut Request) -> CargoResult<Response> {
}

Ok(req.json(&R {
crates: crates,
meta: Meta { total: total },
crates,
meta: Meta { total },
}))
}
2 changes: 1 addition & 1 deletion src/controllers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod prelude {
headers.insert("Location".to_string(), vec![url.to_string()]);
Response {
status: (302, "Found"),
headers: headers,
headers,
body: Box::new(io::empty()),
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/controllers/site_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ pub fn show_deployed_sha(req: &mut Request) -> CargoResult<Response> {
struct R {
deployed_sha: String,
}
Ok(req.json(&R {
deployed_sha: deployed_sha,
}))
Ok(req.json(&R { deployed_sha }))
}
9 changes: 3 additions & 6 deletions src/controllers/user/me.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ pub fn me(req: &mut Request) -> CargoResult<Response> {

let verified = verified.unwrap_or(false);
let verification_sent = verified || verification_sent;
let user = User {
email: email,
..user
};
let user = User { email, ..user };

#[derive(Serialize)]
struct R {
Expand Down Expand Up @@ -88,8 +85,8 @@ pub fn updates(req: &mut Request) -> CargoResult<Response> {
more: bool,
}
Ok(req.json(&R {
versions: versions,
meta: Meta { more: more },
versions,
meta: Meta { more },
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/user/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn github_authorize(req: &mut Request) -> CargoResult<Response> {
}
Ok(req.json(&R {
url: url.to_string(),
state: state,
state,
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/version/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
struct R {
versions: Vec<EncodableVersion>,
}
Ok(req.json(&R { versions: versions }))
Ok(req.json(&R { versions }))
}

/// Handles the `GET /versions/:version_id` and
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/version/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ pub fn authors(req: &mut Request) -> CargoResult<Response> {
}
Ok(req.json(&R {
users: vec![],
meta: Meta { names: names },
meta: Meta { names },
}))
}
2 changes: 1 addition & 1 deletion src/middleware/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct AppMiddleware {

impl AppMiddleware {
pub fn new(app: Arc<App>) -> AppMiddleware {
AppMiddleware { app: app }
AppMiddleware { app }
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/models/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl Category {
id: slug.clone(),
slug: slug.clone(),
description: description.clone(),
created_at: created_at,
crates_cnt: crates_cnt,
category: category,
created_at,
crates_cnt,
category,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/models/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ impl Keyword {
} = self;
EncodableKeyword {
id: keyword.clone(),
created_at: created_at,
crates_cnt: crates_cnt,
keyword: keyword,
created_at,
crates_cnt,
keyword,
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,20 @@ impl Crate {
EncodableCrate {
id: name.clone(),
name: name.clone(),
updated_at: updated_at,
created_at: created_at,
downloads: downloads,
recent_downloads: recent_downloads,
versions: versions,
updated_at,
created_at,
downloads,
recent_downloads,
versions,
keywords: keyword_ids,
categories: category_ids,
badges: badges,
badges,
max_version: max_version.to_string(),
documentation: documentation,
homepage: homepage,
exact_match: exact_match,
description: description,
repository: repository,
documentation,
homepage,
exact_match,
description,
repository,
links: EncodableCrateLinks {
version_downloads: format!("/api/v1/crates/{}/downloads", name),
versions: versions_link,
Expand Down
12 changes: 6 additions & 6 deletions src/models/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ impl Owner {
}) => {
let url = format!("https://github.com/{}", gh_login);
EncodableOwner {
id: id,
id,
login: gh_login,
avatar: gh_avatar,
url: Some(url),
name: name,
name,
kind: String::from("user"),
}
}
Expand All @@ -113,11 +113,11 @@ impl Owner {
}) => {
let url = github::team_url(&login);
EncodableOwner {
id: id,
login: login,
id,
login,
url: Some(url),
avatar: avatar,
name: name,
avatar,
name,
kind: String::from("team"),
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/models/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ impl<'a> NewTeam<'a> {
avatar: Option<String>,
) -> Self {
NewTeam {
login: login,
github_id: github_id,
name: name,
avatar: avatar,
login,
github_id,
name,
avatar,
}
}

Expand Down Expand Up @@ -205,10 +205,10 @@ impl Team {
let url = github::team_url(&login);

EncodableTeam {
id: id,
login: login,
name: name,
avatar: avatar,
id,
login,
name,
avatar,
url: Some(url),
}
}
Expand Down
Loading