Skip to main content

ExtractionRefusal

Enum ExtractionRefusal 

Source
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§

Source§

impl ExtractionRefusal

Source

pub fn message(&self) -> String

A one-line message naming the failed invariant.

Trait Implementations§

Source§

impl Clone for ExtractionRefusal

Source§

fn clone(&self) -> ExtractionRefusal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtractionRefusal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ExtractionRefusal

Source§

impl PartialEq for ExtractionRefusal

Source§

fn eq(&self, other: &ExtractionRefusal) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExtractionRefusal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.