Skip to content

Clippy cleanups #1735

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 4 commits into from
May 2, 2019
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
2 changes: 1 addition & 1 deletion src/background_jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Environment {
.map(|(u, p)| (u.as_str(), p.as_str()))
}

pub fn connection(&self) -> CargoResult<DieselPooledConn> {
pub fn connection(&self) -> CargoResult<DieselPooledConn<'_>> {
self.connection_pool.0.get().map_err(Into::into)
}

Expand Down
2 changes: 1 addition & 1 deletion src/bin/background-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Usage:
// cargo run --bin background-worker

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::git::Repository;
use cargo_registry::{background_jobs::*, db};
Expand Down
2 changes: 1 addition & 1 deletion src/bin/delete-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Usage:
// cargo run --bin delete-crate crate-name

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::{db, models::Crate, schema::crates};
use std::{
Expand Down
2 changes: 1 addition & 1 deletion src/bin/delete-version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Usage:
// cargo run --bin delete-version crate-name version-number

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::{
db,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Usage:
//! cargo run --bin monitor

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

mod on_call;

Expand Down
2 changes: 1 addition & 1 deletion src/bin/populate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Usage:
// cargo run --bin populate version_id1 version_id2 ...

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::{db, schema::version_downloads};
use std::env;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/render-readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Warning: this can take a lot of time.

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

#[macro_use]
extern crate serde;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::{boot, App, Env};
use jemalloc_ctl;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/test-pagerduty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//!
//! Event type can be trigger, acknowledge, or resolve

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

mod on_call;

Expand Down
2 changes: 1 addition & 1 deletion src/bin/transfer-crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Usage:
// cargo run --bin transfer-crates from-user to-user

#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

use cargo_registry::{
db,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/update-downloads.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

#[macro_use]
extern crate diesel;
Expand Down
6 changes: 3 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum DieselPool {
}

impl DieselPool {
pub fn get(&self) -> CargoResult<DieselPooledConn> {
pub fn get(&self) -> CargoResult<DieselPooledConn<'_>> {
match self {
DieselPool::Pool(pool) => Ok(DieselPooledConn::Pool(pool.get()?)),
DieselPool::Test(conn) => Ok(DieselPooledConn::Test(conn.lock())),
Expand Down Expand Up @@ -89,11 +89,11 @@ pub trait RequestTransaction {
///
/// The connection will live for the lifetime of the request.
// FIXME: This description does not match the implementation below.
fn db_conn(&self) -> CargoResult<DieselPooledConn>;
fn db_conn(&self) -> CargoResult<DieselPooledConn<'_>>;
}

impl<T: Request + ?Sized> RequestTransaction for T {
fn db_conn(&self) -> CargoResult<DieselPooledConn> {
fn db_conn(&self) -> CargoResult<DieselPooledConn<'_>> {
self.app().diesel_database.get().map_err(Into::into)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! All implemented routes are defined in the [middleware](fn.middleware.html) function and
//! implemented in the [category](category/index.html), [keyword](keyword/index.html),
//! [krate](krate/index.html), [user](user/index.html) and [version](version/index.html) modules.
#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]
#![deny(missing_debug_implementations, missing_copy_implementations)]
#![deny(bare_trait_objects)]
#![recursion_limit = "256"]
Expand Down
2 changes: 1 addition & 1 deletion src/s3/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]

extern crate base64;
extern crate chrono;
Expand Down
8 changes: 7 additions & 1 deletion src/tests/all.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#![deny(warnings)]
#![deny(warnings, clippy::all, rust_2018_idioms)]
// TODO: Remove after we can bump to Rust 1.35 stable in `RustConfig`
#![allow(
renamed_and_removed_lints,
clippy::cyclomatic_complexity,
clippy::unknown_clippy_lints
)]

#[macro_use]
extern crate diesel;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn show() {
}

#[test]
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cognitive_complexity)]
fn update_crate() {
let (_b, app, middle) = app();
let mut req = req(Method::Get, "/api/v1/categories/foo");
Expand Down
6 changes: 3 additions & 3 deletions src/tests/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn index() {
}

#[test]
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cognitive_complexity)]
fn index_queries() {
let (app, anon, user) = TestApp::init().with_user();
let user = user.as_model();
Expand Down Expand Up @@ -316,7 +316,7 @@ fn index_sorting() {
}

#[test]
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cognitive_complexity)]
fn exact_match_on_queries_with_sort() {
let (app, anon, user) = TestApp::init().with_user();
let user = user.as_model();
Expand Down Expand Up @@ -1459,7 +1459,7 @@ fn yank_not_owner() {
}

#[test]
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cognitive_complexity)]
fn yank_max_version() {
let (_, anon, _, token) = TestApp::with_proxy().with_token();

Expand Down