Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Phase 3: Automatic Weaving

The breakthrough feature enabling AspectJ-style annotation-free AOP.

The Vision

Phase 1-2: Per-function annotation required

#![allow(unused)]
fn main() {
#[aspect(LoggingAspect::new())]  // Repeated for every function
fn my_function() { }
}

Phase 3: Pattern-based automatic weaving

#![allow(unused)]
fn main() {
#[advice(
    pointcut = "execution(pub fn *(..)) && within(crate::api)",
    advice = "before"
)]
static LOGGER: LoggingAspect = LoggingAspect::new();

// No annotation needed - automatically woven!
pub fn api_handler() { }
}

Technical Achievement

Phase 3 uses:

  • rustc-driver to compile code
  • TyCtxt to access type information
  • MIR extraction to analyze functions
  • Function pointers to register aspects globally
  • Pointcut matching to determine which functions get woven

This is a major breakthrough - the first Rust AOP framework with automatic weaving!

See The Vision for details.