pub enum ExtractionRefusal {
Show 16 variants
UnsupportedLanguage(&'static str),
ParseFailed,
EmptyRange,
NotContiguousSiblings,
NotInsideFunction,
EnclosingFunctionNotHoistable,
ControlFlowEscapes(&'static str),
RebindsOuterScope(String),
NameCollision(String),
MultipleReturnsUnsupported(&'static str),
MixedReturnDeclarations,
MovedNameUsedAfterRange(String),
ReturnsThroughTailExpression,
ReferencesReceiver(&'static str),
AssignsUndeclaredName(String),
UnspellableParameterType(String),
}Expand description
Why an extraction was refused.
Each variant names one invariant. A refusal is a first-class result here for
the same reason it is in edit-intents: an extraction that guesses is worse
than one that declines.
Variants§
UnsupportedLanguage(&'static str)
The language has no extraction emitter yet.
ParseFailed
The source could not be parsed at all.
EmptyRange
No statement starts inside the requested line range.
NotContiguousSiblings
The selected statements do not share one block, so they are not a contiguous run of siblings.
NotInsideFunction
The range is not inside a function body.
EnclosingFunctionNotHoistable
The enclosing function is not itself a statement — it is a method, or a function expression bound into a larger expression — so there is nowhere beside it to put a new function without changing what the new function is.
ControlFlowEscapes(&'static str)
Control flow leaves the range: hoisting it changes what it does, and no signature can carry that.
RebindsOuterScope(String)
The range assigns a name the enclosing function declared global or
nonlocal; the assignment’s effect is outside the new function’s scope.
NameCollision(String)
The extracted name already binds something visible at the call site.
MultipleReturnsUnsupported(&'static str)
The extraction would have to return several values in a language with no spelling for that which keeps the call site one statement.
MixedReturnDeclarations
Some returned names were declared inside the range and others already existed outside it. One call site cannot both declare and assign, and splitting it into two statements would change what a caller reads.
MovedNameUsedAfterRange(String)
A name the range needs would have to be moved into the new function and is still read afterwards. Passing it by reference instead would mean rewriting every use in the body into a dereference, which is a body rewrite this intent does not do.
ReturnsThroughTailExpression
The range covers the block’s trailing expression — the value the enclosing function returns. Hoisting it would hand that value to the new function and leave the caller returning nothing.
ReferencesReceiver(&'static str)
The range names the receiver the enclosing function was called on.
Unlike Python’s self, this is not a name a derived signature can
carry, and it means something different inside a plain function.
AssignsUndeclaredName(String)
The range assigns a name it does not declare, and that name is not a local of the enclosing function either. Declaring it inside the new function would shadow an outer binding or turn a global into a local; leaving it undeclared would write to a scope the caller did not mean.
UnspellableParameterType(String)
A parameter’s type cannot be copied from an existing annotation, and
this language requires one. Writing unknown — or leaving it implicitly
any — would produce a signature that type-checks and means nothing.
Implementations§
Trait Implementations§
Source§impl Clone for ExtractionRefusal
impl Clone for ExtractionRefusal
Source§fn clone(&self) -> ExtractionRefusal
fn clone(&self) -> ExtractionRefusal
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more