Skip to content

Commit 191e1e4

Browse files
committed
Improve proc_macro crate type docs
1 parent 1b2fdb7 commit 191e1e4

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

src/linkage.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ be ignored in favor of only building the artifacts specified by command line.
6060
* `--crate-type=proc-macro`, `#[crate_type = "proc-macro"]` - The output
6161
produced is not specified, but if a `-L` path is provided to it then the
6262
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.
6970

7071
Note that these outputs are stackable in the sense that if multiple are
7172
specified, then the compiler will produce each form of output at once without

src/procedural-macros.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@ Procedural macros must be defined in a crate with the [crate type] of
2424
> proc-macro = true
2525
> ```
2626
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-
4327
### The `proc_macro` crate
4428
4529
Procedural macro crates almost always will link to the compiler-provided

0 commit comments

Comments
 (0)