Update tutorials to use new attribute syntax (#13476)

This commit is contained in:
Manish Goregaokar 2014-04-12 09:03:16 +05:30
parent b2b2bbb628
commit d0aed0995b
8 changed files with 28 additions and 28 deletions

View file

@ -407,7 +407,7 @@ As an example, `loop` and `for-loop` labels (discussed in the lifetimes guide)
will not clash. The following code will print "Hello!" only once: will not clash. The following code will print "Hello!" only once:
~~~ ~~~
#[feature(macro_rules)]; #![feature(macro_rules)]
macro_rules! loop_x ( macro_rules! loop_x (
($e: expr) => ( ($e: expr) => (

View file

@ -250,7 +250,7 @@ struct.
# Managed Pointers # Managed Pointers
> **Note**: the `@` form of managed pointers is deprecated and behind a > **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 > the crate root; remember the semicolon!). There are replacements, currently
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference > there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
> counting and garbage collection respectively. > counting and garbage collection respectively.

View file

@ -185,7 +185,7 @@ amount.
For example: For example:
~~~ ~~~
# #[allow(unused_imports)]; # #![allow(unused_imports)]
extern crate test; extern crate test;
use std::slice; use std::slice;
@ -247,7 +247,7 @@ recognize that some calculation has no external effects and remove
it entirely. it entirely.
~~~ ~~~
# #[allow(unused_imports)]; # #![allow(unused_imports)]
extern crate test; extern crate test;
use test::BenchHarness; use test::BenchHarness;

View file

@ -423,14 +423,14 @@ Current valid options are:
# Avoiding the standard library # Avoiding the standard library
By default, `std` is linked to every Rust crate. In some contexts, 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. attribute attached to the crate.
```ignore ```ignore
# // FIXME #12903: linking failures due to no_std # // FIXME #12903: linking failures due to no_std
// the minimal library // the minimal library
#[crate_type="lib"]; #![crate_type="lib"]
#[no_std]; #![no_std]
# // fn main() {} tricked you, rustdoc! # // fn main() {} tricked you, rustdoc!
``` ```
@ -445,7 +445,7 @@ in the same format as a C:
```ignore ```ignore
# // FIXME #12903: linking failures due to no_std # // FIXME #12903: linking failures due to no_std
#[no_std]; #![no_std]
extern "rust-intrinsic" { fn abort() -> !; } extern "rust-intrinsic" { fn abort() -> !; }
#[no_mangle] pub extern fn rust_stack_exhausted() { #[no_mangle] pub extern fn rust_stack_exhausted() {
@ -461,14 +461,14 @@ fn start(_argc: int, _argv: **u8) -> int {
``` ```
To override the compiler-inserted `main` shim, one has to disable it 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 correct ABI and the correct name, which requires overriding the
compiler's name mangling too: compiler's name mangling too:
```ignore ```ignore
# // FIXME #12903: linking failures due to no_std # // FIXME #12903: linking failures due to no_std
#[no_std]; #![no_std]
#[no_main]; #![no_main]
extern "rust-intrinsic" { fn abort() -> !; } extern "rust-intrinsic" { fn abort() -> !; }
#[no_mangle] pub extern fn rust_stack_exhausted() { #[no_mangle] pub extern fn rust_stack_exhausted() {
@ -542,7 +542,7 @@ sugar for dynamic allocations via `malloc` and `free`:
```ignore ```ignore
# // FIXME #12903: linking failures due to no_std # // FIXME #12903: linking failures due to no_std
#[no_std]; #![no_std]
#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms #[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
extern { extern {

View file

@ -252,7 +252,7 @@ msgstr "# モジュールとクレート"
#: src/doc/rust.md:627 #: src/doc/rust.md:627
#, fuzzy #, 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) ]; ~~~~" msgid "// Turn on a warning #![ warn(non_camel_case_types) ] ~~~~"
msgstr "" msgstr ""
"// 警告を有効にする\n" "// 警告を有効にする\n"
"#[warn(non_camel_case_types)]" "#[warn(non_camel_case_types)]"

View file

@ -4851,13 +4851,13 @@ msgstr ""
#. type: Plain text #. type: Plain text
#: src/doc/tutorial.md:3134 #: src/doc/tutorial.md:3134
#, fuzzy #, fuzzy
#| msgid "// Make a library (\"bin\" is the default) #[crate_type = \"lib\"];" #| msgid "// Make a library (\"bin\" is the default) #![crate_type = \"lib\"]"
msgid "" msgid ""
"// This crate is a library (\"bin\" is the default) #[crate_id = " "// This crate is a library (\"bin\" is the default) #[crate_id = "
"\"farm#2.5\"]; #[crate_type = \"lib\"];" "\"farm#2.5\"]; #![crate_type = \"lib\"]"
msgstr "" msgstr ""
"// ライブラリを作成する (\"bin\" がデフォルト値)\n" "// ライブラリを作成する (\"bin\" がデフォルト値)\n"
"#[crate_type = \"lib\"];" "#![crate_type = \"lib\"]"
#. type: Plain text #. type: Plain text
#: src/doc/tutorial.md:3139 #: src/doc/tutorial.md:3139
@ -4888,15 +4888,15 @@ msgstr ""
#: src/doc/tutorial.md:3153 #: src/doc/tutorial.md:3153
#, fuzzy #, fuzzy
#| msgid "" #| msgid ""
#| "~~~~ // world.rs #[link(name = \"world\", vers = \"1.0\")]; pub fn " #| "~~~~ // world.rs #![link(name = \"world\", vers = \"1.0\")] pub fn "
#| "explore() -> &str { \"world\" } ~~~~" #| "explore() -> &str { \"world\" } ~~~~"
msgid "" 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() {} ~~~~" "explore() -> &'static str { \"world\" } # fn main() {} ~~~~"
msgstr "" msgstr ""
"~~~~\n" "~~~~\n"
"// world.rs\n" "// world.rs\n"
"#[link(name = \"world\", vers = \"1.0\")];\n" "#![link(name = \"world\", vers = \"1.0\")]\n"
"pub fn explore() -> &str { \"world\" }\n" "pub fn explore() -> &str { \"world\" }\n"
"~~~~" "~~~~"

View file

@ -13,8 +13,8 @@ comments":
~~~ ~~~
// the "link" crate attribute is currently required for rustdoc, but normally // the "link" crate attribute is currently required for rustdoc, but normally
// isn't needed. // isn't needed.
#[crate_id = "universe"]; #![crate_id = "universe"]
#[crate_type="lib"]; #![crate_type="lib"]
//! Tools for dealing with universes (this is a doc comment, and is shown on //! 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, //! the crate index page. The ! makes it apply to the parent of the comment,

View file

@ -3094,8 +3094,8 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
~~~~ ~~~~
// `lib.rs` // `lib.rs`
# #[crate_type = "lib"]; # #![crate_type = "lib"]
#[crate_id = "farm#2.5"]; #![crate_id = "farm#2.5"]
// ... // ...
# fn farm() {} # fn farm() {}
@ -3119,8 +3119,8 @@ or setting the crate type (library or executable) explicitly:
// ... // ...
// This crate is a library ("bin" is the default) // This crate is a library ("bin" is the default)
#[crate_id = "farm#2.5"]; #![crate_id = "farm#2.5"]
#[crate_type = "lib"]; #![crate_type = "lib"]
// Turn on a warning // Turn on a warning
#[warn(non_camel_case_types)] #[warn(non_camel_case_types)]
@ -3135,7 +3135,7 @@ We define two crates, and use one of them as a library in the other.
~~~~ ~~~~
// `world.rs` // `world.rs`
#[crate_id = "world#0.42"]; #![crate_id = "world#0.42"]
# mod secret_module_to_make_this_test_run { # mod secret_module_to_make_this_test_run {
pub fn explore() -> &'static str { "world" } pub fn explore() -> &'static str { "world" }
@ -3209,12 +3209,12 @@ Both auto-insertions can be disabled with an attribute if necessary:
~~~ ~~~
// In the crate root: // In the crate root:
#[no_std]; #![no_std]
~~~ ~~~
~~~ ~~~
// In any module: // In any module:
#[no_implicit_prelude]; #![no_implicit_prelude]
~~~ ~~~
See the [API documentation][stddoc] for details. See the [API documentation][stddoc] for details.