Skip to content

Commit 8cee265

Browse files
committed
---
yaml --- r: 217583 b: refs/heads/tmp c: 65b5c15 h: refs/heads/master i: 217581: 297f991 217579: 771e6cb 217575: 9253edc 217567: 915c219 v: v3
1 parent 942eb9e commit 8cee265

37 files changed

+1110
-814
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: 2ad26e850ed5dfedda8c96d7315aee50145ceedd
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: be38926b6941f13b1f03c2e3523b98dd256b3c7b
28+
refs/heads/tmp: 65b5c15384e7fad8868f375d7f1e6f765db0be21
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rust is a fast systems programming language that guarantees
44
memory safety and offers painless concurrency ([no data races]).
55
It does not employ a garbage collector and has minimal runtime overhead.
66

7-
This repo contains the code for `rustc`, the Rust compiler, as well
7+
This repo contains the code for the compiler (`rustc`), as well
88
as standard libraries, tools and documentation for Rust.
99

1010
[no data races]: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
% The (old) Rust Pointer Guide
1+
% The Rust Pointer Guide
22

3-
This content has moved into
4-
[the Rust Programming Language book](book/pointers.html).
3+
This content has been removed, with no direct replacement. Rust only
4+
has two built-in pointer types now,
5+
[references](book/references-and-borrowing.html) and [raw
6+
pointers](book/raw-pointers.html). Older Rusts had many more pointer
7+
types, they’re gone now.

branches/tmp/src/doc/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ series of small examples.
2020

2121
[rbe]: http://rustbyexample.com/
2222

23+
# The Standard Library
24+
25+
We have [API documentation for the entire standard
26+
library](std/index.html). There's a list of crates on the left with more
27+
specific sections, or you can use the search bar at the top to search for
28+
something if you know its name.
29+
2330
# Community & Getting Help
2431

2532
If you need help with something, or just want to talk about Rust with others,
@@ -75,13 +82,6 @@ There are questions that are asked quite often, so we've made FAQs for them:
7582
* [Project FAQ](complement-project-faq.html)
7683
* [How to submit a bug report](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports)
7784

78-
# The Standard Library
79-
80-
We have [API documentation for the entire standard
81-
library](std/index.html). There's a list of crates on the left with more
82-
specific sections, or you can use the search bar at the top to search for
83-
something if you know its name.
84-
8585
# The Error Index
8686

8787
If you encounter an error while compiling your code you may be able to look it

