Skip to main content

Resugaring

Trait Resugaring 

Source
pub trait Resugaring: for<'a> AstVisitorMut<'a> {
    // Required method
    fn name(&self) -> String;
}
Expand description

A resugaring is an erased mapper visitor with a name. A resugaring is a local transformation on the AST that produces exclusively ast::resugared nodes. Any involved or non-local transformation should be a phase, not a resugaring.

Backends may provide multiple resugaring phases to incrementally refine the tree into something idiomatic for the target language (e.g., desugaring pattern sugar into a more uniform core, then resugaring back into target idioms). Each phase mutates the AST in place and should be small, focused, and easy to test.

If you add a new phase, make sure it appears in the backend’s resugaring_phases() list in the correct order.

Required Methods§

Source

fn name(&self) -> String

Get the name of the resugar.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§