Skip to content

Commit c414d73

Browse files
committed
Auto merge of #587 - Freax13:fix-warnings, r=pietroalbini
fix a bunch of clippy warnings
2 parents 2475482 + 3944ec9 commit c414d73

File tree

18 files changed

+64
-73
lines changed

18 files changed

+64
-73
lines changed

src/actions/experiments/create.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl CreateExperiment {
4141
impl Action for CreateExperiment {
4242
fn apply(self, ctx: &ActionsCtx) -> Fallible<()> {
4343
// Ensure no duplicate experiments are created
44-
if Experiment::exists(&ctx.db, &self.name)? {
44+
if Experiment::exists(ctx.db, &self.name)? {
4545
return Err(ExperimentError::AlreadyExists(self.name).into());
4646
}
4747

@@ -50,7 +50,7 @@ impl Action for CreateExperiment {
5050
return Err(ExperimentError::DuplicateToolchains.into());
5151
}
5252

53-
let crates = crate::crates::lists::get_crates(&self.crates, &ctx.db, &ctx.config)?;
53+
let crates = crate::crates::lists::get_crates(&self.crates, ctx.db, ctx.config)?;
5454

5555
ctx.db.transaction(|transaction| {
5656
transaction.execute(
@@ -142,7 +142,7 @@ mod tests {
142142
);
143143
assert_eq!(ex.mode, Mode::BuildAndTest);
144144
assert_eq!(
145-
ex.get_crates(&ctx.db).unwrap(),
145+
ex.get_crates(ctx.db).unwrap(),
146146
crate::crates::lists::get_crates(&CrateSelect::Local, &db, &config).unwrap()
147147
);
148148
assert_eq!(ex.cap_lints, CapLints::Forbid);
@@ -192,16 +192,13 @@ mod tests {
192192
},
193193
)
194194
.unwrap();
195-
crates
196-
.iter()
197-
.find(|c| {
198-
if let Crate::Local(name) = c {
199-
name == krate
200-
} else {
201-
panic!("there should be no non-local crates")
202-
}
203-
})
204-
.is_none()
195+
!crates.iter().any(|c| {
196+
if let Crate::Local(name) = c {
197+
name == krate
198+
} else {
199+
panic!("there should be no non-local crates")
200+
}
201+
})
205202
}
206203

207204
let db = Database::temp().unwrap();

src/actions/experiments/delete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct DeleteExperiment {
99

1010
impl Action for DeleteExperiment {
1111
fn apply(self, ctx: &ActionsCtx) -> Fallible<()> {
12-
if !Experiment::exists(&ctx.db, &self.name)? {
12+
if !Experiment::exists(ctx.db, &self.name)? {
1313
return Err(ExperimentError::NotFound(self.name).into());
1414
}
1515

src/actions/experiments/edit.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl EditExperiment {
3535

3636
impl Action for EditExperiment {
3737
fn apply(mut self, ctx: &ActionsCtx) -> Fallible<()> {
38-
let mut ex = match Experiment::get(&ctx.db, &self.name)? {
38+
let mut ex = match Experiment::get(ctx.db, &self.name)? {
3939
Some(ex) => ex,
4040
None => return Err(ExperimentError::NotFound(self.name.clone()).into()),
4141
};
@@ -79,12 +79,10 @@ impl Action for EditExperiment {
7979
// This is also done if ignore_blacklist is changed to recalculate the skipped crates
8080
let new_crates = if let Some(crates) = self.crates {
8181
Some(crate::crates::lists::get_crates(
82-
&crates,
83-
&ctx.db,
84-
&ctx.config,
82+
&crates, ctx.db, ctx.config,
8583
)?)
8684
} else if self.ignore_blacklist.is_some() {
87-
Some(ex.get_crates(&ctx.db)?)
85+
Some(ex.get_crates(ctx.db)?)
8886
} else {
8987
None
9088
};
@@ -237,12 +235,12 @@ mod tests {
237235
assert_eq!(ex.mode, Mode::CheckOnly);
238236
assert_eq!(ex.cap_lints, CapLints::Warn);
239237
assert_eq!(ex.priority, 10);
240-
assert_eq!(ex.ignore_blacklist, true);
238+
assert!(ex.ignore_blacklist);
241239
assert_eq!(ex.assigned_to, Some(Assignee::CLI));
242240
assert_eq!(ex.requirement, Some("windows".to_string()));
243241

244242
assert_eq!(
245-
ex.get_crates(&ctx.db).unwrap(),
243+
ex.get_crates(ctx.db).unwrap(),
246244
crate::crates::lists::get_crates(&CrateSelect::Local, &db, &config).unwrap()
247245
);
248246
}
@@ -260,16 +258,13 @@ mod tests {
260258
},
261259
)
262260
.unwrap();
263-
crates
264-
.iter()
265-
.find(|c| {
266-
if let Crate::Local(name) = c {
267-
name == krate
268-
} else {
269-
panic!("there should be no non-local crates")
270-
}
271-
})
272-
.is_none()
261+
!crates.iter().any(|c| {
262+
if let Crate::Local(name) = c {
263+
name == krate
264+
} else {
265+
panic!("there should be no non-local crates")
266+
}
267+
})
273268
}
274269

275270
let db = Database::temp().unwrap();

src/actions/lists/update.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ impl Action for UpdateLists {
2222
fn apply(self, ctx: &ActionsCtx) -> Fallible<()> {
2323
if self.github {
2424
info!("updating GitHub repositories list");
25-
GitHubList::default().update(&ctx.db)?;
25+
GitHubList::default().update(ctx.db)?;
2626
}
2727

2828
if self.registry {
2929
info!("updating crates.io crates list");
30-
RegistryList.update(&ctx.db)?;
30+
RegistryList.update(ctx.db)?;
3131
}
3232

3333
if self.local {
3434
info!("updating local crates list");
35-
LocalList::default().update(&ctx.db)?;
35+
LocalList::default().update(ctx.db)?;
3636
}
3737

3838
Ok(())

src/assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Asset {
118118
}
119119

120120
pub fn load(name: &str) -> Fallible<&Asset> {
121-
if let Some(ref asset) = ASSETS.get(name) {
121+
if let Some(asset) = ASSETS.get(name) {
122122
Ok(asset)
123123
} else {
124124
bail!(

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Config {
168168
}
169169

170170
fn check_for_dup_keys(buffer: &str) -> Fallible<()> {
171-
if let Err(e) = ::toml::from_str::<::toml::Value>(&buffer) {
171+
if let Err(e) = ::toml::from_str::<::toml::Value>(buffer) {
172172
error!("got error parsing the config-file: {}", e);
173173
Err(e.into())
174174
} else {
@@ -317,7 +317,7 @@ mod tests {
317317
"[local-crates]\n"
318318
);
319319

320-
let list: Config = ::toml::from_str(&config).unwrap();
320+
let list: Config = ::toml::from_str(config).unwrap();
321321

322322
assert!(list.should_skip(&Crate::Registry(RegistryCrate {
323323
name: "lazy_static".into(),

src/crates/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ impl Crate {
4242
}
4343
Crate::Local(ref name) => format!("local/{}", name),
4444
Crate::Path(ref path) => {
45-
format!("path/{}", utf8_percent_encode(&path, &NON_ALPHANUMERIC))
45+
format!("path/{}", utf8_percent_encode(path, NON_ALPHANUMERIC))
4646
}
4747
Crate::Git(ref repo) => {
4848
if let Some(ref sha) = repo.sha {
4949
format!(
5050
"git/{}/{}",
51-
utf8_percent_encode(&repo.url, &NON_ALPHANUMERIC),
51+
utf8_percent_encode(&repo.url, NON_ALPHANUMERIC),
5252
sha
5353
)
5454
} else {
55-
format!("git/{}", utf8_percent_encode(&repo.url, &NON_ALPHANUMERIC),)
55+
format!("git/{}", utf8_percent_encode(&repo.url, NON_ALPHANUMERIC),)
5656
}
5757
}
5858
}
@@ -137,17 +137,16 @@ impl fmt::Display for Crate {
137137
format!("{}/{}", repo.org, repo.name)
138138
},
139139
Crate::Local(ref name) => format!("{} (local)", name),
140-
Crate::Path(ref path) =>
141-
format!("{}", utf8_percent_encode(path, &NON_ALPHANUMERIC)),
140+
Crate::Path(ref path) => format!("{}", utf8_percent_encode(path, NON_ALPHANUMERIC)),
142141
Crate::Git(ref repo) =>
143142
if let Some(ref sha) = repo.sha {
144143
format!(
145144
"{}/{}",
146-
utf8_percent_encode(&repo.url, &NON_ALPHANUMERIC),
145+
utf8_percent_encode(&repo.url, NON_ALPHANUMERIC),
147146
sha
148147
)
149148
} else {
150-
utf8_percent_encode(&repo.url, &NON_ALPHANUMERIC).to_string()
149+
utf8_percent_encode(&repo.url, NON_ALPHANUMERIC).to_string()
151150
},
152151
}
153152
)
@@ -282,11 +281,11 @@ mod tests {
282281
test_from_str! {
283282
"local/build-fail" => Crate::Local("build-fail".to_string()),
284283
"path/pathtofile" => Crate::Path("pathtofile".to_string()),
285-
&format!("path/{}", utf8_percent_encode("path/with:stange?characters", &NON_ALPHANUMERIC)) => Crate::Path("path/with:stange?characters".to_string()),
284+
&format!("path/{}", utf8_percent_encode("path/with:stange?characters", NON_ALPHANUMERIC)) => Crate::Path("path/with:stange?characters".to_string()),
286285
"gh/org/user" => Crate::GitHub(GitHubRepo{org: "org".to_string(), name: "user".to_string(), sha: None}),
287286
"gh/org/user/sha" => Crate::GitHub(GitHubRepo{org: "org".to_string(), name: "user".to_string(), sha: Some("sha".to_string())}),
288287
"git/url" => Crate::Git(GitRepo{url: "url".to_string(), sha: None}),
289-
&format!("git/{}", utf8_percent_encode("url/with:stange?characters", &NON_ALPHANUMERIC)) => Crate::Git(GitRepo{url: "url/with:stange?characters".to_string(), sha: None}),
288+
&format!("git/{}", utf8_percent_encode("url/with:stange?characters", NON_ALPHANUMERIC)) => Crate::Git(GitRepo{url: "url/with:stange?characters".to_string(), sha: None}),
290289
"git/url/sha" => Crate::Git(GitRepo{url: "url".to_string(), sha: Some("sha".to_string())}),
291290
"reg/name/version" => Crate::Registry(RegistryCrate{name: "name".to_string(), version: "version".to_string()}),
292291
}

src/experiments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ impl Experiment {
354354
if let Some(mut experiment) = ex {
355355
let new_ex = experiment.status != Status::Running;
356356
if new_ex {
357-
experiment.set_status(&db, Status::Running)?;
357+
experiment.set_status(db, Status::Running)?;
358358
// If this experiment was not assigned to a specific agent make it distributed
359359
experiment.set_assigned_to(
360-
&db,
360+
db,
361361
experiment
362362
.assigned_to
363363
.clone()

src/report/archives.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ mod tests {
142142
.record_result(
143143
&ex,
144144
&ex.toolchains[0],
145-
&crate1,
145+
crate1,
146146
None,
147147
&config,
148148
EncodingType::Gzip,
@@ -156,7 +156,7 @@ mod tests {
156156
.record_result(
157157
&ex,
158158
&ex.toolchains[1],
159-
&crate1,
159+
crate1,
160160
None,
161161
&config,
162162
EncodingType::Plain,
@@ -170,7 +170,7 @@ mod tests {
170170
.record_result(
171171
&ex,
172172
&ex.toolchains[0],
173-
&crate2,
173+
crate2,
174174
None,
175175
&config,
176176
EncodingType::Gzip,
@@ -184,7 +184,7 @@ mod tests {
184184
.record_result(
185185
&ex,
186186
&ex.toolchains[1],
187-
&crate2,
187+
crate2,
188188
None,
189189
&config,
190190
EncodingType::Plain,

src/report/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn render_markdown(context: &ResultsContext) -> Fallible<String> {
132132
&mut rendered,
133133
"* [{}]({}) (not covered in crater testing)",
134134
krate,
135-
crate_to_url(&krate)
135+
crate_to_url(krate)
136136
)?;
137137
for krate in deps {
138138
write_crate(&mut rendered, krate, *comparison, true)?;

0 commit comments

Comments
 (0)