Skip to content

Commit 7416ae3

Browse files
Fix crate_type attribute examples
As a crate-level attribute, this must be an inner attribute.
1 parent 18c8dd6 commit 7416ae3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/linkage.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ through the usage of either command line flags or the `crate_type` attribute.
1515
If one or more command line flags are specified, all `crate_type` attributes will
1616
be ignored in favor of only building the artifacts specified by command line.
1717

18-
* `--crate-type=bin`, `#[crate_type = "bin"]` - A runnable executable will be
18+
* `--crate-type=bin`, `#![crate_type = "bin"]` - A runnable executable will be
1919
produced. This requires that there is a `main` function in the crate which
2020
will be run when the program begins executing. This will link in all Rust and
2121
native dependencies, producing a single distributable binary.
2222
This is the default crate type.
2323

24-
* `--crate-type=lib`, `#[crate_type = "lib"]` - A Rust library will be produced.
24+
* `--crate-type=lib`, `#![crate_type = "lib"]` - A Rust library will be produced.
2525
This is an ambiguous concept as to what exactly is produced because a library
2626
can manifest itself in several forms. The purpose of this generic `lib` option
2727
is to generate the "compiler recommended" style of library. The output library
@@ -30,14 +30,14 @@ be ignored in favor of only building the artifacts specified by command line.
3030
libraries, and the `lib` type can be seen as an alias for one of them (but the
3131
actual one is compiler-defined).
3232

33-
* `--crate-type=dylib`, `#[crate_type = "dylib"]` - A dynamic Rust library will
33+
* `--crate-type=dylib`, `#![crate_type = "dylib"]` - A dynamic Rust library will
3434
be produced. This is different from the `lib` output type in that this forces
3535
dynamic library generation. The resulting dynamic library can be used as a
3636
dependency for other libraries and/or executables. This output type will
3737
create `*.so` files on Linux, `*.dylib` files on macOS, and `*.dll` files on
3838
Windows.
3939

40-
* `--crate-type=staticlib`, `#[crate_type = "staticlib"]` - A static system
40+
* `--crate-type=staticlib`, `#![crate_type = "staticlib"]` - A static system
4141
library will be produced. This is different from other library outputs in that
4242
the compiler will never attempt to link to `staticlib` outputs. The
4343
purpose of this output type is to create a static library containing all of
@@ -47,21 +47,21 @@ be ignored in favor of only building the artifacts specified by command line.
4747
linking Rust code into an existing non-Rust application
4848
because it will not have dynamic dependencies on other Rust code.
4949

50-
* `--crate-type=cdylib`, `#[crate_type = "cdylib"]` - A dynamic system
50+
* `--crate-type=cdylib`, `#![crate_type = "cdylib"]` - A dynamic system
5151
library will be produced. This is used when compiling
5252
a dynamic library to be loaded from another language. This output type will
5353
create `*.so` files on Linux, `*.dylib` files on macOS, and `*.dll` files on
5454
Windows.
5555

56-
* `--crate-type=rlib`, `#[crate_type = "rlib"]` - A "Rust library" file will be
56+
* `--crate-type=rlib`, `#![crate_type = "rlib"]` - A "Rust library" file will be
5757
produced. This is used as an intermediate artifact and can be thought of as a
5858
"static Rust library". These `rlib` files, unlike `staticlib` files, are
5959
interpreted by the compiler in future linkage. This essentially means
6060
that `rustc` will look for metadata in `rlib` files like it looks for metadata
6161
in dynamic libraries. This form of output is used to produce statically linked
6262
executables as well as `staticlib` outputs.
6363

64-
* `--crate-type=proc-macro`, `#[crate_type = "proc-macro"]` - The output
64+
* `--crate-type=proc-macro`, `#![crate_type = "proc-macro"]` - The output
6565
produced is not specified, but if a `-L` path is provided to it then the
6666
compiler will recognize the output artifacts as a macro and it can be loaded
6767
for a program. Crates compiled with this crate type must only export

0 commit comments

Comments
 (0)