File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,29 @@ these tools usually operate at a differeny layer of abstraction so it might not
269
269
A major drawback of this proposal is that it is very general, and perhaps too powerful. We're currently using the
270
270
more focused API in the eRFC, and may switch to this during experimentation if a pressing need crops up.
271
271
272
+ # # Alternative procedural macro with minimal compiler changes
273
+
274
+ The above proposal can be made even more general, minimizing the impact on the compiler.
275
+
276
+ This assumes that `#![foo]` ("inner attribute") macros work on modules and on crates.
277
+
278
+ The idea is that the compiler defines no new proc macro surface, and instead simply exposes
279
+ a `--attribute` flag. This flag, like `-Zextra-plugins`, lets you attach a proc macro attribute
280
+ to the whole crate before compiling. (This flag actually generalizes a bunch of flags that the
281
+ compiler already has)
282
+
283
+ Test crates are now simply proc macro attributes:
284
+
285
+ ```rust
286
+ # [proc_macro_attr(attributes(test, foo, bar))]
287
+ pub fn harness(crate: TokenStream) -> TokenStream {
288
+ // ...
289
+ }
290
+ ```
291
+
292
+ The cargo functionality will basically compile the file with the right dependencies
293
+ and `--attribute=your_crate::harness`.
294
+
272
295
# Unresolved questions
273
296
[unresolved]: # unresolved-questions
274
297
You can’t perform that action at this time.
0 commit comments