Skip to content

Commit 8358ee3

Browse files
committed
---
yaml --- r: 187866 b: refs/heads/tmp c: 7074346 h: refs/heads/master v: v3
1 parent d82e621 commit 8358ee3

File tree

185 files changed

+1274
-2800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+1274
-2800
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 91569a95f16580f05f9dcb4b6d6eff50203cdde8
37+
refs/heads/tmp: 7074346e4f092064c5a5fa276be81d08951f56c9
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/src/doc/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ There are questions that are asked quite often, and so we've made FAQs for them:
6868
* [Language Design FAQ](complement-design-faq.html)
6969
* [Language FAQ](complement-lang-faq.html)
7070
* [Project FAQ](complement-project-faq.html)
71-
* [How to submit a bug report](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports)
71+
* [How to submit a bug report](complement-bugreport.html)
7272

7373
# The standard library
7474

branches/tmp/src/doc/reference.md

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ nonzero_dec: '1' | '2' | '3' | '4'
302302

303303
A _character literal_ is a single Unicode character enclosed within two
304304
`U+0027` (single-quote) characters, with the exception of `U+0027` itself,
305-
which must be _escaped_ by a preceding `U+005C` character (`\`).
305+
which must be _escaped_ by a preceding U+005C character (`\`).
306306

307307
##### String literals
308308

@@ -311,19 +311,6 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
311311
which must be _escaped_ by a preceding `U+005C` character (`\`), or a _raw
312312
string literal_.
313313

314-
A multi-line string literal may be defined by terminating each line with a
315-
`U+005C` character (`\`) immediately before the newline. This causes the
316-
`U+005C` character, the newline, and all whitespace at the beginning of the
317-
next line to be ignored.
318-
319-
```rust
320-
let a = "foobar";
321-
let b = "foo\
322-
bar";
323-
324-
assert_eq!(a,b);
325-
```
326-
327314
##### Character escapes
328315

329316
Some additional _escapes_ are available in either character or non-raw string
@@ -744,20 +731,15 @@ Rust syntax is restricted in two ways:
744731
pairs when they occur at the beginning of, or immediately after, a `$(...)*`;
745732
requiring a distinctive token in front can solve the problem.
746733

747-
## Syntax extensions useful in macros
748-
749-
* `stringify!` : turn the identifier argument into a string literal
750-
* `concat!` : concatenates a comma-separated list of literals
751-
752-
## Syntax extensions for macro debugging
734+
## Syntax extensions useful for the macro author
753735

754736
* `log_syntax!` : print out the arguments at compile time
755737
* `trace_macros!` : supply `true` or `false` to enable or disable macro expansion logging
738+
* `stringify!` : turn the identifier argument into a string literal
739+
* `concat!` : concatenates a comma-separated list of literals
740+
* `concat_idents!` : create a new identifier by concatenating the arguments
756741

757-
## Quasiquoting
758-
759-
The following syntax extensions are used for quasiquoting Rust syntax trees,
760-
usually in [procedural macros](book/plugins.html#syntax-extensions):
742+
The following attributes are used for quasiquoting in procedural macros:
761743

762744
* `quote_expr!`
763745
* `quote_item!`
@@ -766,8 +748,6 @@ usually in [procedural macros](book/plugins.html#syntax-extensions):
766748
* `quote_tokens!`
767749
* `quote_ty!`
768750

769-
Documentation is very limited at the moment.
770-
771751
# Crates and source files
772752

773753
Rust is a *compiled* language. Its semantics obey a *phase distinction*

branches/tmp/src/doc/trpl/advanced-macros.md

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -192,58 +192,19 @@ To keep this system simple and correct, `#[macro_use] extern crate ...` may
192192
only appear at the root of your crate, not inside `mod`. This ensures that
193193
`$crate` is a single identifier.
194194

195-
# The deep end
195+
# A final note
196196

197-
The introductory chapter mentioned recursive macros, but it did not give the
198-
full story. Recursive macros are useful for another reason: Each recursive
199-
invocation gives you another opportunity to pattern-match the macro's
200-
arguments.
201-
202-
As an extreme example, it is possible, though hardly advisable, to implement
203-
the [Bitwise Cyclic Tag](http://esolangs.org/wiki/Bitwise_Cyclic_Tag) automaton
204-
within Rust's macro system.
205-
206-
```rust
207-
#![feature(trace_macros)]
208-
209-
macro_rules! bct {
210-
// cmd 0: d ... => ...
211-
(0, $($ps:tt),* ; $_d:tt)
212-
=> (bct!($($ps),*, 0 ; ));
213-
(0, $($ps:tt),* ; $_d:tt, $($ds:tt),*)
214-
=> (bct!($($ps),*, 0 ; $($ds),*));
215-
216-
// cmd 1p: 1 ... => 1 ... p
217-
(1, $p:tt, $($ps:tt),* ; 1)
218-
=> (bct!($($ps),*, 1, $p ; 1, $p));
219-
(1, $p:tt, $($ps:tt),* ; 1, $($ds:tt),*)
220-
=> (bct!($($ps),*, 1, $p ; 1, $($ds),*, $p));
221-
222-
// cmd 1p: 0 ... => 0 ...
223-
(1, $p:tt, $($ps:tt),* ; $($ds:tt),*)
224-
=> (bct!($($ps),*, 1, $p ; $($ds),*));
225-
226-
// halt on empty data string
227-
( $($ps:tt),* ; )
228-
=> (());
229-
}
230-
231-
fn main() {
232-
trace_macros!(true);
233-
# /* just check the definition
234-
bct!(0, 0, 1, 1, 1 ; 1, 0, 1);
235-
# */
236-
}
237-
```
238-
239-
Exercise: use macros to reduce duplication in the above definition of the
240-
`bct!` macro.
241-
242-
# Procedural macros
197+
Macros, as currently implemented, are not for the faint of heart. Even
198+
ordinary syntax errors can be more difficult to debug when they occur inside a
199+
macro, and errors caused by parse problems in generated code can be very
200+
tricky. Invoking the `log_syntax!` macro can help elucidate intermediate
201+
states, invoking `trace_macros!(true)` will automatically print those
202+
intermediate states out, and passing the flag `--pretty expanded` as a
203+
command-line argument to the compiler will show the result of expansion.
243204

244205
If Rust's macro system can't do what you need, you may want to write a
245206
[compiler plugin](plugins.html) instead. Compared to `macro_rules!`
246207
macros, this is significantly more work, the interfaces are much less stable,
247-
and bugs can be much harder to track down. In exchange you get the
208+
and the warnings about debugging apply ten-fold. In exchange you get the
248209
flexibility of running arbitrary Rust code within the compiler. Syntax
249210
extension plugins are sometimes called *procedural macros* for this reason.

branches/tmp/src/doc/trpl/error-handling.md

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -223,78 +223,6 @@ let input = io::stdin().read_line()
223223
.ok()
224224
.expect("Failed to read line");
225225
```
226-
227226
`ok()` converts the `IoResult` into an `Option`, and `expect()` does the same
228227
thing as `unwrap()`, but takes a message. This message is passed along to the
229228
underlying `panic!`, providing a better error message if the code errors.
230-
231-
# Using `try!`
232-
233-
When writing code that calls many functions that return the `Result` type, the
234-
error handling can be tedious. The `try!` macro hides some of the boilerplate
235-
of propagating errors up the call stack.
236-
237-
It replaces this:
238-
239-
```rust
240-
use std::fs::File;
241-
use std::io;
242-
use std::io::prelude::*;
243-
244-
struct Info {
245-
name: String,
246-
age: i32,
247-
rating: i32,
248-
}
249-
250-
fn write_info(info: &Info) -> io::Result<()> {
251-
let mut file = File::open("my_best_friends.txt").unwrap();
252-
253-
if let Err(e) = writeln!(&mut file, "name: {}", info.name) {
254-
return Err(e)
255-
}
256-
if let Err(e) = writeln!(&mut file, "age: {}", info.age) {
257-
return Err(e)
258-
}
259-
if let Err(e) = writeln!(&mut file, "rating: {}", info.rating) {
260-
return Err(e)
261-
}
262-
263-
return Ok(());
264-
}
265-
```
266-
267-
With this:
268-
269-
```rust
270-
use std::fs::File;
271-
use std::io;
272-
use std::io::prelude::*;
273-
274-
struct Info {
275-
name: String,
276-
age: i32,
277-
rating: i32,
278-
}
279-
280-
fn write_info(info: &Info) -> io::Result<()> {
281-
let mut file = try!(File::open("my_best_friends.txt"));
282-
283-
try!(writeln!(&mut file, "name: {}", info.name));
284-
try!(writeln!(&mut file, "age: {}", info.age));
285-
try!(writeln!(&mut file, "rating: {}", info.rating));
286-
287-
return Ok(());
288-
}
289-
```
290-
291-
Wrapping an expression in `try!` will result in the unwrapped success (`Ok`)
292-
value, unless the result is `Err`, in which case `Err` is returned early from
293-
the enclosing function.
294-
295-
It's worth noting that you can only use `try!` from a function that returns a
296-
`Result`, which means that you cannot use `try!` inside of `main()`, because
297-
`main()` doesn't return anything.
298-
299-
`try!` makes use of [`FromError`](../std/error/#the-fromerror-trait) to determine
300-
what to return in the error case.

branches/tmp/src/doc/trpl/hello-cargo.md

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ the Cargo
1818
README](https://github.com/rust-lang/cargo#installing-cargo-from-nightlies)
1919
for specific instructions about installing it.
2020

21-
## Converting to Cargo
22-
2321
Let's convert Hello World to Cargo.
2422

2523
To Cargo-ify our project, we need to do two things: Make a `Cargo.toml`
2624
configuration file, and put our source file in the right place. Let's
2725
do that part first:
2826

29-
```bash
27+
```{bash}
3028
$ mkdir src
3129
$ mv main.rs src/main.rs
3230
```
@@ -38,7 +36,7 @@ place for everything, and everything in its place.
3836

3937
Next, our configuration file:
4038

41-
```bash
39+
```{bash}
4240
$ editor Cargo.toml
4341
```
4442

@@ -75,7 +73,7 @@ well as what it is named.
7573

7674
Once you have this file in place, we should be ready to build! Try this:
7775

78-
```bash
76+
```{bash}
7977
$ cargo build
8078
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
8179
$ ./target/hello_world
@@ -105,62 +103,6 @@ That's it! We've successfully built `hello_world` with Cargo. Even though our
105103
program is simple, it's using much of the real tooling that you'll use for the
106104
rest of your Rust career.
107105

108-
## A New Project
109-
110-
You don't have to go through this whole process every time you want to start a new
111-
project! Cargo has the ability to make a bare-bones project directory in which you
112-
can start developing right away.
113-
114-
To start a new project with Cargo, use `cargo new`:
115-
116-
```bash
117-
$ cargo new hello_world --bin
118-
```
119-
120-
We're passing `--bin` because we're making a binary program: if we
121-
were making a library, we'd leave it off.
122-
123-
Let's check out what Cargo has generated for us:
124-
125-
```bash
126-
$ cd hello_world
127-
$ tree .
128-
.
129-
├── Cargo.toml
130-
└── src
131-
└── main.rs
132-
133-
1 directory, 2 files
134-
```
135-
136-
If you don't have the `tree` command, you can probably get it from your distro's package
137-
manager. It's not necessary, but it's certainly useful.
138-
139-
This is all we need to get started. First, let's check out `Cargo.toml`:
140-
141-
```toml
142-
[package]
143-
144-
name = "hello_world"
145-
version = "0.0.1"
146-
authors = ["Your Name <[email protected]>"]
147-
```
148-
149-
Cargo has populated this file with reasonable defaults based off the arguments you gave
150-
it and your `git` global configuration. You may notice that Cargo has also initialized
151-
the `hello_world` directory as a `git` repository.
152-
153-
Here's what's in `src/main.rs`:
154-
155-
```rust
156-
fn main() {
157-
println!("Hello, world!");
158-
}
159-
```
160-
161-
Cargo has generated a "Hello World!" for us, and you're ready to start coding! A
162-
much more in-depth guide to Cargo can be found [here](http://doc.crates.io/guide.html).
163-
164106
Now that you've got the tools down, let's actually learn more about the Rust
165107
language itself. These are the basics that will serve you well through the rest
166-
of your time with Rust.
108+
of your time with Rust.

0 commit comments

Comments
 (0)