Skip to content
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

fix interference between arg interchange & ref mut clone #123

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 17 additions & 5 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,19 @@ fn fold_first_block(block: P<Block>, p: &mut MutatorPlugin) -> P<Block> {
quote_stmt!(m.cx,
if ::mutagen::now($n, &$coverage_ident[$flag], $mask) { return $ident; }).unwrap());
}
let mut interchanged_self = false;
for (key, ref values) in interchangeables {
for value in values.iter() {
let key_ident = Ident::with_empty_ctxt(*key);
let value_ident = Ident::with_empty_ctxt(*value);
let target_key_ident = if key.as_str() == "self" { Ident::with_empty_ctxt(self_sym.unwrap()) } else { Ident::with_empty_ctxt(*key) };
let target_value_ident = if value.as_str() == "self" { Ident::with_empty_ctxt(self_sym.unwrap()) } else { Ident::with_empty_ctxt(*value) };
let target_key_ident = if key.as_str() == "self" {
interchanged_self = true;
Ident::with_empty_ctxt(self_sym.unwrap())
} else { key_ident };
let target_value_ident = if value.as_str() == "self" {
interchanged_self = true;
Ident::with_empty_ctxt(self_sym.unwrap())
} else { value_ident };
let n = m.add_mutations(
block.span,
avoid,
Expand All @@ -936,10 +943,15 @@ fn fold_first_block(block: P<Block>, p: &mut MutatorPlugin) -> P<Block> {
}
for name in ref_muts {
let ident = Ident::with_empty_ctxt(*name);
let target_ident = if name.as_str() == "self" {
if let Some(sym) = self_sym { Ident::with_empty_ctxt(*sym) } else { ident }
let (ident, target_ident) = if name.as_str() == "self" {
let sym_ident = Ident::with_empty_ctxt(self_sym.unwrap());
if interchanged_self {
(sym_ident, sym_ident)
} else {
(ident, sym_ident)
}
} else {
ident
(ident, ident)
};
let ident_clone = Ident::with_empty_ctxt(Symbol::gensym(&format!("_{}_clone", ident)));
let n = m.add_mutations(
Expand Down