Skip to content

Commit 9b29e50

Browse files
authored
Fix clippy and update dependencies (#180)
* Fix clippy warnings * Update dependencies
1 parent b1886fa commit 9b29e50

23 files changed

+57
-58
lines changed

mutagen-core/Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77

88
[dependencies]
9-
serde = { version = "1.0", features = ["derive"] }
10-
serde_json = "1.0"
11-
failure = "0.1"
12-
json = "0.12"
13-
lazy_static = "1.3.0"
9+
serde = { version = "1.0.130", features = ["derive"] }
10+
serde_json = "1.0.68"
11+
failure = "0.1.8"
12+
json = "0.12.4"
13+
lazy_static = "1.4.0"
1414

15-
quote = "1.0.2"
16-
proc-macro2 = { version = "1.0.1", features = ["span-locations"] }
17-
syn = { version = "1.0.3", features = ["full", "extra-traits", "fold"] }
15+
quote = "1.0.9"
16+
proc-macro2 = { version = "1.0.29", features = ["span-locations"] }
17+
syn = { version = "1.0.76", features = ["full", "extra-traits", "fold"] }
1818

1919

2020
[features]

mutagen-core/src/comm/coverage.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ impl CoverageCollection {
6161

6262
for c in coverages {
6363
for m_id in 1..=num_mutations {
64-
if c.is_covered(m_id) {
65-
if !coverage[m_id] {
66-
num_covered += 1;
67-
coverage[m_id] = true;
68-
}
64+
if c.is_covered(m_id) && !coverage[m_id] {
65+
num_covered += 1;
66+
coverage[m_id] = true;
6967
}
7068
}
7169
}

mutagen-core/src/comm/mutation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl BakedMutation {
107107

108108
pub fn fn_name(&self) -> Option<&str> {
109109
// TODO: use Option::deref instead
110-
self.mutation.fn_name.as_ref().map(String::deref)
110+
self.mutation.fn_name.as_deref()
111111
}
112112

113113
pub fn original_code(&self) -> &str {

mutagen-core/src/comm/report.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ impl MutagenReport {
4040
let mut map = BTreeMap::new();
4141
// collect mutations by source file
4242
for (m, s) in &self.mutant_results {
43-
map.entry(m.source_file()).or_insert(vec![]).push((m, *s));
43+
map.entry(m.source_file())
44+
.or_insert_with(Vec::new)
45+
.push((m, *s));
4446
}
4547
// sort list of mutations per source file by id
46-
for (_, ms) in &mut map {
48+
for ms in map.values_mut() {
4749
ms.sort_unstable_by_key(|(m, _)| m.id());
4850
}
4951
map

mutagen-core/src/mutator/mutator_binop_bit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl MutationBinopBit {
129129

130130
fn to_mutation(self, original_expr: &ExprBinopBit, context: &TransformContext) -> Mutation {
131131
Mutation::new_spanned(
132-
&context,
132+
context,
133133
"binop_bit".to_owned(),
134134
format!("{}", original_expr.op),
135135
format!("{}", self.op),

mutagen-core/src/mutator/mutator_binop_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl MutationBinopBool {
8181

8282
fn to_mutation(self, original_op: &ExprBinopBool, context: &TransformContext) -> Mutation {
8383
Mutation::new_spanned(
84-
&context,
84+
context,
8585
"binop_bool".to_owned(),
8686
format!("{}", original_op),
8787
format!("{}", self.op),

mutagen-core/src/mutator/mutator_binop_cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl MutationBinopCmp {
8383

8484
fn to_mutation(self, original_op: &ExprBinopCmp, context: &TransformContext) -> Mutation {
8585
Mutation::new_spanned(
86-
&context,
86+
context,
8787
"binop_cmp".to_owned(),
8888
format!("{}", original_op.op),
8989
format!("{}", self.op),

mutagen-core/src/mutator/mutator_binop_eq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl MutationBinopEq {
8383

8484
fn to_mutation(self, original_op: &ExprBinopEq, context: &TransformContext) -> Mutation {
8585
Mutation::new_spanned(
86-
&context,
86+
context,
8787
"binop_eq".to_owned(),
8888
format!("{}", original_op.op),
8989
format!("{}", self.op),

mutagen-core/src/mutator/mutator_binop_num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl MutationBinopNum {
127127

128128
fn to_mutation(self, original_expr: &ExprBinopNum, context: &TransformContext) -> Mutation {
129129
Mutation::new_spanned(
130-
&context,
130+
context,
131131
"binop_num".to_owned(),
132132
format!("{}", original_expr.op),
133133
format!("{}", self.op),

mutagen-core/src/mutator/mutator_lit_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn transform(
3737
};
3838

3939
let mutator_id = transform_info.add_mutation(Mutation::new_spanned(
40-
&context,
40+
context,
4141
"lit_bool".to_owned(),
4242
format!("{:?}", e.value),
4343
format!("{:?}", !e.value),

mutagen-core/src/mutator/mutator_lit_int.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl MutationLitInt {
7979

8080
fn to_mutation(self, original_lit: &ExprLitInt, context: &TransformContext) -> Mutation {
8181
Mutation::new_spanned(
82-
&context,
82+
context,
8383
"lit_int".to_owned(),
8484
format!("{}", original_lit.value),
8585
format!("{}", self.mutate::<u128>(original_lit.value)),

mutagen-core/src/mutator/mutator_stmt_call.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ pub fn transform(
3232
};
3333

3434
let mutator_id = transform_info.add_mutation(Mutation::new_spanned(
35-
&context,
35+
context,
3636
"stmt_call".to_owned(),
37-
format!(
38-
"{}",
39-
context
40-
.original_stmt
41-
.to_token_stream()
42-
.to_string()
43-
.replace("\n", " ")
44-
),
37+
context
38+
.original_stmt
39+
.to_token_stream()
40+
.to_string()
41+
.replace("\n", " "),
4542
"".to_owned(),
4643
s.span,
4744
));
@@ -80,7 +77,7 @@ impl TryFrom<Stmt> for StmtCall {
8077
span: call.span(),
8178
call: call.into_token_stream(),
8279
}),
83-
_ => return Err(stmt),
80+
_ => Err(stmt),
8481
}
8582
}
8683
}
@@ -104,7 +101,7 @@ impl<T> StmtCallToNone for T {
104101
}
105102

106103
impl StmtCallToNone for () {
107-
fn stmt_call_to_none() -> () {}
104+
fn stmt_call_to_none() {}
108105
}
109106

110107
pub fn stmt_call_to_none<T: StmtCallToNone>() -> T {

mutagen-core/src/mutator/mutator_unop_not.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn transform(
3939
};
4040

4141
let mutator_id = transform_info.add_mutation(Mutation::new_spanned(
42-
&context,
42+
context,
4343
"unop_not".to_owned(),
4444
"!".to_owned(),
4545
"".to_owned(),

mutagen-core/src/runtime_config.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ impl MutagenRuntimeConfig {
6565
#[cfg_attr(any(test, feature = "self_test"), allow(dead_code))]
6666
// private fn `from_env` is not used when during test (cfg-switch in RUNTIME_CONFIG)
6767
fn from_env() -> Self {
68-
let mode = std::env::var("MUTAGEN_MODE").ok().unwrap_or("".to_owned());
68+
let mode = std::env::var("MUTAGEN_MODE")
69+
.ok()
70+
.unwrap_or_else(|| "".to_owned());
6971
match &*mode {
7072
"coverage" => {
7173
let num_mutations = std::env::var("MUTAGEN_NUM_MUTATIONS")
@@ -201,18 +203,18 @@ mod test_tools {
201203
/// sets the global `mutation_id` correctly before running the test and runs tests sequentially.
202204
///
203205
/// The lock is required to ensure that set `mutation_id` is valid for the complete duration of the test case.
204-
fn test_with_runtime<F: FnOnce() -> ()>(self, testcase: F) {
206+
fn test_with_runtime<F: FnOnce()>(self, testcase: F) {
205207
let lock = TEST_LOCK.lock();
206208
*RUNTIME_CONFIG.write().unwrap() = self;
207209
testcase();
208210
drop(lock); // drop here to show the extended lifetime of lock guard
209211
}
210212

211-
pub fn test_without_mutation<F: FnOnce() -> ()>(testcase: F) {
213+
pub fn test_without_mutation<F: FnOnce()>(testcase: F) {
212214
Self::test_with_runtime(Self::without_mutation(), testcase)
213215
}
214216

215-
pub fn test_with_mutation_id<F: FnOnce() -> ()>(mutation_id: usize, testcase: F) {
217+
pub fn test_with_mutation_id<F: FnOnce()>(mutation_id: usize, testcase: F) {
216218
Self::test_with_runtime(Self::with_mutation_id(mutation_id), testcase)
217219
}
218220

mutagen-core/src/transformer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use transform_info::SharedTransformInfo;
1414
pub fn do_transform_item(args: TokenStream, input: TokenStream) -> TokenStream {
1515
let input = match syn::parse2::<syn::Item>(input) {
1616
Ok(ast) => ast,
17-
Err(e) => return TokenStream::from(e.to_compile_error()),
17+
Err(e) => return e.to_compile_error(),
1818
};
19-
MutagenTransformerBundle::setup_from_attr(args.into()).mutagen_process_item(input)
19+
MutagenTransformerBundle::setup_from_attr(args).mutagen_process_item(input)
2020
}
2121

2222
pub enum MutagenTransformer {

mutagen-core/src/transformer/arg_ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl ArgAst {
8181
tt_iter: &mut impl Iterator<Item = TokenTree>,
8282
) -> Result<Self, ()> {
8383
match tt_iter.next() {
84-
None => return Ok(Self::new_fn(name, ArgAstList(vec![]))),
84+
None => Ok(Self::new_fn(name, ArgAstList(vec![]))),
8585

8686
// parse fn-variant
8787
Some(TokenTree::Group(g)) => {
@@ -90,7 +90,7 @@ impl ArgAst {
9090
}
9191
let args = ArgAstList::parse_list(g.stream())?;
9292
tt_expect_comma_or_end(tt_iter)?;
93-
return Ok(Self::new_fn(name, args));
93+
Ok(Self::new_fn(name, args))
9494
}
9595

9696
// parse eq-variant
@@ -113,9 +113,9 @@ impl ArgAst {
113113

114114
// parse value, only allow ArgFn values.
115115
let val = Self::parse_single(next, tt_iter)?.expect_fn()?;
116-
return Ok(Self::new_eq(name, val));
116+
Ok(Self::new_eq(name, val))
117117
}
118-
_ => return Err(()),
118+
_ => Err(()),
119119
}
120120
}
121121

mutagen-core/src/transformer/mutate_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl ArgOptions {
4949

5050
let ast = ArgAstList::parse_list(args)?;
5151
if let Some(conf) = ast.find_named_arg("conf")? {
52-
options.conf = Conf::parse(&conf)?;
52+
options.conf = Conf::parse(conf)?;
5353
}
5454
if let Some(transformers_arg) = ast.find_named_arg("mutators")? {
5555
match &*transformers_arg.name {

mutagen-runner/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ edition = "2018"
66
license = "Apache-2.0/MIT"
77

88
[dependencies]
9-
json = "0.12"
10-
failure = "0.1"
9+
json = "0.12.4"
10+
failure = "0.1.8"
1111
wait-timeout = "0.2.0"
12-
serde_json = "1.0"
12+
serde_json = "1.0.68"
1313
mutagen-core = { path = "../mutagen-core"}
14-
console = "0.14.0"
15-
humantime = "2.0.0"
16-
structopt = "0.3"
14+
console = "0.14.1"
15+
humantime = "2.1.0"
16+
structopt = "0.3.23"
1717

1818
[badges]
1919
travis-ci = { repository = "llogiq/mutagen", branch = "master" }

mutagen-runner/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn run() -> Fallible<()> {
7070
let test_bins = test_bins
7171
.iter()
7272
.enumerate()
73-
.map(|(i, e)| TestBin::new(&e, i))
73+
.map(|(i, e)| TestBin::new(e, i))
7474
.filter_map(|bin| {
7575
bin.run_test(&mut progress, &mutations)
7676
.map(|bin| Some(bin).filter(|bin| bin.coveres_any_mutation()))

mutagen-runner/src/progress.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Progress {
133133
let bar = ProgressBarState {
134134
action: "Test Mutants",
135135
current: self.tested_mutations,
136-
action_details: action_details,
136+
action_details,
137137
};
138138
self.bar.set_state(bar)?;
139139
}

mutagen-runner/src/progress_bar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl ProgressBar {
109109

110110
/// clears the progress bar
111111
pub fn clear_bar(&mut self) -> Fallible<()> {
112-
if let Some(_) = self.current_bar_state.take() {
112+
if self.current_bar_state.take().is_some() {
113113
self.term.clear_line()?;
114114
}
115115
Ok(())

mutagen-runner/src/test_bin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'a> TestBin<'a> {
4040
let num_mutations = mutations.len();
4141
let test_start = Instant::now();
4242

43-
progress.start_testsuite_unmutated(&self.bin_path, self.id)?;
43+
progress.start_testsuite_unmutated(self.bin_path, self.id)?;
4444

4545
::std::io::stdout().flush()?;
4646

@@ -71,7 +71,7 @@ impl<'a> TestBin<'a> {
7171
// delete coverage file after the execution of this testsuite
7272
fs::remove_file(coverage_file)?;
7373

74-
CoverageCollection::from_coverage_hits(num_mutations, &coverage_hits, &mutations)
74+
CoverageCollection::from_coverage_hits(num_mutations, &coverage_hits, mutations)
7575
}
7676
};
7777

mutagen-transform/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "Apache-2.0/MIT"
77

88
[dependencies]
99
mutagen-core = { path = "../mutagen-core" }
10-
proc-macro2 = "1.0.1"
10+
proc-macro2 = "1.0.29"
1111

1212
[lib]
1313
proc_macro = true

0 commit comments

Comments
 (0)