Skip to content

Commit 317b487

Browse files
committed
---
yaml --- r: 195051 b: refs/heads/beta c: dc6bb5e h: refs/heads/master i: 195049: ba026d7 195047: ab9109b v: v3
1 parent 11b9655 commit 317b487

File tree

127 files changed

+2232
-1276
lines changed

Some content is hidden

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

127 files changed

+2232
-1276
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: a67faf1b25f40c3a4ad8545192136ceea8c4e63f
34+
refs/heads/beta: dc6bb5e8ef68720650ae37354684a6dee61117bb
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: be7f6ac7008f8ddf980ac07026b05bdd865f29cc

branches/beta/src/compiletest/util.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,34 @@ use common::Config;
1313

1414
/// Conversion table from triple OS name to Rust SYSNAME
1515
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
16-
("mingw32", "windows"),
17-
("win32", "windows"),
18-
("windows", "windows"),
19-
("darwin", "macos"),
2016
("android", "android"),
21-
("linux", "linux"),
22-
("freebsd", "freebsd"),
23-
("dragonfly", "dragonfly"),
2417
("bitrig", "bitrig"),
18+
("darwin", "macos"),
19+
("dragonfly", "dragonfly"),
20+
("freebsd", "freebsd"),
21+
("ios", "ios"),
22+
("linux", "linux"),
23+
("mingw32", "windows"),
2524
("openbsd", "openbsd"),
25+
("win32", "windows"),
26+
("windows", "windows"),
2627
];
2728

2829
const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
29-
("i386", "x86"),
30-
("i686", "x86"),
30+
("aarch64", "aarch64"),
3131
("amd64", "x86_64"),
32-
("x86_64", "x86_64"),
33-
("sparc", "sparc"),
34-
("powerpc", "powerpc"),
35-
("arm64", "aarch64"),
3632
("arm", "arm"),
37-
("aarch64", "aarch64"),
33+
("arm64", "aarch64"),
34+
("hexagon", "hexagon"),
35+
("i386", "x86"),
36+
("i686", "x86"),
3837
("mips", "mips"),
39-
("xcore", "xcore"),
4038
("msp430", "msp430"),
41-
("hexagon", "hexagon"),
39+
("powerpc", "powerpc"),
4240
("s390x", "systemz"),
41+
("sparc", "sparc"),
42+
("x86_64", "x86_64"),
43+
("xcore", "xcore"),
4344
];
4445

4546
pub fn get_os(triple: &str) -> &'static str {

branches/beta/src/doc/trpl/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ navigate through the menu on the left.
1111
<h2 class="section-header"><a href="basic.html">Basics</a></h2>
1212

1313
This section is a linear introduction to the basic syntax and semantics of
14-
Rust. It has individual sections on each part of Rust's syntax, and culminates
15-
in a small project: a guessing game.
14+
Rust. It has individual sections on each part of Rust's syntax.
1615

1716
After reading "Basics," you will have a good foundation to learn more about
1817
Rust, and can write very simple programs.
@@ -29,7 +28,12 @@ and will be able to understand most Rust code and write more complex programs.
2928

3029
In a similar fashion to "Intermediate," this section is full of individual,
3130
deep-dive chapters, which stand alone and can be read in any order. These
32-
chapters focus on the most complex features, as well as some things that
33-
are only available in upcoming versions of Rust.
31+
chapters focus on the most complex features,
3432

35-
After reading "Advanced," you'll be a Rust expert!
33+
<h2 class="section-header"><a href="unstable.html">Unstable</a></h2>
34+
35+
In a similar fashion to "Intermediate," this section is full of individual,
36+
deep-dive chapters, which stand alone and can be read in any order.
37+
38+
This chapter contains things that are only available on the nightly channel of
39+
Rust.

