File tree Expand file tree Collapse file tree 2 files changed +7
-22
lines changed Expand file tree Collapse file tree 2 files changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,13 @@ be ignored in favor of only building the artifacts specified by command line.
60
60
* ` --crate-type=proc-macro ` , ` #[crate_type = "proc-macro"] ` - The output
61
61
produced is not specified, but if a ` -L ` path is provided to it then the
62
62
compiler will recognize the output artifacts as a macro and it can be loaded
63
- for a program. If a crate is compiled with the ` proc-macro ` crate type it
64
- will forbid exporting any items in the crate other than those functions
65
- tagged ` #[proc_macro_derive] ` and those functions must also be placed at the
66
- crate root. Finally, the compiler will automatically set the
67
- ` cfg(proc_macro) ` annotation whenever any crate type of a compilation is the
68
- ` proc-macro ` crate type.
63
+ for a program. Crates compiled with this crate type must only export
64
+ [ procedural macros] . The compiler will automatically set the ` proc_macro `
65
+ [ configuration option] . The crates are always compiled with the same target
66
+ that the compiler itself was built with. For example, if you are executing
67
+ the compiler from Linux with an ` x86_64 ` CPU, the target will be
68
+ ` x86_64-unknown-linux-gnu ` even if the crate is a dependency of another crate
69
+ being built for a different target.
69
70
70
71
Note that these outputs are stackable in the sense that if multiple are
71
72
specified, then the compiler will produce each form of output at once without
Original file line number Diff line number Diff line change @@ -24,22 +24,6 @@ Procedural macros must be defined in a crate with the [crate type] of
24
24
> proc-macro = true
25
25
> ```
26
26
27
- Procedural macros are always compiled with the same target as the compiler
28
- itself. For example if you execute `cargo build --target
29
- arm-unknown-linux-gnueabi` then procedural macros will not be compiled for ARM,
30
- but rather your build computer (for example `x86_64-unknown-linux-gnu`).
31
-
32
- Procedural macro crates are not currently allowed to export any items except
33
- procedural macros (we'll see how to define these in a bit). For example this
34
- crate is not allowed:
35
-
36
- ```rust
37
- pub fn foo() {}
38
- ```
39
-
40
- because the ` foo ` function is not a procedural macro. Procedural macros are
41
- loaded dynamically by the compiler when they are needed during compilation.
42
-
43
27
# ## The `proc_macro` crate
44
28
45
29
Procedural macro crates almost always will link to the compiler-provided
You can’t perform that action at this time.
0 commit comments