Skip to content

Commit bc17ad8

Browse files
authored
Merge branch 'rust-lang:master' into c-unwind-documentation
2 parents 6ee4999 + 3ae6268 commit bc17ad8

File tree

11 files changed

+139
-101
lines changed

11 files changed

+139
-101
lines changed

src/attributes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ The following is an index of all built-in attributes.
248248
- [`no_builtins`] — Disables use of certain built-in functions.
249249
- [`target_feature`] — Configure platform-specific code generation.
250250
- [`track_caller`] - Pass the parent call location to `std::panic::Location::caller()`.
251+
- [`instruction_set`] - Specify the instruction set used to generate a functions code
251252
- Documentation
252253
- `doc` — Specifies documentation. See [The Rustdoc Book] for more
253254
information. [Doc comments] are transformed into `doc` attributes.
@@ -298,6 +299,7 @@ The following is an index of all built-in attributes.
298299
[`global_allocator`]: runtime.md#the-global_allocator-attribute
299300
[`ignore`]: attributes/testing.md#the-ignore-attribute
300301
[`inline`]: attributes/codegen.md#the-inline-attribute
302+
[`instruction_set`]: attributes/codegen.md#the-instruction_set-attribute
301303
[`link_name`]: items/external-blocks.md#the-link_name-attribute
302304
[`link_ordinal`]: items/external-blocks.md#the-link_ordinal-attribute
303305
[`link_section`]: abi.md#the-link_section-attribute

src/attributes/codegen.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,26 @@ trait object whose methods are attributed.
352352
[`core::intrinsics::caller_location`]: ../../core/intrinsics/fn.caller_location.html
353353
[`core::panic::Location::caller`]: ../../core/panic/struct.Location.html#method.caller
354354
[`Location`]: ../../core/panic/struct.Location.html
355+
356+
## The `instruction_set` attribute
357+
358+
The *`instruction_set` attribute* may be applied to a function to enable code generation for a specific
359+
instruction set supported by the target architecture. It uses the [_MetaListPath_] syntax and a path
360+
comprised of the architecture and instruction set to specify how to generate the code for
361+
architectures where a single program may utilize multiple instruction sets.
362+
363+
The following values are available on targets for the `ARMv4` and `ARMv5te` architectures:
364+
365+
* `arm::a32` - Uses ARM code.
366+
* `arm::t32` - Uses Thumb code.
367+
368+
<!-- ignore: arm-only -->
369+
```rust,ignore
370+
#[instruction_set(arm::a32)]
371+
fn foo_arm_code() {}
372+
373+
#[instruction_set(arm::t32)]
374+
fn bar_thumb_code() {}
375+
```
376+
377+
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax

src/behavior-considered-undefined.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,22 @@ code.
2626
* Evaluating a [dereference expression] (`*expr`) on a raw pointer that is
2727
[dangling] or unaligned, even in [place expression context]
2828
(e.g. `addr_of!(&*expr)`).
29-
* Breaking the [pointer aliasing rules]. `&mut T` and `&T` follow LLVM’s scoped
30-
[noalias] model, except if the `&T` contains an [`UnsafeCell<U>`].
29+
* Breaking the [pointer aliasing rules]. `Box<T>`, `&mut T` and `&T` follow
30+
LLVM’s scoped [noalias] model, except if the `&T` contains an
31+
[`UnsafeCell<U>`]. References and boxes must not be [dangling] while they are
32+
live. The exact liveness duration is not specified, but some bounds exist:
33+
* For references, the liveness duration is upper-bounded by the syntactic
34+
lifetime assigned by the borrow checker; it cannot be live any *longer* than
35+
that lifetime.
36+
* Each time a reference or box is passed to or returned from a function, it is
37+
considered live.
38+
* When a reference (but not a `Box`!) is passed to a function, it is live at
39+
least as long as that function call, again except if the `&T` contains an
40+
[`UnsafeCell<U>`].
41+
42+
All this also applies when values of these
43+
types are passed in a (nested) field of a compound type, but not behind
44+
pointer indirections.
3145
* Mutating immutable data. All data inside a [`const`] item is immutable. Moreover, all
3246
data reached through a shared reference or data owned by an immutable binding
3347
is immutable, unless that data is contained within an [`UnsafeCell<U>`].

