Skip to content

Writing a custom crate attribute is impossible with the current plugin system #15778

Closed
@Kimundi

Description

@Kimundi

Currently, its not possible to write a custom attribute that applies to the crate, due to the way syntax extensions and the module system works.

  • This does not work because inner attributes have to go first an a module body:
// crate.rs
#![feature(phase)]
#[phase(plugin)]
extern crate foo;
#![foo] // ERROR: An inner attribute is not permitted in this context
  • This does not work because the attribute gets only loaded after it got used:
// crate.rs
#![feature(phase)]
#![foo] // Gets ignored because the syntax extension did not yet get loaded
#[phase(plugin)]
extern crate foo;

Possible solutions

  • Lift the ordering restriction between items.
  • Make plugins mutual recursive visible, like regular items.

Metadata

Metadata

Assignees

Labels

A-pluginsArea: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions