pub enum MutationSpec {
Show 51 variants
Rename {
target: MutationTargetSymbol,
to: String,
scope: Scope,
},
AddField {
target: MutationTargetSymbol,
field_name: String,
field_type: String,
visibility: Visibility,
},
RemoveField {
target: MutationTargetSymbol,
field_name: String,
},
ChangeVisibility {
target: MutationTargetSymbol,
visibility: Visibility,
},
AddDerive {
target: MutationTargetSymbol,
derives: Vec<String>,
},
RemoveDerive {
target: MutationTargetSymbol,
derives: Vec<String>,
},
AddVariant {
target: MutationTargetSymbol,
variant_name: String,
variant_kind: VariantKind,
},
RemoveVariant {
target: MutationTargetSymbol,
variant_name: String,
},
AddMatchArm {
target: MutationTargetSymbol,
enum_name: String,
pattern: String,
body: String,
},
RemoveMatchArm {
target: MutationTargetSymbol,
enum_name: String,
pattern: String,
},
ReplaceMatchArm {
target: MutationTargetSymbol,
enum_name: String,
old_pattern: String,
new_pattern: String,
new_body: String,
},
AddStructLiteralField {
target: MutationTargetSymbol,
field_name: String,
value: String,
},
RemoveStructLiteralField {
target: MutationTargetSymbol,
field_name: String,
},
AddItem {
target: MutationTargetSymbol,
content: String,
position: InsertPosition,
},
RemoveItem {
target: MutationTargetSymbol,
item_kind: ItemKind,
},
AddSpec {
type_id: SymbolId,
module_id: SymbolId,
group: String,
alias_name: Option<String>,
relations: Vec<SpecRelation>,
},
RemoveSpec {
type_id: SymbolId,
module_id: SymbolId,
},
ValidateSpec {
type_ids: Vec<SymbolId>,
expected_group: Option<String>,
validate_relations: bool,
},
AddMethod {
target: MutationTargetSymbol,
method_name: String,
params: Vec<(String, String)>,
return_type: Option<String>,
body: String,
is_pub: bool,
self_param: Option<SelfParam>,
},
RemoveMethod {
target: MutationTargetSymbol,
method_name: String,
},
RemoveMod {
target: MutationTargetSymbol,
mod_name: String,
},
CreateMod {
target: MutationTargetSymbol,
mod_name: String,
content: String,
is_pub: bool,
},
OrganizeImports {
module_id: Option<SymbolId>,
deduplicate: bool,
merge_groups: bool,
},
LoopToIterator {
module_id: Option<SymbolId>,
target_var: Option<String>,
},
UnwrapToQuestion {
module_id: Option<SymbolId>,
target_fn: Option<SymbolId>,
include_expect: bool,
},
AssignOp {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
},
BoolSimplify {
module_id: Option<SymbolId>,
},
CloneOnCopy {
module_id: Option<SymbolId>,
},
CollapsibleIf {
module_id: Option<SymbolId>,
},
NoOpArmToTodo {
module_id: Option<SymbolId>,
replacement: String,
},
ComparisonToMethod {
module_id: Option<SymbolId>,
},
RedundantClosure {
module_id: Option<SymbolId>,
},
IntroduceVariable {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
expr: String,
var_name: String,
},
ManualMap {
module_id: Option<SymbolId>,
},
MatchToIfLet {
module_id: Option<SymbolId>,
},
FilterNext {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
},
MapUnwrapOr {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
},
ReplaceExpr {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
old_expr: String,
new_expr: String,
replace_all: bool,
symbol_path: Option<String>,
},
RemoveStatement {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
pattern: String,
remove_all: bool,
symbol_path: Option<String>,
},
InsertStatement {
module_id: Option<SymbolId>,
fn_id: SymbolId,
stmt: String,
position: StmtInsertPosition,
reference_pattern: Option<String>,
symbol_path: Option<String>,
},
ReplaceStatement {
module_id: Option<SymbolId>,
fn_id: Option<SymbolId>,
old_stmt: String,
new_stmt: String,
symbol_path: Option<String>,
},
ExtractTrait {
target: MutationTargetSymbol,
trait_name: String,
methods: Option<Vec<String>>,
},
InlineTrait {
target: MutationTargetSymbol,
struct_name: String,
remove_trait: bool,
},
ReplaceType {
target: MutationTargetSymbol,
to_type: TypeTransform,
scope: Option<SymbolPath>,
contexts: Option<Vec<TypeContext>>,
},
EnumToTrait {
target: MutationTargetSymbol,
trait_name: Option<String>,
remove_enum: bool,
strategy: EnumToTraitStrategy,
match_handling: MatchHandling,
},
MoveItem {
source: MutationTargetSymbol,
target: MutationTargetSymbol,
item_name: String,
item_kind: ItemKind,
add_use: bool,
},
PluginTransform {
plugin_name: String,
target_id: Option<SymbolId>,
file_patterns: Vec<String>,
config: Value,
},
DuplicateFunction {
target: MutationTargetSymbol,
to: String,
},
DuplicateStruct {
target: MutationTargetSymbol,
to: String,
include_impls: bool,
},
DuplicateEnum {
target: MutationTargetSymbol,
to: String,
include_impls: bool,
},
DuplicateModTree {
target: MutationTargetSymbol,
to: String,
},
}Expand description
Atomic mutation specification
Variants§
Rename
Rename an identifier across scope
Fields
target: MutationTargetSymbolTarget symbol (supports lazy resolution)
AddField
Add a field to a struct
RemoveField
Remove a field from a struct
ChangeVisibility
Change visibility of an item or struct field
AddDerive
Add derive macros to a type
RemoveDerive
Remove derive macros from a type
AddVariant
Add a variant to an enum
Fields
target: MutationTargetSymbolTarget enum (supports lazy resolution)
variant_kind: VariantKindRemoveVariant
Remove a variant from an enum
AddMatchArm
Add a match arm to a match expression
Used to fix exhaustiveness errors when adding enum variants.
Fields
target: MutationTargetSymbolTarget function/method containing the match expression
RemoveMatchArm
Remove a match arm from a match expression
Used to remove arms when deleting enum variants.
Fields
target: MutationTargetSymbolTarget function/method containing the match expression
ReplaceMatchArm
Replace a match arm (pattern + body) in a match expression
Unlike ReplaceExpr which only replaces the body, this replaces both the pattern and body atomically. Useful when pattern bindings need to change along with the body.
Fields
target: MutationTargetSymbolTarget function/method containing the match expression
AddStructLiteralField
Add a field to all struct literals of a given type
Used to fix missing field errors when adding struct fields.
Fields
target: MutationTargetSymbolTarget struct (supports lazy resolution)
RemoveStructLiteralField
Remove a field from all struct literals of a given type
Used to update struct literals when removing struct fields.
Fields
target: MutationTargetSymbolTarget struct (supports lazy resolution)
AddItem
Add an item (struct, fn, impl, etc.)
Fields
target: MutationTargetSymbolTarget module (supports lazy resolution)
position: InsertPositionInsert position within the module
RemoveItem
Remove an item
AddSpec
Add a Spec TypeAlias (Spec<Group, T> or SpecWith<Group, R, T>)
Fields
relations: Vec<SpecRelation>Relations (up to 3)
RemoveSpec
Remove a Spec TypeAlias
Fields
ValidateSpec
Validate existing Spec definitions
Fields
AddMethod
Add a method to an impl block
Fields
target: MutationTargetSymbolTarget impl block (supports lazy resolution)
RemoveMethod
Remove a method from an impl block
Fields
target: MutationTargetSymbolTarget impl block (supports lazy resolution)
RemoveMod
Remove a module declaration
Fields
target: MutationTargetSymbolTarget parent module (supports lazy resolution)
CreateMod
Create a new module (adds to module tree)
Fields
target: MutationTargetSymbolTarget parent module (supports lazy resolution)
OrganizeImports
Organize imports (sort, dedupe, merge)
Fields
LoopToIterator
Convert loop to iterator
UnwrapToQuestion
Convert unwrap/expect to ? operator
Fields
AssignOp
Simplify assign operations: a = a + b → a += b
Fields
BoolSimplify
Simplify boolean comparisons: x == true → x, x == false → !x
CloneOnCopy
Remove redundant .clone() on Copy types
CollapsibleIf
Merge nested if statements into single if with &&
NoOpArmToTodo
Replace empty/noop match arms with todo!/unimplemented!/unreachable!
_ => {} → _ => todo!() or _ => unreachable!()
Fields
ComparisonToMethod
Convert comparisons to method calls: s == "" → s.is_empty()
RedundantClosure
Remove redundant closures: |x| f(x) → f
IntroduceVariable
Introduce variable for repeated expressions Expression is specified as string and parsed at runtime
Fields
ManualMap
Convert manual match on Option to .map(): match opt { Some(x) => Some(f(x)), None => None } → opt.map(f)
MatchToIfLet
Convert simple match to if let
FilterNext
Convert .filter().next() to .find()
Fields
MapUnwrapOr
Convert .map().unwrap_or() to .map_or()
Fields
ReplaceExpr
Replace an expression with another expression
Target can be specified by:
old_expr: Pattern matching (searches for matching expressions)symbol_path: Direct position (e.g., “crate::fn::$body::0::1”)
Fields
RemoveStatement
Remove statements matching a pattern
Target can be specified by:
pattern: Pattern matching (searches for matching statements)symbol_path: Direct position (e.g., “crate::fn::$body::2”)
Fields
InsertStatement
Insert a statement at a specific position
Position can be specified by:
position+reference_pattern: Traditional modesymbol_path: Direct position (inserts after $body::N)
Fields
position: StmtInsertPositionInsert position
ReplaceStatement
Replace a statement with another statement
Target can be specified by:
old_stmt: Pattern matching (searches for matching statements)symbol_path: Direct position (e.g., “crate::fn::$body::1”)
Fields
ExtractTrait
Extract a trait from an impl block
Fields
target: MutationTargetSymbolTarget impl block (supports lazy resolution)
InlineTrait
Inline a trait back into inherent impl
Fields
target: MutationTargetSymbolTarget trait (supports lazy resolution)
ReplaceType
Replace all occurrences of a type with a transformed type
§Examples
// Replace Status with Box<dyn Status>
MutationSpec::ReplaceType {
from_type: "Status".to_string(),
to_type: TypeTransform::BoxDyn { trait_name: "Status".to_string() },
scope: None,
contexts: None,
}Fields
target: MutationTargetSymbolTarget type to replace (supports lazy resolution)
to_type: TypeTransformHow to transform the type
scope: Option<SymbolPath>Scope to limit replacements (None = entire crate)
contexts: Option<Vec<TypeContext>>Which contexts to replace in (None = all contexts)
EnumToTrait
Convert an enum to a trait with struct implementations
Transforms:
enum Status { Running, Stopped }into:pub trait Status {}pub struct Running;pub struct Stopped;impl Status for Running {}impl Status for Stopped {}
Also updates all usage sites: Status::Running → Running
§Type Replacement
With strategy: dynamic (default):
fn process(status: Status)→fn process(status: Box<dyn Status>)
With strategy: static:
fn process(status: Status)→fn process(status: impl Status)
With strategy: marker_only:
- No type replacement (manual migration required)
Fields
target: MutationTargetSymbolTarget enum (supports lazy resolution)
strategy: EnumToTraitStrategyType replacement strategy (default: dynamic = Box
match_handling: MatchHandlingHow to handle match expressions (default: warn_only)
MoveItem
Move an item from one file to another
Fields
source: MutationTargetSymbolSource module (supports lazy resolution)
target: MutationTargetSymbolTarget module (supports lazy resolution)
PluginTransform
Execute a WASM plugin transform
Fields
DuplicateFunction
Duplicate a function with a new name
Fields
target: MutationTargetSymbolTarget function (supports lazy resolution)
DuplicateStruct
Duplicate a struct with a new name (including impl blocks)
Fields
target: MutationTargetSymbolTarget struct (supports lazy resolution)
DuplicateEnum
Duplicate an enum with a new name (including impl blocks)
Fields
target: MutationTargetSymbolTarget enum (supports lazy resolution)
DuplicateModTree
Duplicate an inline module with a new name
Fields
target: MutationTargetSymbolTarget module (supports lazy resolution)
Implementations§
Source§impl MutationSpec
impl MutationSpec
Sourcepub fn kind_name(&self) -> &'static str
pub fn kind_name(&self) -> &'static str
Get the kind name of this spec (e.g., “Rename”, “AddField”)
Used by MutationRegistry to route specs to appropriate converters. TODO: Consider typed approach (enum variant discriminant or macro-based)
Sourcepub fn is_additive(&self) -> bool
pub fn is_additive(&self) -> bool
Check if this is an additive operation (order-independent within same target)
Additive operations like AddItem, AddMethod, AddField etc. can be applied
in any order to the same target without conflict, unless they add the
same named item (detected via additive_identity).
Sourcepub fn additive_identity(&self) -> Option<String>
pub fn additive_identity(&self) -> Option<String>
Get unique identity for additive operations (for duplicate detection)
Returns a unique identifier for what this operation adds.
Two additive operations with the same additive_identity targeting the
same parent are true conflicts (trying to add the same thing twice).
Sourcepub fn get_targets(&self) -> Vec<&MutationTargetSymbol>
pub fn get_targets(&self) -> Vec<&MutationTargetSymbol>
Get target symbols from this spec.
Returns references to all MutationTargetSymbol fields in this spec.
Used for computing affected_symbols after mutation execution.
Trait Implementations§
Source§impl Clone for MutationSpec
impl Clone for MutationSpec
Source§fn clone(&self) -> MutationSpec
fn clone(&self) -> MutationSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MutationSpec
impl Debug for MutationSpec
Source§impl<'de> Deserialize<'de> for MutationSpec
impl<'de> Deserialize<'de> for MutationSpec
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MutationSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MutationSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<CascadeSpec> for MutationSpec
impl From<CascadeSpec> for MutationSpec
Source§fn from(cascade: CascadeSpec) -> MutationSpec
fn from(cascade: CascadeSpec) -> MutationSpec
Source§impl PartialEq for MutationSpec
impl PartialEq for MutationSpec
Source§fn eq(&self, other: &MutationSpec) -> bool
fn eq(&self, other: &MutationSpec) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MutationSpec
impl Serialize for MutationSpec
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for MutationSpec
Auto Trait Implementations§
impl Freeze for MutationSpec
impl RefUnwindSafe for MutationSpec
impl Send for MutationSpec
impl Sync for MutationSpec
impl Unpin for MutationSpec
impl UnsafeUnpin for MutationSpec
impl UnwindSafe for MutationSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more