cargo-mutants
cargo-mutants copied to clipboard
'impl trait' representation in mutant names can be wrong vs Rust source
For example from https://github.com/sourcefrog/conserve/blob/main/src/apath.rs
impl AsRef<str> for Apath {
fn as_ref(&self) -> &str {
&self.0
}
}
impl From<Apath> for String {
fn from(a: Apath) -> String {
a.0
}
}
impl<'a> From<&'a str> for Apath {
fn from(s: &'a str) -> Apath {
assert!(Apath::is_valid(s), "invalid apath: {s:?}");
Apath(s.to_string())
}
}
it's reported as
src/apath.rs:190:9: replace <impl AsRef for Apath>::as_ref -> &str with ""
src/apath.rs:138:9: replace <impl From for String>::from -> String with String::new()
src/apath.rs:138:9: replace <impl From for String>::from -> String with "xyzzy".into()
src/apath.rs:144:9: replace <impl From for Apath>::from -> Apath with Default::default()
src/apath.rs:151:9: replace <impl From for Apath>::from -> Apath with Default::default()
You can still basically see what it's talking about but it's a bit unclear.
A couple of options:
- Build the name by copying more of the AST
- Or, explicitly copy the type parameters.
In any case, add some tests for this.