Tracking issue for RFC 1566: Procedural macros · Issue #38356 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@aturon

Description

@aturon

Current Status

This issue has been closed in favor of more fine-grained tracking issues

~~~Updated Description~~~

Next steps:

Possible Stabilization Showstoppers

Original Description

RFC.

This RFC proposes an evolution of Rust's procedural macro system (aka syntax
extensions, aka compiler plugins). This RFC specifies syntax for the definition
of procedural macros, a high-level view of their implementation in the compiler,
and outlines how they interact with the compilation process.

At the highest level, macros are defined by implementing functions marked with
a #[macro] attribute. Macros operate on a list of tokens provided by the
compiler and return a list of tokens that the macro use is replaced by. We
provide low-level facilities for operating on these tokens. Higher level
facilities (e.g., for parsing tokens to an AST) should exist as library crates.

Roadmap: #38356 (comment).


Tasks

#[derive(Trait, OtherTrait)] struct S; // Both these derives should resolve macro_rules! m { () => { #[macro_use(Trait)] extern crate derives; use derives::OtherTrait; // this kind of import is gated behind #![feature(proc_macro)] } } m!();