Skip to content

Commit 355f3b7

Browse files
committed
---
yaml --- r: 236427 b: refs/heads/auto c: 8f51c8d h: refs/heads/master i: 236425: 33e10cd 236423: 7dabd74 v: v3
1 parent 29ff096 commit 355f3b7

Some content is hidden

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

68 files changed

+575
-317
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 6c2e3fbe909be15cbc3a0a981950acd99360bedb
11+
refs/heads/auto: 8f51c8d687cb6fd7e98f68b93f40445ecd4690fa
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/doc/grammar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ provides only one kind of material:
99

1010
This document does not serve as an introduction to the language. Background
1111
familiarity with the language is assumed. A separate [guide] is available to
12-
help acquire such background.
12+
help acquire such background familiarity.
1313

1414
This document also does not serve as a reference to the [standard] library
1515
included in the language distribution. Those libraries are documented

branches/auto/src/doc/reference.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ There are several kinds of item:
674674
* [modules](#modules)
675675
* [functions](#functions)
676676
* [type definitions](grammar.html#type-definitions)
677-
* [structs](#structs)
677+
* [structures](#structures)
678678
* [enumerations](#enumerations)
679679
* [constant items](#constant-items)
680680
* [static items](#static-items)
@@ -900,10 +900,9 @@ fn main() {}
900900

901901
### Functions
902902

903-
A _function item_ defines a sequence of [statements](#statements) and a
904-
final [expression](#expressions), along with a name and a set of
905-
parameters. Other than a name, all these are optional.
906-
Functions are declared with the keyword `fn`. Functions may declare a
903+
A _function item_ defines a sequence of [statements](#statements) and an
904+
optional final [expression](#expressions), along with a name and a set of
905+
parameters. Functions are declared with the keyword `fn`. Functions declare a
907906
set of *input* [*variables*](#variables) as parameters, through which the caller
908907
passes arguments into the function, and the *output* [*type*](#types)
909908
of the value the function will return to its caller on completion.
@@ -922,7 +921,7 @@ An example of a function:
922921

923922
```
924923
fn add(x: i32, y: i32) -> i32 {
925-
x + y
924+
return x + y;
926925
}
927926
```
928927

@@ -1156,7 +1155,7 @@ type Point = (u8, u8);
11561155
let p: Point = (41, 68);
11571156
```
11581157

1159-
### Structs
1158+
### Structures
11601159

11611160
A _structure_ is a nominal [structure type](#structure-types) defined with the
11621161
keyword `struct`.
@@ -2615,21 +2614,21 @@ comma:
26152614
### Structure expressions
26162615

26172616
There are several forms of structure expressions. A _structure expression_
2618-
consists of the [path](#paths) of a [structure item](#structs), followed by
2617+
consists of the [path](#paths) of a [structure item](#structures), followed by
26192618
a brace-enclosed list of one or more comma-separated name-value pairs,
26202619
providing the field values of a new instance of the structure. A field name
26212620
can be any identifier, and is separated from its value expression by a colon.
26222621
The location denoted by a structure field is mutable if and only if the
26232622
enclosing structure is mutable.
26242623

26252624
A _tuple structure expression_ consists of the [path](#paths) of a [structure
2626-
item](#structs), followed by a parenthesized list of one or more
2625+
item](#structures), followed by a parenthesized list of one or more
26272626
comma-separated expressions (in other words, the path of a structure item
26282627
followed by a tuple expression). The structure item must be a tuple structure
26292628
item.
26302629

26312630
A _unit-like structure expression_ consists only of the [path](#paths) of a
2632-
[structure item](#structs).
2631+
[structure item](#structures).
26332632

26342633
The following are examples of structure expressions:
26352634

@@ -3146,7 +3145,7 @@ if` condition is evaluated. If all `if` and `else if` conditions evaluate to
31463145

31473146
A `match` expression branches on a *pattern*. The exact form of matching that
31483147
occurs depends on the pattern. Patterns consist of some combination of
3149-
literals, destructured arrays or enum constructors, structs and tuples,
3148+
literals, destructured arrays or enum constructors, structures and tuples,
31503149
variable binding specifications, wildcards (`..`), and placeholders (`_`). A
31513150
`match` expression has a *head expression*, which is the value to compare to
31523151
the patterns. The type of the patterns must equal the type of the head
@@ -3470,7 +3469,7 @@ named reference to an [`enum` item](#enumerations).
34703469
### Recursive types
34713470

34723471
Nominal types — [enumerations](#enumerated-types) and
3473-
[structs](#structure-types) — may be recursive. That is, each `enum`
3472+
[structures](#structure-types) — may be recursive. That is, each `enum`
34743473
constructor or `struct` field may refer, directly or indirectly, to the
34753474
enclosing `enum` or `struct` type itself. Such recursion has restrictions:
34763475

@@ -3498,7 +3497,7 @@ let a: List<i32> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
34983497
### Pointer types
34993498

35003499
All pointers in Rust are explicit first-class values. They can be copied,
3501-
stored into data structs, and returned from functions. There are two
3500+
stored into data structures, and returned from functions. There are two
35023501
varieties of pointer in Rust:
35033502

35043503
* References (`&`)
@@ -3898,7 +3897,7 @@ references to boxes are dropped.
38983897
### Variables
38993898

39003899
A _variable_ is a component of a stack frame, either a named function parameter,
3901-
an anonymous [temporary](#lvalues-rvalues-and-temporaries), or a named local
3900+
an anonymous [temporary](#lvalues,-rvalues-and-temporaries), or a named local
39023901
variable.
39033902

39043903
A _local variable_ (or *stack-local* allocation) holds a value directly,
@@ -4037,6 +4036,10 @@ In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for
40374036
all compilation needs, and the other options are just available if more
40384037
fine-grained control is desired over the output format of a Rust crate.
40394038

4039+
# Appendix: Rationales and design trade-offs
4040+
4041+
*TODO*.
4042+
40404043
# Appendix: Influences
40414044

40424045
Rust is not a particularly original language, with design elements coming from

branches/auto/src/liballoc/arc.rs

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ impl<T> Arc<T> {
214214
#[stable(feature = "arc_unique", since = "1.4.0")]
215215
pub fn try_unwrap(this: Self) -> Result<T, Self> {
216216
// See `drop` for why all these atomics are like this
217-
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 { return Err(this) }
217+
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 {
218+
return Err(this)
219+
}
218220

219221
atomic::fence(Acquire);
220222

@@ -251,7 +253,9 @@ impl<T: ?Sized> Arc<T> {
251253
let cur = this.inner().weak.load(Relaxed);
252254

253255
// check if the weak counter is currently "locked"; if so, spin.
254-
if cur == usize::MAX { continue }
256+
if cur == usize::MAX {
257+
continue
258+
}
255259

256260
// NOTE: this code currently ignores the possibility of overflow
257261
// into usize::MAX; in general both Rc and Arc need to be adjusted
@@ -348,7 +352,9 @@ impl<T: ?Sized> Clone for Arc<T> {
348352
// We abort because such a program is incredibly degenerate, and we
349353
// don't care to support it.
350354
if old_size > MAX_REFCOUNT {
351-
unsafe { abort(); }
355+
unsafe {
356+
abort();
357+
}
352358
}
353359

354360
Arc { _ptr: self._ptr }
@@ -556,7 +562,9 @@ impl<T: ?Sized> Drop for Arc<T> {
556562
// Because `fetch_sub` is already atomic, we do not need to synchronize
557563
// with other threads unless we are going to delete the object. This
558564
// same logic applies to the below `fetch_sub` to the `weak` count.
559-
if self.inner().strong.fetch_sub(1, Release) != 1 { return }
565+
if self.inner().strong.fetch_sub(1, Release) != 1 {
566+
return
567+
}
560568

561569
// This fence is needed to prevent reordering of use of the data and
562570
// deletion of the data. Because it is marked `Release`, the decreasing
@@ -577,9 +585,7 @@ impl<T: ?Sized> Drop for Arc<T> {
577585
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
578586
atomic::fence(Acquire);
579587

580-
unsafe {
581-
self.drop_slow()
582-
}
588+
unsafe { self.drop_slow() }
583589
}
584590
}
585591

@@ -613,11 +619,15 @@ impl<T: ?Sized> Weak<T> {
613619
// "stale" read of 0 is fine), and any other value is
614620
// confirmed via the CAS below.
615621
let n = inner.strong.load(Relaxed);
616-
if n == 0 { return None }
622+
if n == 0 {
623+
return None
624+
}
617625

618626
// Relaxed is valid for the same reason it is on Arc's Clone impl
619627
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
620-
if old == n { return Some(Arc { _ptr: self._ptr }) }
628+
if old == n {
629+
return Some(Arc { _ptr: self._ptr })
630+
}
621631
}
622632
}
623633

@@ -653,7 +663,9 @@ impl<T: ?Sized> Clone for Weak<T> {
653663

654664
// See comments in Arc::clone() for why we do this (for mem::forget).
655665
if old_size > MAX_REFCOUNT {
656-
unsafe { abort(); }
666+
unsafe {
667+
abort();
668+
}
657669
}
658670

659671
return Weak { _ptr: self._ptr }
@@ -705,9 +717,7 @@ impl<T: ?Sized> Drop for Weak<T> {
705717
// ref, which can only happen after the lock is released.
706718
if self.inner().weak.fetch_sub(1, Release) == 1 {
707719
atomic::fence(Acquire);
708-
unsafe { deallocate(ptr as *mut u8,
709-
size_of_val(&*ptr),
710-
align_of_val(&*ptr)) }
720+
unsafe { deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) }
711721
}
712722
}
713723
}
@@ -727,7 +737,9 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
727737
///
728738
/// five == Arc::new(5);
729739
/// ```
730-
fn eq(&self, other: &Arc<T>) -> bool { *(*self) == *(*other) }
740+
fn eq(&self, other: &Arc<T>) -> bool {
741+
*(*self) == *(*other)
742+
}
731743

732744
/// Inequality for two `Arc<T>`s.
733745
///
@@ -742,7 +754,9 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
742754
///
743755
/// five != Arc::new(5);
744756
/// ```
745-
fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) }
757+
fn ne(&self, other: &Arc<T>) -> bool {
758+
*(*self) != *(*other)
759+
}
746760
}
747761
#[stable(feature = "rust1", since = "1.0.0")]
748762
impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
@@ -776,7 +790,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
776790
///
777791
/// five < Arc::new(5);
778792
/// ```
779-
fn lt(&self, other: &Arc<T>) -> bool { *(*self) < *(*other) }
793+
fn lt(&self, other: &Arc<T>) -> bool {
794+
*(*self) < *(*other)
795+
}
780796

781797
/// 'Less-than or equal to' comparison for two `Arc<T>`s.
782798
///
@@ -791,7 +807,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
791807
///
792808
/// five <= Arc::new(5);
793809
/// ```
794-
fn le(&self, other: &Arc<T>) -> bool { *(*self) <= *(*other) }
810+
fn le(&self, other: &Arc<T>) -> bool {
811+
*(*self) <= *(*other)
812+
}
795813

796814
/// Greater-than comparison for two `Arc<T>`s.
797815
///
@@ -806,7 +824,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
806824
///
807825
/// five > Arc::new(5);
808826
/// ```
809-
fn gt(&self, other: &Arc<T>) -> bool { *(*self) > *(*other) }
827+
fn gt(&self, other: &Arc<T>) -> bool {
828+
*(*self) > *(*other)
829+
}
810830

811831
/// 'Greater-than or equal to' comparison for two `Arc<T>`s.
812832
///
@@ -821,11 +841,15 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
821841
///
822842
/// five >= Arc::new(5);
823843
/// ```
824-
fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) }
844+
fn ge(&self, other: &Arc<T>) -> bool {
845+
*(*self) >= *(*other)
846+
}
825847
}
826848
#[stable(feature = "rust1", since = "1.0.0")]
827849
impl<T: ?Sized + Ord> Ord for Arc<T> {
828-
fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) }
850+
fn cmp(&self, other: &Arc<T>) -> Ordering {
851+
(**self).cmp(&**other)
852+
}
829853
}
830854
#[stable(feature = "rust1", since = "1.0.0")]
831855
impl<T: ?Sized + Eq> Eq for Arc<T> {}
@@ -854,7 +878,9 @@ impl<T> fmt::Pointer for Arc<T> {
854878
#[stable(feature = "rust1", since = "1.0.0")]
855879
impl<T: Default> Default for Arc<T> {
856880
#[stable(feature = "rust1", since = "1.0.0")]
857-
fn default() -> Arc<T> { Arc::new(Default::default()) }
881+
fn default() -> Arc<T> {
882+
Arc::new(Default::default())
883+
}
858884
}
859885

860886
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1015,7 +1041,7 @@ mod tests {
10151041
#[test]
10161042
fn weak_self_cyclic() {
10171043
struct Cycle {
1018-
x: Mutex<Option<Weak<Cycle>>>
1044+
x: Mutex<Option<Weak<Cycle>>>,
10191045
}
10201046

10211047
let a = Arc::new(Cycle { x: Mutex::new(None) });
@@ -1095,7 +1121,9 @@ mod tests {
10951121

10961122
// Make sure deriving works with Arc<T>
10971123
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
1098-
struct Foo { inner: Arc<i32> }
1124+
struct Foo {
1125+
inner: Arc<i32>,
1126+
}
10991127

11001128
#[test]
11011129
fn test_unsized() {
@@ -1108,5 +1136,7 @@ mod tests {
11081136
}
11091137

11101138
impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
1111-
fn borrow(&self) -> &T { &**self }
1139+
fn borrow(&self) -> &T {
1140+
&**self
1141+
}
11121142
}

0 commit comments

Comments
 (0)