Skip to content

Commit d0aed09

Browse files
committed
Update tutorials to use new attribute syntax (#13476)
1 parent b2b2bbb commit d0aed09

8 files changed

+28
-28
lines changed

src/doc/guide-macros.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ As an example, `loop` and `for-loop` labels (discussed in the lifetimes guide)
407407
will not clash. The following code will print "Hello!" only once:
408408

409409
~~~
410-
#[feature(macro_rules)];
410+
#![feature(macro_rules)]
411411
412412
macro_rules! loop_x (
413413
($e: expr) => (

src/doc/guide-pointers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ struct.
250250
# Managed Pointers
251251

252252
> **Note**: the `@` form of managed pointers is deprecated and behind a
253-
> feature gate (it requires a `#[feature(managed_pointers)];` attribute on
253+
> feature gate (it requires a `#![feature(managed_pointers)]` attribute on
254254
> the crate root; remember the semicolon!). There are replacements, currently
255255
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
256256
> counting and garbage collection respectively.

src/doc/guide-testing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ amount.
185185
For example:
186186

187187
~~~
188-
# #[allow(unused_imports)];
188+
# #![allow(unused_imports)]
189189
extern crate test;
190190
191191
use std::slice;
@@ -247,7 +247,7 @@ recognize that some calculation has no external effects and remove
247247
it entirely.
248248

249249
~~~
250-
# #[allow(unused_imports)];
250+
# #![allow(unused_imports)]
251251
extern crate test;
252252
use test::BenchHarness;
253253

src/doc/guide-unsafe.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,14 @@ Current valid options are:
423423
# Avoiding the standard library
424424

425425
By default, `std` is linked to every Rust crate. In some contexts,
426-
this is undesirable, and can be avoided with the `#[no_std];`
426+
this is undesirable, and can be avoided with the `#![no_std]`
427427
attribute attached to the crate.
428428

429429
```ignore
430430
# // FIXME #12903: linking failures due to no_std
431431
// the minimal library
432-
#[crate_type="lib"];
433-
#[no_std];
432+
#![crate_type="lib"]
433+
#![no_std]
434434
435435
# // fn main() {} tricked you, rustdoc!
436436
```
@@ -445,7 +445,7 @@ in the same format as a C:
445445

446446
```ignore
447447
# // FIXME #12903: linking failures due to no_std
448-
#[no_std];
448+
#![no_std]
449449
450450
extern "rust-intrinsic" { fn abort() -> !; }
451451
#[no_mangle] pub extern fn rust_stack_exhausted() {
@@ -461,14 +461,14 @@ fn start(_argc: int, _argv: **u8) -> int {
461461
```
462462

463463
To override the compiler-inserted `main` shim, one has to disable it
464-
with `#[no_main];` and then create the appropriate symbol with the
464+
with `#![no_main]` and then create the appropriate symbol with the
465465
correct ABI and the correct name, which requires overriding the
466466
compiler's name mangling too:
467467

468468
```ignore
469469
# // FIXME #12903: linking failures due to no_std
470-
#[no_std];
471-
#[no_main];
470+
#![no_std]
471+
#![no_main]
472472
473473
extern "rust-intrinsic" { fn abort() -> !; }
474474
#[no_mangle] pub extern fn rust_stack_exhausted() {
@@ -542,7 +542,7 @@ sugar for dynamic allocations via `malloc` and `free`:
542542

543543
```ignore
544544
# // FIXME #12903: linking failures due to no_std
545-
#[no_std];
545+
#![no_std]
546546
547547
#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
548548
extern {

src/doc/po/ja/rust.md.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ msgstr "# モジュールとクレート"
252252
#: src/doc/rust.md:627
253253
#, fuzzy
254254
#| msgid "// Turn on a warning #[warn(non_camel_case_types)]"
255-
msgid "// Turn on a warning #[ warn(non_camel_case_types) ]; ~~~~"
255+
msgid "// Turn on a warning #![ warn(non_camel_case_types) ] ~~~~"
256256
msgstr ""
257257
"// 警告を有効にする\n"
258258
"#[warn(non_camel_case_types)]"

src/doc/po/ja/tutorial.md.po

+6-6
Original file line numberDiff line numberDiff line change
@@ -4851,13 +4851,13 @@ msgstr ""
48514851
#. type: Plain text
48524852
#: src/doc/tutorial.md:3134
48534853
#, fuzzy
4854-
#| msgid "// Make a library (\"bin\" is the default) #[crate_type = \"lib\"];"
4854+
#| msgid "// Make a library (\"bin\" is the default) #![crate_type = \"lib\"]"
48554855
msgid ""
48564856
"// This crate is a library (\"bin\" is the default) #[crate_id = "
4857-
"\"farm#2.5\"]; #[crate_type = \"lib\"];"
4857+
"\"farm#2.5\"]; #![crate_type = \"lib\"]"
48584858
msgstr ""
48594859
"// ライブラリを作成する (\"bin\" がデフォルト値)\n"
4860-
"#[crate_type = \"lib\"];"
4860+
"#![crate_type = \"lib\"]"
48614861

48624862
#. type: Plain text
48634863
#: src/doc/tutorial.md:3139
@@ -4888,15 +4888,15 @@ msgstr ""
48884888
#: src/doc/tutorial.md:3153
48894889
#, fuzzy
48904890
#| msgid ""
4891-
#| "~~~~ // world.rs #[link(name = \"world\", vers = \"1.0\")]; pub fn "
4891+
#| "~~~~ // world.rs #![link(name = \"world\", vers = \"1.0\")] pub fn "
48924892
#| "explore() -> &str { \"world\" } ~~~~"
48934893
msgid ""
4894-
"~~~~ // `world.rs` #[crate_id = \"world#0.42\"]; # extern crate extra; pub fn "
4894+
"~~~~ // `world.rs` #![crate_id = \"world#0.42\"] # extern crate extra; pub fn "
48954895
"explore() -> &'static str { \"world\" } # fn main() {} ~~~~"
48964896
msgstr ""
48974897
"~~~~\n"
48984898
"// world.rs\n"
4899-
"#[link(name = \"world\", vers = \"1.0\")];\n"
4899+
"#![link(name = \"world\", vers = \"1.0\")]\n"
49004900
"pub fn explore() -> &str { \"world\" }\n"
49014901
"~~~~"
49024902

src/doc/rustdoc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ comments":
1313
~~~
1414
// the "link" crate attribute is currently required for rustdoc, but normally
1515
// isn't needed.
16-
#[crate_id = "universe"];
17-
#[crate_type="lib"];
16+
#![crate_id = "universe"]
17+
#![crate_type="lib"]
1818
1919
//! Tools for dealing with universes (this is a doc comment, and is shown on
2020
//! the crate index page. The ! makes it apply to the parent of the comment,

src/doc/tutorial.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -3094,8 +3094,8 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
30943094
~~~~
30953095
// `lib.rs`
30963096
3097-
# #[crate_type = "lib"];
3098-
#[crate_id = "farm#2.5"];
3097+
# #![crate_type = "lib"]
3098+
#![crate_id = "farm#2.5"]
30993099
31003100
// ...
31013101
# fn farm() {}
@@ -3119,8 +3119,8 @@ or setting the crate type (library or executable) explicitly:
31193119
// ...
31203120
31213121
// This crate is a library ("bin" is the default)
3122-
#[crate_id = "farm#2.5"];
3123-
#[crate_type = "lib"];
3122+
#![crate_id = "farm#2.5"]
3123+
#![crate_type = "lib"]
31243124
31253125
// Turn on a warning
31263126
#[warn(non_camel_case_types)]
@@ -3135,7 +3135,7 @@ We define two crates, and use one of them as a library in the other.
31353135

31363136
~~~~
31373137
// `world.rs`
3138-
#[crate_id = "world#0.42"];
3138+
#![crate_id = "world#0.42"]
31393139
31403140
# mod secret_module_to_make_this_test_run {
31413141
pub fn explore() -> &'static str { "world" }
@@ -3209,12 +3209,12 @@ Both auto-insertions can be disabled with an attribute if necessary:
32093209

32103210
~~~
32113211
// In the crate root:
3212-
#[no_std];
3212+
#![no_std]
32133213
~~~
32143214

32153215
~~~
32163216
// In any module:
3217-
#[no_implicit_prelude];
3217+
#![no_implicit_prelude]
32183218
~~~
32193219

32203220
See the [API documentation][stddoc] for details.

0 commit comments

Comments
 (0)