branches/tmp/src/doc/trpl/academic-research.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Recommended for inspiration and a better understanding of Rust's background.
1212
* [Macros that work together](https://www.cs.utah.edu/plt/publications/jfp12-draft-fcdf.pdf)
1313
* [Traits: composable units of behavior](http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf)
1414
* [Alias burying](http://www.cs.uwm.edu/faculty/boyland/papers/unique-preprint.ps) - We tried something similar and abandoned it.
15-
* [External uniqueness is unique enough](http://www.computingscience.nl/research/techreps/repo/CS-2002/2002-048.pdf)
15+
* [External uniqueness is unique enough](http://www.cs.uu.nl/research/techreps/UU-CS-2002-048.html)
1616
* [Uniqueness and Reference Immutability for Safe Parallelism](https://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf)
1717
* [Region Based Memory Management](http://www.cs.ucla.edu/~palsberg/tba/papers/tofte-talpin-iandc97.pdf)
1818

@@ -26,10 +26,10 @@ Recommended for inspiration and a better understanding of Rust's background.
2626
* [Dynamic circular work stealing deque](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.170.1097&rep=rep1&type=pdf) - The Chase/Lev deque
2727
* [Work-first and help-first scheduling policies for async-finish task parallelism](http://www.cs.rice.edu/%7Eyguo/pubs/PID824943.pdf) - More general than fully-strict work stealing
2828
* [A Java fork/join calamity](http://www.coopsoft.com/ar/CalamityArticle.html) - critique of Java's fork/join library, particularly its application of work stealing to non-strict computation
29-
* [Scheduling techniques for concurrent systems](http://www.ece.rutgers.edu/%7Eparashar/Classes/ece572-papers/05/ps-ousterhout.pdf)
29+
* [Scheduling techniques for concurrent systems](http://www.stanford.edu/~ouster/cgi-bin/papers/coscheduling.pdf)
3030
* [Contention aware scheduling](http://www.blagodurov.net/files/a8-blagodurov.pdf)
3131
* [Balanced work stealing for time-sharing multicores](http://www.cse.ohio-state.edu/hpcs/WWW/HTML/publications/papers/TR-12-1.pdf)
32-
* [Three layer cake](http://www.upcrc.illinois.edu/workshops/paraplop10/papers/paraplop10_submission_8.pdf)
32+
* [Three layer cake for shared-memory programming](http://dl.acm.org/citation.cfm?id=1953616&dl=ACM&coll=DL&CFID=524387192&CFTOKEN=44362705)
3333
* [Non-blocking steal-half work queues](http://www.cs.bgu.ac.il/%7Ehendlerd/papers/p280-hendler.pdf)
3434
* [Reagents: expressing and composing fine-grained concurrency](http://www.mpi-sws.org/~turon/reagents.pdf)
3535
* [Algorithms for scalable synchronization of shared-memory multiprocessors](https://www.cs.rochester.edu/u/scott/papers/1991_TOCS_synch.pdf)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ pub fn new(value: T) -> Rc<T> {
3333
```
3434

3535
This code generates documentation that looks [like this][rc-new]. I've left the
36-
implementation out, with a regular comment in its place. That's the first thing
37-
to notice about this annotation: it uses `///`, instead of `//`. The triple slash
36+
implementation out, with a regular comment in its place.
37+
38+
The first thing to notice about this annotation is that it uses
39+
`///` instead of `//`. The triple slash
3840
indicates a documentation comment.
3941

4042
Documentation comments are written in Markdown.
@@ -375,7 +377,7 @@ $ rustdoc --test path/to/my/crate/root.rs
375377
$ cargo test
376378
```
377379

378-
That's right, `cargo test` tests embedded documentation too. However,
380+
That's right, `cargo test` tests embedded documentation too. However,
379381
`cargo test` will not test binary crates, only library ones. This is
380382
due to the way `rustdoc` works: it links against the library to be tested,
381383
but with a binary, there’s nothing to link to.

branches/tmp/src/doc/trpl/link-args.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Note that this feature is currently hidden behind the `feature(link_args)` gate
1717
because this is not a sanctioned way of performing linking. Right now rustc
1818
shells out to the system linker, so it makes sense to provide extra command line
1919
arguments, but this will not always be the case. In the future rustc may use
20-
LLVM directly to link native libraries in which case `link_args` will have no
20+
LLVM directly to link native libraries, in which case `link_args` will have no
2121
meaning.
2222

2323
It is highly recommended to *not* use this attribute, and rather use the more

branches/tmp/src/doc/trpl/references-and-borrowing.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ In other words, `y` is only valid for the scope where `x` exists. As soon as
336336
the borrow ‘doesn’t live long enough’ because it’s not valid for the right
337337
amount of time.
338338

339-
The same problem occurs when the reference is declared _before_ the variable it refers to:
339+
The same problem occurs when the reference is declared _before_ the variable it
340+
refers to. This is because resources within the same scope are freed in the
341+
opposite order they were declared:
340342

341343
```rust,ignore
342344
let y: &i32;
@@ -369,3 +371,6 @@ statement 1 at 3:14
369371
println!("{}", y);
370372
}
371373
```
374+
375+
In the above example, `y` is declared before `x`, meaning that `y` lives longer
376+
than `x`, which is not allowed.

branches/tmp/src/libcollectionstest/str.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn test_split_at() {
705705
#[should_panic]
706706
fn test_split_at_boundscheck() {
707707
let s = "ศไทย中华Việt Nam";
708-
let (a, b) = s.split_at(1);
708+
s.split_at(1);
709709
}
710710

711711
#[test]
@@ -1820,6 +1820,14 @@ mod pattern {
18201820
Match (4, 6),
18211821
Reject(6, 7),
18221822
]);
1823+
make_test!(str_searcher_ascii_haystack_seq, "bb", "abbcbbbbd", [
1824+
Reject(0, 1),
1825+
Match (1, 3),
1826+
Reject(3, 4),
1827+
Match (4, 6),
1828+
Match (6, 8),
1829+
Reject(8, 9),
1830+
]);
18231831
make_test!(str_searcher_empty_needle_ascii_haystack, "", "abbcbbd", [
18241832
Match (0, 0),
18251833
Reject(0, 1),

branches/tmp/src/libcore/atomic.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ impl AtomicBool {
272272
unsafe { atomic_swap(self.v.get(), val, order) > 0 }
273273
}
274274

275-
/// Stores a value into the bool if the current value is the same as the expected value.
275+
/// Stores a value into the `bool` if the current value is the same as the `current` value.
276276
///
277-
/// The return value is always the previous value. If it is equal to `old`, then the value was
278-
/// updated.
277+
/// The return value is always the previous value. If it is equal to `current`, then the value
278+
/// was updated.
279279
///
280-
/// `swap` also takes an `Ordering` argument which describes the memory ordering of this
281-
/// operation.
280+
/// `compare_and_swap` also takes an `Ordering` argument which describes the memory ordering of
281+
/// this operation.
282282
///
283283
/// # Examples
284284
///
@@ -295,11 +295,11 @@ impl AtomicBool {
295295
/// ```
296296
#[inline]
297297
#[stable(feature = "rust1", since = "1.0.0")]
298-
pub fn compare_and_swap(&self, old: bool, new: bool, order: Ordering) -> bool {
299-
let old = if old { UINT_TRUE } else { 0 };
298+
pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool {
299+
let current = if current { UINT_TRUE } else { 0 };
300300
let new = if new { UINT_TRUE } else { 0 };
301301

302-
unsafe { atomic_compare_and_swap(self.v.get(), old, new, order) > 0 }
302+
unsafe { atomic_compare_and_swap(self.v.get(), current, new, order) > 0 }
303303
}
304304

305305
/// Logical "and" with a boolean value.
@@ -515,10 +515,10 @@ impl AtomicIsize {
515515
unsafe { atomic_swap(self.v.get(), val, order) }
516516
}
517517

518-
/// Stores a value into the isize if the current value is the same as the expected value.
518+
/// Stores a value into the `isize` if the current value is the same as the `current` value.
519519
///
520-
/// The return value is always the previous value. If it is equal to `old`, then the value was
521-
/// updated.
520+
/// The return value is always the previous value. If it is equal to `current`, then the value
521+
/// was updated.
522522
///
523523
/// `compare_and_swap` also takes an `Ordering` argument which describes the memory ordering of
524524
/// this operation.
@@ -538,8 +538,8 @@ impl AtomicIsize {
538538
/// ```
539539
#[inline]
540540
#[stable(feature = "rust1", since = "1.0.0")]
541-
pub fn compare_and_swap(&self, old: isize, new: isize, order: Ordering) -> isize {
542-
unsafe { atomic_compare_and_swap(self.v.get(), old, new, order) }
541+
pub fn compare_and_swap(&self, current: isize, new: isize, order: Ordering) -> isize {
542+
unsafe { atomic_compare_and_swap(self.v.get(), current, new, order) }
543543
}
544544

545545
/// Add an isize to the current value, returning the previous value.
@@ -709,10 +709,10 @@ impl AtomicUsize {
709709
unsafe { atomic_swap(self.v.get(), val, order) }
710710
}
711711

712-
/// Stores a value into the usize if the current value is the same as the expected value.
712+
/// Stores a value into the `usize` if the current value is the same as the `current` value.
713713
///
714-
/// The return value is always the previous value. If it is equal to `old`, then the value was
715-
/// updated.
714+
/// The return value is always the previous value. If it is equal to `current`, then the value
715+
/// was updated.
716716
///
717717
/// `compare_and_swap` also takes an `Ordering` argument which describes the memory ordering of
718718
/// this operation.
@@ -732,8 +732,8 @@ impl AtomicUsize {
732732
/// ```
733733
#[inline]
734734
#[stable(feature = "rust1", since = "1.0.0")]
735-
pub fn compare_and_swap(&self, old: usize, new: usize, order: Ordering) -> usize {
736-
unsafe { atomic_compare_and_swap(self.v.get(), old, new, order) }
735+
pub fn compare_and_swap(&self, current: usize, new: usize, order: Ordering) -> usize {
736+
unsafe { atomic_compare_and_swap(self.v.get(), current, new, order) }
737737
}
738738

739739
/// Add to the current usize, returning the previous value.
@@ -910,10 +910,10 @@ impl<T> AtomicPtr<T> {
910910
unsafe { atomic_swap(self.p.get() as *mut usize, ptr as usize, order) as *mut T }
911911
}
912912

913-
/// Stores a value into the pointer if the current value is the same as the expected value.
913+
/// Stores a value into the pointer if the current value is the same as the `current` value.
914914
///
915-
/// The return value is always the previous value. If it is equal to `old`, then the value was
916-
/// updated.
915+
/// The return value is always the previous value. If it is equal to `current`, then the value
916+
/// was updated.
917917
///
918918
/// `compare_and_swap` also takes an `Ordering` argument which describes the memory ordering of
919919
/// this operation.
@@ -933,9 +933,9 @@ impl<T> AtomicPtr<T> {
933933
/// ```
934934
#[inline]
935935
#[stable(feature = "rust1", since = "1.0.0")]
936-
pub fn compare_and_swap(&self, old: *mut T, new: *mut T, order: Ordering) -> *mut T {
936+
pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T {
937937
unsafe {
938-
atomic_compare_and_swap(self.p.get() as *mut usize, old as usize,
938+
atomic_compare_and_swap(self.p.get() as *mut usize, current as usize,
939939
new as usize, order) as *mut T
940940
}
941941
}

branches/tmp/src/libcore/mem.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,48 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
365365

366366
/// Disposes of a value.
367367
///
368-
/// This function can be used to destroy any value by allowing `drop` to take ownership of its
369-
/// argument.
368+
/// While this does call the argument's implementation of `Drop`, it will not
369+
/// release any borrows, as borrows are based on lexical scope.
370370
///
371371
/// # Examples
372372
///
373+
/// Basic usage:
374+
///
375+
/// ```
376+
/// let v = vec![1, 2, 3];
377+
///
378+
/// drop(v); // explicitly drop the vector
379+
/// ```
380+
///
381+
/// Borrows are based on lexical scope, so this produces an error:
382+
///
383+
/// ```ignore
384+
/// let mut v = vec![1, 2, 3];
385+
/// let x = &v[0];
386+
///
387+
/// drop(x); // explicitly drop the reference, but the borrow still exists
388+
///
389+
/// v.push(4); // error: cannot borrow `v` as mutable because it is also
390+
/// // borrowed as immutable
391+
/// ```
392+
///
393+
/// An inner scope is needed to fix this:
394+
///
395+
/// ```
396+
/// let mut v = vec![1, 2, 3];
397+
///
398+
/// {
399+
/// let x = &v[0];
400+
///
401+
/// drop(x); // this is now redundant, as `x` is going out of scope anyway
402+
/// }
403+
///
404+
/// v.push(4); // no problems
405+
/// ```
406+
///
407+
/// Since `RefCell` enforces the borrow rules at runtime, `drop()` can
408+
/// seemingly release a borrow of one:
409+
///
373410
/// ```
374411
/// use std::cell::RefCell;
375412
///

0 commit comments

Comments
 (0)