src/comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **<sup>Lexer</sup>**\
44
> LINE_COMMENT :\
5-
> &nbsp;&nbsp; &nbsp;&nbsp; `//` (~\[`/` `!`] | `//`) ~`\n`<sup>\*</sup>\
5+
> &nbsp;&nbsp; &nbsp;&nbsp; `//` (~\[`/` `!` `\n`] | `//`) ~`\n`<sup>\*</sup>\
66
> &nbsp;&nbsp; | `//`
77
>
88
> BLOCK_COMMENT :\

src/expressions/literal-expr.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
> &nbsp;&nbsp; | [BYTE_LITERAL]\
99
> &nbsp;&nbsp; | [BYTE_STRING_LITERAL]\
1010
> &nbsp;&nbsp; | [RAW_BYTE_STRING_LITERAL]\
11-
> &nbsp;&nbsp; | [INTEGER_LITERAL][^out-of-range]\
11+
> &nbsp;&nbsp; | [INTEGER_LITERAL]\
1212
> &nbsp;&nbsp; | [FLOAT_LITERAL]\
1313
> &nbsp;&nbsp; | `true` | `false`
14-
>
15-
> [^out-of-range]: A value ≥ 2<sup>128</sup> is not allowed.
1614
1715
A _literal expression_ is an expression consisting of a single token, rather than a sequence of tokens, that immediately and directly denotes the value it evaluates to, rather than referring to it by name or some other evaluation rule.
1816

