Skip to content

Commit d6c711b

Browse files
committed
---
yaml --- r: 236435 b: refs/heads/auto c: 081278e h: refs/heads/master i: 236433: e57d0ac 236431: 6c908f8 v: v3
1 parent 92d94d7 commit d6c711b

Some content is hidden

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

63 files changed

+346
-220
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: aed73e0122e538375e6ef827e90c6d1a191c5fff
11+
refs/heads/auto: 081278eb7acc761f583351e846ebad21c88331ff
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/doc/trpl/closures.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,8 @@ fn factory() -> &(Fn(i32) -> i32) {
411411
```
412412

413413
Right. Because we have a reference, we need to give it a lifetime. But
414-
our `factory()` function takes no arguments, so
415-
[elision](lifetimes.html#lifetime-elision) doesn’t kick in here. Then what
416-
choices do we have? Try `'static`:
414+
our `factory()` function takes no arguments, so elision doesn’t kick in
415+
here. What lifetime can we choose? `'static`:
417416

418417
```rust,ignore
419418
fn factory() -> &'static (Fn(i32) -> i32) {
@@ -433,7 +432,7 @@ But we get another error:
433432
```text
434433
error: mismatched types:
435434
expected `&'static core::ops::Fn(i32) -> i32`,
436-
found `[closure@<anon>:7:9: 7:20]`
435+
found `[closure <anon>:7:9: 7:20]`
437436
(expected &-ptr,
438437
found closure) [E0308]
439438
|x| x + num
@@ -442,17 +441,21 @@ error: mismatched types:
442441
```
443442

444443
This error is letting us know that we don’t have a `&'static Fn(i32) -> i32`,
445-
we have a `[closure@<anon>:7:9: 7:20]`. Wait, what?
444+
we have a `[closure <anon>:7:9: 7:20]`. Wait, what?
446445

447446
Because each closure generates its own environment `struct` and implementation
448447
of `Fn` and friends, these types are anonymous. They exist just solely for
449-
this closure. So Rust shows them as `closure@<anon>`, rather than some
448+
this closure. So Rust shows them as `closure <anon>`, rather than some
450449
autogenerated name.
451450

452-
The error also points out that the return type is expected to be a reference,
453-
but what we are trying to return is not. Further, we cannot directly assign a
454-
`'static` lifetime to an object. So we'll take a different approach and return
455-
a "trait object" by `Box`ing up the `Fn`. This _almost_ works:
451+
But why doesn’t our closure implement `&'static Fn`? Well, as we discussed before,
452+
closures borrow their environment. And in this case, our environment is based
453+
on a stack-allocated `5`, the `num` variable binding. So the borrow has a lifetime
454+
of the stack frame. So if we returned this closure, the function call would be
455+
over, the stack frame would go away, and our closure is capturing an environment
456+
of garbage memory!
457+
458+
So what to do? This _almost_ works:
456459

457460
```rust,ignore
458461
fn factory() -> Box<Fn(i32) -> i32> {
@@ -468,7 +471,7 @@ assert_eq!(6, answer);
468471
# }
469472
```
470473

471-
There’s just one last problem:
474+
We use a trait object, by `Box`ing up the `Fn`. There’s just one last problem:
472475

473476
```text
474477
error: closure may outlive the current function, but it borrows `num`,
@@ -477,12 +480,8 @@ Box::new(|x| x + num)
477480
^~~~~~~~~~~
478481
```
479482

480-
Well, as we discussed before, closures borrow their environment. And in this
481-
case, our environment is based on a stack-allocated `5`, the `num` variable
482-
binding. So the borrow has a lifetime of the stack frame. So if we returned
483-
this closure, the function call would be over, the stack frame would go away,
484-
and our closure is capturing an environment of garbage memory! With one last
485-
fix, we can make this work:
483+
We still have a reference to the parent stack frame. With one last fix, we can
484+
make this work:
486485

487486
```rust
488487
fn factory() -> Box<Fn(i32) -> i32> {

branches/auto/src/liballoc/boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ use core::raw::{TraitObject};
8080
/// use std::boxed::HEAP;
8181
///
8282
/// fn main() {
83-
/// let foo: Box<i32> = in HEAP { 5 };
83+
/// let foo = box(HEAP) 5;
8484
/// let foo = box 5;
8585
/// }
8686
/// ```
87+
#[lang = "exchange_heap"]
8788
#[unstable(feature = "box_heap",
8889
reason = "may be renamed; uncertain about custom allocator design",
8990
issue = "27779")]

