Skip to content

Commit 4eaafba

Browse files
Merge #1256
1256: Bump rustfmt and clippy on CI r=jtgeibel Bump rustfmt and clippy and apply fixups.
2 parents 47998b7 + 2da98c0 commit 4eaafba

File tree

14 files changed

+57
-34
lines changed

14 files changed

+57
-34
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ matrix:
4242
allow_failures:
4343
- rust: nightly
4444
include:
45-
- rust: nightly-2017-12-28
45+
- rust: nightly-2018-02-13
4646
script:
47-
- cargo install --force rustfmt-nightly --vers 0.3.4
47+
- cargo install --force rustfmt-nightly --vers 0.3.6
4848
- cargo fmt -- --write-mode=diff
49-
- cargo install --force clippy --vers 0.0.177
49+
- cargo install --force clippy --vers 0.0.186
5050
- cargo clippy
5151
- rust: stable
5252
script:

src/bin/render-readmes.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,11 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
237237
krate_name, version.num
238238
))
239239
};
240-
if manifest.package.readme.is_none() {
241-
return None;
242-
}
240+
243241
let rendered = {
244242
let path = format!(
245243
"{}-{}/{}",
246-
krate_name,
247-
version.num,
248-
manifest.package.readme.unwrap()
244+
krate_name, version.num, manifest.package.readme?
249245
);
250246
let contents = find_file_by_path(&mut entries, Path::new(&path), version, krate_name);
251247
readme_to_html(
@@ -262,12 +258,14 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
262258
))
263259
};
264260
return Some(rendered);
261+
265262
#[derive(Deserialize)]
266263
struct Package {
267264
readme: Option<String>,
268265
readme_file: Option<String>,
269266
repository: Option<String>,
270267
}
268+
271269
#[derive(Deserialize)]
272270
struct Manifest {
273271
package: Package,

src/crate_owner_invitation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ pub struct EncodableCrateOwnerInvitation {
6262
pub invited_by_username: String,
6363
pub crate_name: String,
6464
pub crate_id: i32,
65-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
65+
#[serde(with = "::util::rfc3339")]
66+
pub created_at: NaiveDateTime,
6667
}
6768

6869
/// Handles the `GET /me/crate_owner_invitations` route.

src/dependency.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ pub struct Dependency {
2828

2929
#[derive(Debug, QueryableByName)]
3030
pub struct ReverseDependency {
31-
#[diesel(embed)] dependency: Dependency,
32-
#[sql_type = "::diesel::sql_types::Integer"] crate_downloads: i32,
31+
#[diesel(embed)]
32+
dependency: Dependency,
33+
#[sql_type = "::diesel::sql_types::Integer"]
34+
crate_downloads: i32,
3335
#[sql_type = "::diesel::sql_types::Text"]
3436
#[column_name = "crate_name"]
3537
name: String,

src/krate/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
142142

143143
#[derive(Serialize)]
144144
struct R {
145-
#[serde(rename = "crate")] krate: EncodableCrate,
145+
#[serde(rename = "crate")]
146+
krate: EncodableCrate,
146147
versions: Vec<EncodableVersion>,
147148
keywords: Vec<EncodableKeyword>,
148149
categories: Vec<EncodableCategory>,

src/krate/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ type ByName<'a> = diesel::dsl::Filter<All, WithName<'a>>;
9898
pub struct EncodableCrate {
9999
pub id: String,
100100
pub name: String,
101-
#[serde(with = "::util::rfc3339")] pub updated_at: NaiveDateTime,
101+
#[serde(with = "::util::rfc3339")]
102+
pub updated_at: NaiveDateTime,
102103
pub versions: Option<Vec<i32>>,
103104
pub keywords: Option<Vec<String>>,
104105
pub categories: Option<Vec<String>>,
105106
pub badges: Option<Vec<EncodableBadge>>,
106-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
107+
#[serde(with = "::util::rfc3339")]
108+
pub created_at: NaiveDateTime,
107109
pub downloads: i32,
108110
pub recent_downloads: Option<i64>,
109111
pub max_version: String,

src/krate/publish.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {
177177

178178
#[derive(Serialize)]
179179
struct R<'a> {
180-
#[serde(rename = "crate")] krate: EncodableCrate,
180+
#[serde(rename = "crate")]
181+
krate: EncodableCrate,
181182
warnings: Warnings<'a>,
182183
}
183184
Ok(req.json(&R {

src/tests/all.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ mod version;
100100

101101
#[derive(Deserialize, Debug)]
102102
struct GoodCrate {
103-
#[serde(rename = "crate")] krate: EncodableCrate,
103+
#[serde(rename = "crate")]
104+
krate: EncodableCrate,
104105
warnings: Warnings,
105106
}
106107
#[derive(Deserialize)]

src/tests/krate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ struct VersionsList {
3131
}
3232
#[derive(Deserialize)]
3333
struct CrateResponse {
34-
#[serde(rename = "crate")] krate: EncodableCrate,
34+
#[serde(rename = "crate")]
35+
krate: EncodableCrate,
3536
versions: Vec<EncodableVersion>,
3637
keywords: Vec<EncodableKeyword>,
3738
}

src/tests/schema_details.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ struct FkConstraint {
4646
#[sql_type = "Text"]
4747
#[column_name = "conname"]
4848
name: String,
49-
#[sql_type = "Text"] definition: String,
49+
#[sql_type = "Text"]
50+
definition: String,
5051
}
5152

5253
#[derive(QueryableByName)]
5354
struct TableNameAndConstraint {
5455
#[sql_type = "Text"]
5556
#[column_name = "relname"]
5657
table_name: String,
57-
#[diesel(embed)] constraint: Option<FkConstraint>,
58+
#[diesel(embed)]
59+
constraint: Option<FkConstraint>,
5860
}
5961

6062
fn get_fk_constraint_definitions(column_name: &str) -> Vec<TableNameAndConstraint> {

src/token.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ use schema::api_tokens;
1717
#[belongs_to(User)]
1818
pub struct ApiToken {
1919
pub id: i32,
20-
#[serde(skip)] pub user_id: i32,
21-
#[serde(skip)] pub token: String,
20+
#[serde(skip)]
21+
pub user_id: i32,
22+
#[serde(skip)]
23+
pub token: String,
2224
pub name: String,
23-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
24-
#[serde(with = "::util::rfc3339::option")] pub last_used_at: Option<NaiveDateTime>,
25+
#[serde(with = "::util::rfc3339")]
26+
pub created_at: NaiveDateTime,
27+
#[serde(with = "::util::rfc3339::option")]
28+
pub last_used_at: Option<NaiveDateTime>,
2529
}
2630

2731
/// The serialization format for the `ApiToken` model with its token value.
@@ -32,8 +36,10 @@ pub struct EncodableApiTokenWithToken {
3236
pub id: i32,
3337
pub name: String,
3438
pub token: String,
35-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
36-
#[serde(with = "::util::rfc3339::option")] pub last_used_at: Option<NaiveDateTime>,
39+
#[serde(with = "::util::rfc3339")]
40+
pub created_at: NaiveDateTime,
41+
#[serde(with = "::util::rfc3339::option")]
42+
pub last_used_at: Option<NaiveDateTime>,
3743
}
3844

3945
impl ApiToken {

src/version/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ pub struct NewVersion {
4848
#[derive(Serialize, Deserialize, Debug)]
4949
pub struct EncodableVersion {
5050
pub id: i32,
51-
#[serde(rename = "crate")] pub krate: String,
51+
#[serde(rename = "crate")]
52+
pub krate: String,
5253
pub num: String,
5354
pub dl_path: String,
5455
pub readme_path: String,
55-
#[serde(with = "::util::rfc3339")] pub updated_at: NaiveDateTime,
56-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
56+
#[serde(with = "::util::rfc3339")]
57+
pub updated_at: NaiveDateTime,
58+
#[serde(with = "::util::rfc3339")]
59+
pub created_at: NaiveDateTime,
5760
pub downloads: i32,
5861
pub features: HashMap<String, Vec<String>>,
5962
pub yanked: bool,

src/views/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ pub struct EncodableCategory {
1111
pub category: String,
1212
pub slug: String,
1313
pub description: String,
14-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
14+
#[serde(with = "::util::rfc3339")]
15+
pub created_at: NaiveDateTime,
1516
pub crates_cnt: i32,
1617
}
1718

@@ -21,7 +22,8 @@ pub struct EncodableCategoryWithSubcategories {
2122
pub category: String,
2223
pub slug: String,
2324
pub description: String,
24-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
25+
#[serde(with = "::util::rfc3339")]
26+
pub created_at: NaiveDateTime,
2527
pub crates_cnt: i32,
2628
pub subcategories: Vec<EncodableCategory>,
2729
}
@@ -34,7 +36,8 @@ pub use download::EncodableVersionDownload;
3436
pub struct EncodableKeyword {
3537
pub id: String,
3638
pub keyword: String,
37-
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
39+
#[serde(with = "::util::rfc3339")]
40+
pub created_at: NaiveDateTime,
3841
pub crates_cnt: i32,
3942
}
4043

src/with_count.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#[derive(QueryableByName)]
22
pub struct WithCount<T> {
3-
#[sql_type = "::diesel::sql_types::BigInt"] total: i64,
4-
#[diesel(embed)] record: T,
3+
#[sql_type = "::diesel::sql_types::BigInt"]
4+
total: i64,
5+
#[diesel(embed)]
6+
record: T,
57
}
68

79
pub trait WithCountExtension<T> {

0 commit comments

Comments
 (0)