Skip to content

Commit 720cc36

Browse files
committed
Document -Z crate-attr
1 parent 385970f commit 720cc36

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# `crate-attr`
2+
3+
The tracking issue for this feature is: [#138287](https://github.com/rust-lang/rust/issues/138287).
4+
5+
------------------------
6+
7+
The `-Z crate-attr` flag allows you to inject attributes into the crate root.
8+
For example, `-Z crate-attr=crate_name="test"` acts as if `#![crate_name="test"]` were present before the first source line of the crate root.
9+
10+
To inject multiple attributes, pass `-Z crate-attr` multiple times.
11+
12+
Formally, the expansion behaves as follows:
13+
1. The crate is parsed as if `-Z crate-attr` were not present.
14+
2. The attributes in `-Z crate-attr` are parsed and validated.
15+
3. The attributes are injected at the top of the crate root.
16+
4. Macro expansion is performed.

0 commit comments

Comments
 (0)