branches/auto/src/libcollections/binary_heap.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,12 @@ use vec::{self, Vec};
167167
/// item's ordering relative to any other item, as determined by the `Ord`
168168
/// trait, changes while it is in the heap. This is normally only possible
169169
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
170+
#[derive(Clone)]
170171
#[stable(feature = "rust1", since = "1.0.0")]
171172
pub struct BinaryHeap<T> {
172173
data: Vec<T>,
173174
}
174175

175-
#[stable(feature = "rust1", since = "1.0.0")]
176-
impl<T: Clone> Clone for BinaryHeap<T> {
177-
fn clone(&self) -> Self {
178-
BinaryHeap { data: self.data.clone() }
179-
}
180-
181-
fn clone_from(&mut self, source: &Self) {
182-
self.data.clone_from(&source.data);
183-
}
184-
}
185-
186176
#[stable(feature = "rust1", since = "1.0.0")]
187177
impl<T: Ord> Default for BinaryHeap<T> {
188178
#[inline]

branches/auto/src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#![feature(unsafe_no_drop_flag, filling_drop)]
6363
#![feature(decode_utf16)]
6464
#![feature(utf8_error)]
65-
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
65+
#![cfg_attr(test, feature(rand, test))]
6666

6767
#![feature(no_std)]
6868
#![no_std]

branches/auto/src/libcollections/string.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use vec::Vec;
3030
use boxed::Box;
3131

3232
/// A growable string stored as a UTF-8 encoded buffer.
33-
#[derive(PartialOrd, Eq, Ord)]
33+
#[derive(Clone, PartialOrd, Eq, Ord)]
3434
#[stable(feature = "rust1", since = "1.0.0")]
3535
pub struct String {
3636
vec: Vec<u8>,
@@ -765,17 +765,6 @@ impl fmt::Display for FromUtf16Error {
765765
}
766766
}
767767

768-
#[stable(feature = "rust1", since = "1.0.0")]
769-
impl Clone for String {
770-
fn clone(&self) -> Self {
771-
String { vec: self.vec.clone() }
772-
}
773-
774-
fn clone_from(&mut self, source: &Self) {
775-
self.vec.clone_from(&source.vec);
776-
}
777-
}
778-
779768
#[stable(feature = "rust1", since = "1.0.0")]
780769
impl FromIterator<char> for String {
781770
fn from_iter<I: IntoIterator<Item=char>>(iterable: I) -> String {

branches/auto/src/libcollections/vec.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,15 +1007,19 @@ impl<T:Clone> Clone for Vec<T> {
10071007

10081008
fn clone_from(&mut self, other: &Vec<T>) {
10091009
// drop anything in self that will not be overwritten
1010-
self.truncate(other.len());
1011-
let len = self.len();
1010+
if self.len() > other.len() {
1011+
self.truncate(other.len())
1012+
}
10121013

10131014
// reuse the contained values' allocations/resources.
1014-
self.clone_from_slice(&other[..len]);
1015+
for (place, thing) in self.iter_mut().zip(other) {
1016+
place.clone_from(thing)
1017+
}
10151018

10161019
// self.len <= other.len due to the truncate above, so the
10171020
// slice here is always in-bounds.
1018-
self.push_all(&other[len..]);
1021+
let slice = &other[self.len()..];
1022+
self.push_all(slice);
10191023
}
10201024
}
10211025

branches/auto/src/libcore/array.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,14 @@ use slice::{Iter, IterMut, SliceExt};
3535
///
3636
/// This trait can be used to implement other traits on fixed-size arrays
3737
/// without causing much metadata bloat.
38-
///
39-
/// The trait is marked unsafe in order to restrict implementors to fixed-size
40-
/// arrays. User of this trait can assume that implementors have the exact
41-
/// layout in memory of a fixed size array (for example, for unsafe
42-
/// initialization).
43-
///
44-
/// Note that the traits AsRef and AsMut provide similar methods for types that
45-
/// may not be fixed-size arrays. Implementors should prefer those traits
46-
/// instead.
47-
pub unsafe trait FixedSizeArray<T> {
38+
pub trait FixedSizeArray<T> {
4839
/// Converts the array to immutable slice
4940
fn as_slice(&self) -> &[T];
5041
/// Converts the array to mutable slice
5142
fn as_mut_slice(&mut self) -> &mut [T];
5243
}
5344

54-
unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
45+
impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
5546
#[inline]
5647
fn as_slice(&self) -> &[T] {
5748
self

branches/auto/src/libcore/mem.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,6 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
434434
/// While this does call the argument's implementation of `Drop`, it will not
435435
/// release any borrows, as borrows are based on lexical scope.
436436
///
437-
/// This effectively does nothing for
438-
/// [types which implement `Copy`](../../book/ownership.html#copy-types),
439-
/// e.g. integers. Such values are copied and _then_ moved into the function,
440-
/// so the value persists after this function call.
441-
///
442437
/// # Examples
443438
///
444439
/// Basic usage:
@@ -491,21 +486,6 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
491486
/// let borrow = x.borrow();
492487
/// println!("{}", *borrow);
493488
/// ```
494-
///
495-
/// Integers and other types implementing `Copy` are unaffected by `drop()`
496-
///
497-
/// ```
498-
/// #[derive(Copy, Clone)]
499-
/// struct Foo(u8);
500-
///
501-
/// let x = 1;
502-
/// let y = Foo(2);
503-
/// drop(x); // a copy of `x` is moved and dropped
504-
/// drop(y); // a copy of `y` is moved and dropped
505-
///
506-
/// println!("x: {}, y: {}", x, y.0); // still available
507-
/// ```
508-
///
509489
#[inline]
510490
#[stable(feature = "rust1", since = "1.0.0")]
511491
pub fn drop<T>(_x: T) { }

branches/auto/src/libcore/str/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ impl Utf8Error {
115115
/// Returns the index in the given string up to which valid UTF-8 was
116116
/// verified.
117117
///
118-
/// Starting at the index provided, but not necessarily at it precisely, an
119-
/// invalid UTF-8 encoding sequence was found.
118+
/// It is the maximum index such that `from_utf8(input[..index])`
119+
/// would return `Some(_)`.
120120
#[unstable(feature = "utf8_error", reason = "method just added",
121121
issue = "27734")]
122122
pub fn valid_up_to(&self) -> usize { self.valid_up_to }

branches/auto/src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
344344
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
345345
}
346346

347+
hir::ExprBox(Some(ref l), ref r) |
347348
hir::ExprIndex(ref l, ref r) |
348349
hir::ExprBinary(_, ref l, ref r) => { // NB: && and || handled earlier
349350
self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
350351
}
351352

352-
hir::ExprBox(ref e) |
353+
hir::ExprBox(None, ref e) |
353354
hir::ExprAddrOf(_, ref e) |
354355
hir::ExprCast(ref e, _) |
355356
hir::ExprUnary(_, ref e) |

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
568568
"user-defined operators are not allowed in {}s", v.msg());
569569
}
570570
}
571-
hir::ExprBox(_) => {
571+
hir::ExprBox(..) |
572+
hir::ExprUnary(hir::UnUniq, _) => {
572573
v.add_qualif(ConstQualif::NOT_CONST);
573574
if v.mode != Mode::Var {
574575
span_err!(v.tcx.sess, e.span, E0010,

0 commit comments

Comments
 (0)