Skip to content

Commit b1eba27

Browse files
committed
---
yaml --- r: 208331 b: refs/heads/snap-stage3 c: 425455b h: refs/heads/master i: 208329: bba9632 208327: fdcfa0f v: v3
1 parent 4f95757 commit b1eba27

File tree

10 files changed

+203
-47
lines changed

10 files changed

+203
-47
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e66653bee52b87ada8d591b13b915e5ed2c86d5a
4+
refs/heads/snap-stage3: 425455b18e2278ff62841dabc305cf6a013af09d
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/doc/reference.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,27 @@ You may also be interested in the [grammar].
3131

3232
## Unicode productions
3333

34-
A few productions in Rust's grammar permit Unicode code points outside the ASCII
35-
range. We define these productions in terms of character properties specified
36-
in the Unicode standard, rather than in terms of ASCII-range code points. The
37-
section [Special Unicode Productions](#special-unicode-productions) lists these
38-
productions.
34+
A few productions in Rust's grammar permit Unicode code points outside the
35+
ASCII range. We define these productions in terms of character properties
36+
specified in the Unicode standard, rather than in terms of ASCII-range code
37+
points. The grammar has a [Special Unicode Productions][unicodeproductions]
38+
section that lists these productions.
39+
40+
[unicodeproductions]: grammar.html#special-unicode-productions
3941

4042
## String table productions
4143

4244
Some rules in the grammar — notably [unary
4345
operators](#unary-operator-expressions), [binary
44-
operators](#binary-operator-expressions), and [keywords](#keywords) — are
46+
operators](#binary-operator-expressions), and [keywords][keywords] — are
4547
given in a simplified form: as a listing of a table of unquoted, printable
4648
whitespace-separated strings. These cases form a subset of the rules regarding
4749
the [token](#tokens) rule, and are assumed to be the result of a
4850
lexical-analysis phase feeding the parser, driven by a DFA, operating over the
4951
disjunction of all such string table entries.
5052

53+
[keywords]: grammar.html#keywords
54+
5155
When such a string enclosed in double-quotes (`"`) occurs inside the grammar,
5256
it is an implicit reference to a single member of such a string table
5357
production. See [tokens](#tokens) for more information.
@@ -75,7 +79,7 @@ An identifier is any nonempty Unicode[^non_ascii_idents] string of the following
7579
- The first character has property `XID_start`
7680
- The remaining characters have property `XID_continue`
7781

78-
that does _not_ occur in the set of [keywords](#keywords).
82+
that does _not_ occur in the set of [keywords][keywords].
7983

8084
> **Note**: `XID_start` and `XID_continue` as character properties cover the
8185
> character ranges used to form the more familiar C and Java language-family
@@ -401,7 +405,7 @@ Symbols are a general class of printable [token](#tokens) that play structural
401405
roles in a variety of grammar productions. They are catalogued here for
402406
completeness as the set of remaining miscellaneous printable tokens that do not
403407
otherwise appear as [unary operators](#unary-operator-expressions), [binary
404-
operators](#binary-operator-expressions), or [keywords](#keywords).
408+
operators](#binary-operator-expressions), or [keywords][keywords].
405409

406410

407411
## Paths
@@ -547,7 +551,7 @@ _name_ s that occur in its body. At the "current layer", they all must repeat
547551
the same number of times, so ` ( $( $i:ident ),* ; $( $j:ident ),* ) => ( $(
548552
($i,$j) ),* )` is valid if given the argument `(a,b,c ; d,e,f)`, but not
549553
`(a,b,c ; d,e)`. The repetition walks through the choices at that layer in
550-
lockstep, so the former input transcribes to `( (a,d), (b,e), (c,f) )`.
554+
lockstep, so the former input transcribes to `(a,d), (b,e), (c,f)`.
551555

552556
Nested repetitions are allowed.
553557

@@ -611,7 +615,7 @@ module needs its own source file: [module definitions](#modules) can be nested
611615
within one file.
612616

613617
Each source file contains a sequence of zero or more `item` definitions, and
614-
may optionally begin with any number of [attributes](#Items and attributes)
618+
may optionally begin with any number of [attributes](#items-and-attributes)
615619
that apply to the containing module, most of which influence the behavior of
616620
the compiler. The anonymous crate module can have additional attributes that
617621
apply to the crate as a whole.
@@ -653,7 +657,7 @@ There are several kinds of item:
653657
* [`use` declarations](#use-declarations)
654658
* [modules](#modules)
655659
* [functions](#functions)
656-
* [type aliases](#type-aliases)
660+
* [type definitions](grammar.html#type-definitions)
657661
* [structures](#structures)
658662
* [enumerations](#enumerations)
659663
* [constant items](#constant-items)
@@ -773,7 +777,7 @@ extern crate std as ruststd; // linking to 'std' under another name
773777
A _use declaration_ creates one or more local name bindings synonymous with
774778
some other [path](#paths). Usually a `use` declaration is used to shorten the
775779
path required to refer to a module item. These declarations may appear at the
776-
top of [modules](#modules) and [blocks](#blocks).
780+
top of [modules](#modules) and [blocks](grammar.html#block-expressions).
777781

778782
> **Note**: Unlike in many languages,
779783
> `use` declarations in Rust do *not* declare linkage dependency with external crates.
@@ -1144,9 +1148,7 @@ let px: i32 = match p { Point(x, _) => x };
11441148
```
11451149

11461150
A _unit-like struct_ is a structure without any fields, defined by leaving off
1147-
the list of fields entirely. Such types will have a single value, just like
1148-
the [unit value `()`](#unit-and-boolean-literals) of the unit type. For
1149-
example:
1151+
the list of fields entirely. Such types will have a single value. For example:
11501152

11511153
```
11521154
struct Cookie;
@@ -2436,11 +2438,6 @@ comma:
24362438
(0); // zero in parentheses
24372439
```
24382440

2439-
### Unit expressions
2440-
2441-
The expression `()` denotes the _unit value_, the only value of the type with
2442-
the same name.
2443-
24442441
### Structure expressions
24452442

24462443
There are several forms of structure expressions. A _structure expression_
@@ -3281,7 +3278,7 @@ constructor or `struct` field may refer, directly or indirectly, to the
32813278
enclosing `enum` or `struct` type itself. Such recursion has restrictions:
32823279

32833280
* Recursive types must include a nominal type in the recursion
3284-
(not mere [type definitions](#type-definitions),
3281+
(not mere [type definitions](grammar.html#type-definitions),
32853282
or other structural types such as [arrays](#array,-and-slice-types) or [tuples](#tuple-types)).
32863283
* A recursive `enum` item must have at least one non-recursive constructor
32873284
(in order to give the recursion a basis case).

branches/snap-stage3/src/liballoc/heap.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::{isize, usize};
12+
13+
#[inline(always)]
14+
fn check_size_and_alignment(size: usize, align: usize) {
15+
debug_assert!(size != 0);
16+
debug_assert!(size <= isize::MAX as usize, "Tried to allocate too much: {} bytes", size);
17+
debug_assert!(usize::is_power_of_two(align), "Invalid alignment of allocation: {}", align);
18+
}
19+
1120
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
1221

1322
/// Return a pointer to `size` bytes of memory aligned to `align`.
@@ -19,6 +28,7 @@
1928
/// size on the platform.
2029
#[inline]
2130
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
31+
check_size_and_alignment(size, align);
2232
imp::allocate(size, align)
2333
}
2434

@@ -38,6 +48,7 @@ pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
3848
/// any value in range_inclusive(requested_size, usable_size).
3949
#[inline]
4050
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
51+
check_size_and_alignment(size, align);
4152
imp::reallocate(ptr, old_size, size, align)
4253
}
4354

@@ -56,6 +67,7 @@ pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usiz
5667
#[inline]
5768
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
5869
align: usize) -> usize {
70+
check_size_and_alignment(size, align);
5971
imp::reallocate_inplace(ptr, old_size, size, align)
6072
}
6173

branches/snap-stage3/src/libcollections/bit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ impl BitSet {
15371537
bit_vec.nbits = trunc_len * u32::BITS;
15381538
}
15391539

1540-
/// Iterator over each u32 stored in the `BitSet`.
1540+
/// Iterator over each usize stored in the `BitSet`.
15411541
///
15421542
/// # Examples
15431543
///
@@ -1558,7 +1558,7 @@ impl BitSet {
15581558
SetIter {set: self, next_idx: 0}
15591559
}
15601560

1561-
/// Iterator over each u32 stored in `self` union `other`.
1561+
/// Iterator over each usize stored in `self` union `other`.
15621562
/// See [union_with](#method.union_with) for an efficient in-place version.
15631563
///
15641564
/// # Examples
@@ -1658,7 +1658,7 @@ impl BitSet {
16581658
})
16591659
}
16601660

1661-
/// Iterator over each u32 stored in the symmetric difference of `self` and `other`.
1661+
/// Iterator over each usize stored in the symmetric difference of `self` and `other`.
16621662
/// See [symmetric_difference_with](#method.symmetric_difference_with) for
16631663
/// an efficient in-place version.
16641664
///

branches/snap-stage3/src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,8 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
16031603
Some(i as usize)),
16041604
_ => {
16051605
span_err!(tcx.sess, ast_ty.span, E0249,
1606-
"expected constant expr for array length");
1606+
"expected constant integer expression \
1607+
for array length");
16071608
this.tcx().types.err
16081609
}
16091610
}

0 commit comments

Comments
 (0)