@@ -54,7 +52,7 @@ A string literal expression consists of a single [BYTE_STRING_LITERAL] or [RAW_B
5452

5553
An integer literal expression consists of a single [INTEGER_LITERAL] token.
5654

57-
If the token has a [suffix], the suffix will be the name of one of the [primitive integer types][numeric types]: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `u128`, `i128`, `usize`, or `isize`, and the expression has that type.
55+
If the token has a [suffix], the suffix must be the name of one of the [primitive integer types][numeric types]: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `u128`, `i128`, `usize`, or `isize`, and the expression has that type.
5856

5957
If the token has no suffix, the expression's type is determined by type inference:
6058

@@ -96,10 +94,12 @@ The value of the expression is determined from the string representation of the
9694

9795
* If the radix is not 10, the first two characters are removed from the string.
9896

97+
* Any suffix is removed from the string.
98+
9999
* Any underscores are removed from the string.
100100

101101
* The string is converted to a `u128` value as if by [`u128::from_str_radix`] with the chosen radix.
102-
If the value does not fit in `u128`, the expression is rejected by the parser.
102+
If the value does not fit in `u128`, it is a compiler error.
103103

104104
* The `u128` value is converted to the expression's type via a [numeric cast].
105105

@@ -111,9 +111,11 @@ If the value does not fit in `u128`, the expression is rejected by the parser.
111111
112112
## Floating-point literal expressions
113113

114-
A floating-point literal expression consists of a single [FLOAT_LITERAL] token.
114+
A floating-point literal expression has one of two forms:
115+
* a single [FLOAT_LITERAL] token
116+
* a single [INTEGER_LITERAL] token which has a suffix and no radix indicator
115117

116-
If the token has a [suffix], the suffix will be the name of one of the [primitive floating-point types][floating-point types]: `f32` or `f64`, and the expression has that type.
118+
If the token has a [suffix], the suffix must be the name of one of the [primitive floating-point types][floating-point types]: `f32` or `f64`, and the expression has that type.
117119

118120
If the token has no suffix, the expression's type is determined by type inference:
119121

@@ -136,6 +138,8 @@ let x: f64 = 2.; // type f64
136138

137139
The value of the expression is determined from the string representation of the token as follows:
138140

141+
* Any suffix is removed from the string.
142+
139143
* Any underscores are removed from the string.
140144

141145
* The string is converted to the expression's type as if by [`f32::from_str`] or [`f64::from_str`].

src/items/extern-crates.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ clause can be used to bind the imported crate to a different name.
2020
The external crate is resolved to a specific `soname` at compile time, and a
2121
runtime linkage requirement to that `soname` is passed to the linker for
2222
loading at runtime. The `soname` is resolved at compile time by scanning the
23-
compiler's library path and matching the optional `crateid` provided against
24-
the `crateid` attributes that were declared on the external crate when it was
25-
compiled. If no `crateid` is provided, a default `name` attribute is assumed,
23+
compiler's library path and matching the optional `crate_name` provided against
24+
the [`crate_name` attributes] that were declared on the external crate when it was
25+
compiled. If no `crate_name` is provided, a default `name` attribute is assumed,
2626
equal to the [identifier] given in the `extern crate` declaration.
2727

2828
The `self` crate may be imported which creates a binding to the current crate.
@@ -78,6 +78,7 @@ crate to access only its macros.
7878
[`macro_use` attribute]: ../macros-by-example.md#the-macro_use-attribute
7979
[extern prelude]: ../names/preludes.md#extern-prelude
8080
[`macro_use` prelude]: ../names/preludes.md#macro_use-prelude
81+
[`crate_name` attributes]: ../crates-and-source-files.md#the-crate_name-attribute
8182

8283
<script>
8384
(function() {

src/items/external-blocks.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ The default for this modifier is `-whole-archive`.
201201
More implementation details about this modifier can be found in
202202
[`whole-archive` documentation for rustc].
203203

204+
### Linking modifiers: `verbatim`
205+
206+
This modifier is compatible with all linking kinds.
207+
208+
`+verbatim` means that rustc itself won't add any target-specified library prefixes or suffixes
209+
(like `lib` or `.a`) to the library name, and will try its best to ask for the same thing from the
210+
linker.
211+
212+
`-verbatim` means that rustc will either add a target-specific prefix and suffix to the library
213+
name before passing it to linker, or won't prevent linker from implicitly adding it.
214+
215+
The default for this modifier is `-verbatim`.
216+
217+
More implementation details about this modifier can be found in
218+
[`verbatim` documentation for rustc].
219+
204220
#### `dylib` versus `raw-dylib`
205221

206222
On Windows, linking against a dynamic library requires that an import library
@@ -288,4 +304,5 @@ restrictions as [regular function parameters].
288304
[regular function parameters]: functions.md#attributes-on-function-parameters
289305
[`bundle` documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-bundle
290306
[`whole-archive` documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-whole-archive
307+
[`verbatim` documentation for rustc]: ../../rustc/command-line-arguments.html#linking-modifiers-verbatim
291308
[`dylib` versus `raw-dylib`]: #dylib-versus-raw-dylib

src/macros-by-example.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ delimiters for the matcher will match any pair of delimiters. Thus, for
7676
instance, the matcher `(())` will match `{()}` but not `{{}}`. The character
7777
`$` cannot be matched or transcribed literally.
7878

79+
### Forwarding a matched fragment
80+
7981
When forwarding a matched fragment to another macro-by-example, matchers in
8082
the second macro will see an opaque AST of the fragment type. The second macro
8183
can't use literal tokens to match the fragments in the matcher, only a

src/special-types-and-traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ UnwindSafe>` is a valid type.
135135
## `Sized`
136136

137137
The [`Sized`] trait indicates that the size of this type is known at compile-time; that is, it's not a [dynamically sized type].
138-
[Type parameters] are `Sized` by default, as are [associated types].
138+
[Type parameters] (except `Self` in traits) are `Sized` by default, as are [associated types].
139139
`Sized` is always implemented automatically by the compiler, not by [implementation items].
140140
These implicit `Sized` bounds may be relaxed by using the special `?Sized` bound.
141141

0 commit comments

Comments
 (0)