will not clash. The following code will print "Hello!" only once:
~~~
-#[feature(macro_rules)];
+#![feature(macro_rules)]
macro_rules! loop_x (
($e: expr) => (
# Managed Pointers
> **Note**: the `@` form of managed pointers is deprecated and behind a
-> feature gate (it requires a `#[feature(managed_pointers)];` attribute on
+> feature gate (it requires a `#![feature(managed_pointers)]` attribute on
> the crate root; remember the semicolon!). There are replacements, currently
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
> counting and garbage collection respectively.
For example:
~~~
-# #[allow(unused_imports)];
+# #![allow(unused_imports)]
extern crate test;
use std::slice;
it entirely.
~~~
-# #[allow(unused_imports)];
+# #![allow(unused_imports)]
extern crate test;
use test::BenchHarness;
# Avoiding the standard library
By default, `std` is linked to every Rust crate. In some contexts,
-this is undesirable, and can be avoided with the `#[no_std];`
+this is undesirable, and can be avoided with the `#![no_std]`
attribute attached to the crate.
```ignore
# // FIXME #12903: linking failures due to no_std
// the minimal library
-#[crate_type="lib"];
-#[no_std];
+#![crate_type="lib"]
+#![no_std]
# // fn main() {} tricked you, rustdoc!
```
```ignore
# // FIXME #12903: linking failures due to no_std
-#[no_std];
+#![no_std]
extern "rust-intrinsic" { fn abort() -> !; }
#[no_mangle] pub extern fn rust_stack_exhausted() {
```
To override the compiler-inserted `main` shim, one has to disable it
-with `#[no_main];` and then create the appropriate symbol with the
+with `#![no_main]` and then create the appropriate symbol with the
correct ABI and the correct name, which requires overriding the
compiler's name mangling too:
```ignore
# // FIXME #12903: linking failures due to no_std
-#[no_std];
-#[no_main];
+#![no_std]
+#![no_main]
extern "rust-intrinsic" { fn abort() -> !; }
#[no_mangle] pub extern fn rust_stack_exhausted() {
```ignore
# // FIXME #12903: linking failures due to no_std
-#[no_std];
+#![no_std]
#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
extern {
#: src/doc/rust.md:627
#, fuzzy
#| msgid "// Turn on a warning #[warn(non_camel_case_types)]"
-msgid "// Turn on a warning #[ warn(non_camel_case_types) ]; ~~~~"
+msgid "// Turn on a warning #![ warn(non_camel_case_types) ] ~~~~"
msgstr ""
"// 警告を有効にする\n"
"#[warn(non_camel_case_types)]"
#. type: Plain text
#: src/doc/tutorial.md:3134
#, fuzzy
-#| msgid "// Make a library (\"bin\" is the default) #[crate_type = \"lib\"];"
+#| msgid "// Make a library (\"bin\" is the default) #![crate_type = \"lib\"]"
msgid ""
"// This crate is a library (\"bin\" is the default) #[crate_id = "
-"\"farm#2.5\"]; #[crate_type = \"lib\"];"
+"\"farm#2.5\"]; #![crate_type = \"lib\"]"
msgstr ""
"// ライブラリを作成する (\"bin\" がデフォルト値)\n"
-"#[crate_type = \"lib\"];"
+"#![crate_type = \"lib\"]"
#. type: Plain text
#: src/doc/tutorial.md:3139
#: src/doc/tutorial.md:3153
#, fuzzy
#| msgid ""
-#| "~~~~ // world.rs #[link(name = \"world\", vers = \"1.0\")]; pub fn "
+#| "~~~~ // world.rs #![link(name = \"world\", vers = \"1.0\")] pub fn "
#| "explore() -> &str { \"world\" } ~~~~"
msgid ""
-"~~~~ // `world.rs` #[crate_id = \"world#0.42\"]; # extern crate extra; pub fn "
+"~~~~ // `world.rs` #![crate_id = \"world#0.42\"] # extern crate extra; pub fn "
"explore() -> &'static str { \"world\" } # fn main() {} ~~~~"
msgstr ""
"~~~~\n"
"// world.rs\n"
-"#[link(name = \"world\", vers = \"1.0\")];\n"
+"#![link(name = \"world\", vers = \"1.0\")]\n"
"pub fn explore() -> &str { \"world\" }\n"
"~~~~"
~~~
// the "link" crate attribute is currently required for rustdoc, but normally
// isn't needed.
-#[crate_id = "universe"];
-#[crate_type="lib"];
+#![crate_id = "universe"]
+#![crate_type="lib"]
//! Tools for dealing with universes (this is a doc comment, and is shown on
//! the crate index page. The ! makes it apply to the parent of the comment,
~~~~
// `lib.rs`
-# #[crate_type = "lib"];
-#[crate_id = "farm#2.5"];
+# #![crate_type = "lib"]
+#![crate_id = "farm#2.5"]
// ...
# fn farm() {}
// ...
// This crate is a library ("bin" is the default)
-#[crate_id = "farm#2.5"];
-#[crate_type = "lib"];
+#![crate_id = "farm#2.5"]
+#![crate_type = "lib"]
// Turn on a warning
#[warn(non_camel_case_types)]
~~~~
// `world.rs`
-#[crate_id = "world#0.42"];
+#![crate_id = "world#0.42"]
# mod secret_module_to_make_this_test_run {
pub fn explore() -> &'static str { "world" }
~~~
// In the crate root:
-#[no_std];
+#![no_std]
~~~
~~~
// In any module:
-#[no_implicit_prelude];
+#![no_implicit_prelude]
~~~
See the [API documentation][stddoc] for details.