pub struct TransformCtx {
pub options: TransformOptions,
pub translated: TranslatedCrate,
pub errors: RefCell<ErrorCtx>,
}
Expand description
Simpler context used for rustc-independent code transformation. This only depends on rustc for its error reporting machinery.
Fields§
§options: TransformOptions
The options that control transformation.
translated: TranslatedCrate
The translated data.
errors: RefCell<ErrorCtx>
Context for tracking and reporting errors.
Implementations§
source§impl<'ctx> TransformCtx
impl<'ctx> TransformCtx
pub(crate) fn has_errors(&self) -> bool
sourcepub(crate) fn span_err(&self, span: Span, msg: &str) -> Error
pub(crate) fn span_err(&self, span: Span, msg: &str) -> Error
Span an error and register the error.
pub(crate) fn with_def_id<F, T>(
&mut self,
def_id: impl Into<AnyTransId>,
def_id_is_local: bool,
f: F,
) -> Twhere
F: FnOnce(&mut Self) -> T,
sourcepub(crate) fn for_each_body(&mut self, f: impl FnMut(&mut Self, &mut Body))
pub(crate) fn for_each_body(&mut self, f: impl FnMut(&mut Self, &mut Body))
Mutably iterate over the bodies.
Warning: we replace each body with Err(Opaque)
while inspecting it so we can keep access
to the rest of the crate.
pub(crate) fn for_each_structured_body( &mut self, f: impl FnMut(&mut Self, &mut ExprBody), )
sourcepub(crate) fn for_each_fun_decl(
&mut self,
f: impl FnMut(&mut Self, &mut FunDecl),
)
pub(crate) fn for_each_fun_decl( &mut self, f: impl FnMut(&mut Self, &mut FunDecl), )
Mutably iterate over the function declarations.
Warning: each inspected fundecl becomes inaccessible from ctx
during the course of this function.
Trait Implementations§
source§impl Display for TransformCtx
impl Display for TransformCtx
Auto Trait Implementations§
impl !Freeze for TransformCtx
impl !RefUnwindSafe for TransformCtx
impl Send for TransformCtx
impl !Sync for TransformCtx
impl Unpin for TransformCtx
impl UnwindSafe for TransformCtx
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
Mutably borrows from an owned value. Read more
§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
§impl<T> Indentable for Twhere
T: Display,
impl<T> Indentable for Twhere
T: Display,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more