branches/beta/src/doc/trpl/SUMMARY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
* [FFI](ffi.md)
3737
* [Unsafe Code](unsafe.md)
3838
* [Advanced Macros](advanced-macros.md)
39+
* [Unstable Rust](unstable.md)
3940
* [Compiler Plugins](plugins.md)
41+
* [Inline Assembly](inline-assembly.md)
42+
* [No stdlib](no-stdlib.md)
43+
* [Intrinsics](intrinsics.md)
44+
* [Lang items](lang-items.md)
45+
* [Link args](link-args.md)
4046
* [Conclusion](conclusion.md)
4147
* [Glossary](glossary.md)

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ the [Bitwise Cyclic Tag](http://esolangs.org/wiki/Bitwise_Cyclic_Tag) automaton
206206
within Rust's macro system.
207207

208208
```rust
209-
#![feature(trace_macros)]
210-
211209
macro_rules! bct {
212210
// cmd 0: d ... => ...
213211
(0, $($ps:tt),* ; $_d:tt)
@@ -229,13 +227,6 @@ macro_rules! bct {
229227
( $($ps:tt),* ; )
230228
=> (());
231229
}
232-
233-
fn main() {
234-
trace_macros!(true);
235-
# /* just check the definition
236-
bct!(0, 0, 1, 1, 1 ; 1, 0, 1);
237-
# */
238-
}
239230
```
240231

241232
Exercise: use macros to reduce duplication in the above definition of the

branches/beta/src/doc/trpl/arrays-vectors-and-slices.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,5 @@ You can also take a slice of a vector, `String`, or `&str`, because they are
9999
backed by arrays. Slices have type `&[T]`, which we'll talk about when we cover
100100
generics.
101101

102-
We have now learned all of the most basic Rust concepts. We're ready to start
103-
building ourselves a guessing game, we just need to know one last thing: how to
104-
get input from the keyboard. You can't have a guessing game without the ability
105-
to guess!
102+
We have now learned all of the most basic Rust concepts. Next, we learn how to
103+
get input from the keyboard.

branches/beta/src/doc/trpl/basic.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
% Basics
22

33
This section is a linear introduction to the basic syntax and semantics of
4-
Rust. It has individual sections on each part of Rust's syntax, and cumulates
5-
in a small project: a guessing game.
4+
Rust. It has individual sections on each part of Rust's syntax.
65

76
After reading "Basics," you will have a good foundation to learn more about
87
Rust, and can write very simple programs.

branches/beta/src/doc/trpl/compound-data-types.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,5 +361,4 @@ and brittle `if`/`else`s.
361361

362362
[arity]: ./glossary.html#arity
363363
[match]: ./match.html
364-
[game]: ./guessing-game.html#comparing-guesses
365364
[generics]: ./generics.html

branches/beta/src/doc/trpl/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Here’s an example of documenting a macro:
352352
/// # }
353353
/// ```
354354
///
355-
/// ```should_fail
355+
/// ```should_panic
356356
/// # #[macro_use] extern crate foo;
357357
/// # fn main() {
358358
/// panic_unless!(true == false, “I’m broken.”);

branches/beta/src/doc/trpl/ffi.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -366,31 +366,6 @@ A few examples of how this model can be used are:
366366
367367
On OSX, frameworks behave with the same semantics as a dynamic library.
368368
369-
## The `link_args` attribute
370-
371-
There is one other way to tell rustc how to customize linking, and that is via
372-
the `link_args` attribute. This attribute is applied to `extern` blocks and
373-
specifies raw flags which need to get passed to the linker when producing an
374-
artifact. An example usage would be:
375-
376-
``` no_run
377-
#![feature(link_args)]
378-
379-
#[link_args = "-foo -bar -baz"]
380-
extern {}
381-
# fn main() {}
382-
```
383-
384-
Note that this feature is currently hidden behind the `feature(link_args)` gate
385-
because this is not a sanctioned way of performing linking. Right now rustc
386-
shells out to the system linker, so it makes sense to provide extra command line
387-
arguments, but this will not always be the case. In the future rustc may use
388-
LLVM directly to link native libraries in which case `link_args` will have no
389-
meaning.
390-
391-
It is highly recommended to *not* use this attribute, and rather use the more
392-
formal `#[link(...)]` attribute on `extern` blocks instead.
393-
394369
# Unsafe blocks
395370
396371
Some operations, like dereferencing unsafe pointers or calling functions that have been marked
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
% Inline Assembly
2+
3+
For extremely low-level manipulations and performance reasons, one
4+
might wish to control the CPU directly. Rust supports using inline
5+
assembly to do this via the `asm!` macro. The syntax roughly matches
6+
that of GCC & Clang:
7+
8+
```ignore
9+
asm!(assembly template
10+
: output operands
11+
: input operands
12+
: clobbers
13+
: options
14+
);
15+
```
16+
17+
Any use of `asm` is feature gated (requires `#![feature(asm)]` on the
18+
crate to allow) and of course requires an `unsafe` block.
19+
20+
> **Note**: the examples here are given in x86/x86-64 assembly, but
21+
> all platforms are supported.
22+
23+
## Assembly template
24+
25+
The `assembly template` is the only required parameter and must be a
26+
literal string (i.e. `""`)
27+
28+
```
29+
#![feature(asm)]
30+
31+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
32+
fn foo() {
33+
unsafe {
34+
asm!("NOP");
35+
}
36+
}
37+
38+
// other platforms
39+
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
40+
fn foo() { /* ... */ }
41+
42+
fn main() {
43+
// ...
44+
foo();
45+
// ...
46+
}
47+
```
48+
49+
(The `feature(asm)` and `#[cfg]`s are omitted from now on.)
50+
51+
Output operands, input operands, clobbers and options are all optional
52+
but you must add the right number of `:` if you skip them:
53+
54+
```
55+
# #![feature(asm)]
56+
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
57+
# fn main() { unsafe {
58+
asm!("xor %eax, %eax"
59+
:
60+
:
61+
: "eax"
62+
);
63+
# } }
64+
```
65+
66+
Whitespace also doesn't matter:
67+
68+
```
69+
# #![feature(asm)]
70+
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
71+
# fn main() { unsafe {
72+
asm!("xor %eax, %eax" ::: "eax");
73+
# } }
74+
```
75+
76+
## Operands
77+
78+
Input and output operands follow the same format: `:
79+
"constraints1"(expr1), "constraints2"(expr2), ..."`. Output operand
80+
expressions must be mutable lvalues:
81+
82+
```
83+
# #![feature(asm)]
84+
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
85+
fn add(a: i32, b: i32) -> i32 {
86+
let mut c = 0;
87+
unsafe {
88+
asm!("add $2, $0"
89+
: "=r"(c)
90+
: "0"(a), "r"(b)
91+
);
92+
}
93+
c
94+
}
95+
# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
96+
# fn add(a: i32, b: i32) -> i32 { a + b }
97+
98+
fn main() {
99+
assert_eq!(add(3, 14159), 14162)
100+
}
101+
```
102+
103+
## Clobbers
104+
105+
Some instructions modify registers which might otherwise have held
106+
different values so we use the clobbers list to indicate to the
107+
compiler not to assume any values loaded into those registers will
108+
stay valid.
109+
110+
```
111+
# #![feature(asm)]
112+
# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
113+
# fn main() { unsafe {
114+
// Put the value 0x200 in eax
115+
asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax");
116+
# } }
117+
```
118+
119+
Input and output registers need not be listed since that information
120+
is already communicated by the given constraints. Otherwise, any other
121+
registers used either implicitly or explicitly should be listed.
122+
123+
If the assembly changes the condition code register `cc` should be
124+
specified as one of the clobbers. Similarly, if the assembly modifies
125+
memory, `memory` should also be specified.
126+
127+
## Options
128+
129+
The last section, `options` is specific to Rust. The format is comma
130+
separated literal strings (i.e. `:"foo", "bar", "baz"`). It's used to
131+
specify some extra info about the inline assembly:
132+
133+
Current valid options are:
134+
135+
1. *volatile* - specifying this is analogous to
136+
`__asm__ __volatile__ (...)` in gcc/clang.
137+
2. *alignstack* - certain instructions expect the stack to be
138+
aligned a certain way (i.e. SSE) and specifying this indicates to
139+
the compiler to insert its usual stack alignment code
140+
3. *intel* - use intel syntax instead of the default AT&T.
141+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
% Intrinsics
2+
3+
> **Note**: intrinsics will forever have an unstable interface, it is
4+
> recommended to use the stable interfaces of libcore rather than intrinsics
5+
> directly.
6+
7+
These are imported as if they were FFI functions, with the special
8+
`rust-intrinsic` ABI. For example, if one was in a freestanding
9+
context, but wished to be able to `transmute` between types, and
10+
perform efficient pointer arithmetic, one would import those functions
11+
via a declaration like
12+
13+
```
14+
# #![feature(intrinsics)]
15+
# fn main() {}
16+
17+
extern "rust-intrinsic" {
18+
fn transmute<T, U>(x: T) -> U;
19+
20+
fn offset<T>(dst: *const T, offset: isize) -> *const T;
21+
}
22+
```
23+
24+
As with any other FFI functions, these are always `unsafe` to call.
25+

0 commit comments

Comments
 (0)