Skip to content

Commit efa863a

Browse files
committed
---
yaml --- r: 214894 b: refs/heads/beta c: eb3566f h: refs/heads/master v: v3
1 parent 789804d commit efa863a

File tree

8 files changed

+48
-68
lines changed

8 files changed

+48
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 16d037866d1fc5b478e40d92e4f76b2ecb8c4d79
26+
refs/heads/beta: eb3566f239f02c4d7dbd7b8d8cb33fe4455347bd
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 8c0aa6d64ebab528f7eb182812007155d6044972
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ opt rpath 0 "build rpaths into rustc itself"
565565
# This is used by the automation to produce single-target nightlies
566566
opt dist-host-only 0 "only install bins for the host architecture"
567567
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
568-
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
568+
opt llvm-version-check 1 "don't check if the LLVM version is supported, build anyway"
569569

570570
# Optimization and debugging options. These may be overridden by the release channel, etc.
571571
opt_nosave optimize 1 "build optimized rust code"

branches/beta/src/doc/trpl/iterators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ As we've said before, an iterator is something that we can call the
213213
`.next()` method on repeatedly, and it gives us a sequence of things.
214214
Because you need to call the method, this means that iterators
215215
can be *lazy* and not generate all of the values upfront. This code,
216-
for example, does not actually generate the numbers `1-99`, instead
216+
for example, does not actually generate the numbers `1-100`, instead
217217
creating a value that merely represents the sequence:
218218

219219
```rust

branches/beta/src/doc/trpl/mutability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ philosophy, memory safety, and the mechanism by which Rust guarantees it, the
8989
> * exactly one mutable reference (`&mut T`)
9090
9191
[ownership]: ownership.html
92-
[borrowing]: references-and-borrowing.html#borrowing
92+
[borrowing]: borrowing.html#The-Rules
9393

9494
So, that’s the real definition of ‘immutability’: is this safe to have two
9595
pointers to? In `Arc<T>`’s case, yes: the mutation is entirely contained inside

branches/beta/src/liballoc/arc.rs

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.loa
250250
///
251251
/// Returns `None` if the `Arc<T>` is not unique.
252252
///
253-
/// This function is marked **unsafe** because it is racy if weak pointers
254-
/// are active.
255-
///
256253
/// # Examples
257254
///
258255
/// ```
@@ -261,27 +258,24 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.loa
261258
/// # fn main() {
262259
/// use alloc::arc::{Arc, get_mut};
263260
///
264-
/// # unsafe {
265261
/// let mut x = Arc::new(3);
266262
/// *get_mut(&mut x).unwrap() = 4;
267263
/// assert_eq!(*x, 4);
268264
///
269265
/// let _y = x.clone();
270266
/// assert!(get_mut(&mut x).is_none());
271267
/// # }
272-
/// # }
273268
/// ```
274269
#[inline]
275270
#[unstable(feature = "alloc")]
276-
pub unsafe fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
277-
// FIXME(#24880) potential race with upgraded weak pointers here
271+
pub fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
278272
if strong_count(this) == 1 && weak_count(this) == 0 {
279273
// This unsafety is ok because we're guaranteed that the pointer
280274
// returned is the *only* pointer that will ever be returned to T. Our
281275
// reference count is guaranteed to be 1 at this point, and we required
282276
// the Arc itself to be `mut`, so we're returning the only possible
283277
// reference to the inner data.
284-
let inner = &mut **this._ptr;
278+
let inner = unsafe { &mut **this._ptr };
285279
Some(&mut inner.data)
286280
} else {
287281
None
@@ -338,26 +332,19 @@ impl<T: Clone> Arc<T> {
338332
/// This is also referred to as a copy-on-write operation because the inner
339333
/// data is cloned if the reference count is greater than one.
340334
///
341-
/// This method is marked **unsafe** because it is racy if weak pointers
342-
/// are active.
343-
///
344335
/// # Examples
345336
///
346337
/// ```
347338
/// # #![feature(alloc)]
348339
/// use std::sync::Arc;
349340
///
350-
/// # unsafe {
351341
/// let mut five = Arc::new(5);
352342
///
353343
/// let mut_five = five.make_unique();
354-
/// # }
355344
/// ```
356345
#[inline]
357346
#[unstable(feature = "alloc")]
358-
pub unsafe fn make_unique(&mut self) -> &mut T {
359-
// FIXME(#24880) potential race with upgraded weak pointers here
360-
//
347+
pub fn make_unique(&mut self) -> &mut T {
361348
// Note that we hold a strong reference, which also counts as a weak
362349
// reference, so we only clone if there is an additional reference of
363350
// either kind.
@@ -367,7 +354,7 @@ impl<T: Clone> Arc<T> {
367354
}
368355
// As with `get_mut()`, the unsafety is ok because our reference was
369356
// either unique to begin with, or became one upon cloning the contents.
370-
let inner = &mut **self._ptr;
357+
let inner = unsafe { &mut **self._ptr };
371358
&mut inner.data
372359
}
373360
}
@@ -757,43 +744,39 @@ mod tests {
757744

758745
#[test]
759746
fn test_arc_get_mut() {
760-
unsafe {
761-
let mut x = Arc::new(3);
762-
*get_mut(&mut x).unwrap() = 4;
763-
assert_eq!(*x, 4);
764-
let y = x.clone();
765-
assert!(get_mut(&mut x).is_none());
766-
drop(y);
767-
assert!(get_mut(&mut x).is_some());
768-
let _w = x.downgrade();
769-
assert!(get_mut(&mut x).is_none());
770-
}
747+
let mut x = Arc::new(3);
748+
*get_mut(&mut x).unwrap() = 4;
749+
assert_eq!(*x, 4);
750+
let y = x.clone();
751+
assert!(get_mut(&mut x).is_none());
752+
drop(y);
753+
assert!(get_mut(&mut x).is_some());
754+
let _w = x.downgrade();
755+
assert!(get_mut(&mut x).is_none());
771756
}
772757

773758
#[test]
774759
fn test_cowarc_clone_make_unique() {
775-
unsafe {
776-
let mut cow0 = Arc::new(75);
777-
let mut cow1 = cow0.clone();
778-
let mut cow2 = cow1.clone();
779-
780-
assert!(75 == *cow0.make_unique());
781-
assert!(75 == *cow1.make_unique());
782-
assert!(75 == *cow2.make_unique());
783-
784-
*cow0.make_unique() += 1;
785-
*cow1.make_unique() += 2;
786-
*cow2.make_unique() += 3;
787-
788-
assert!(76 == *cow0);
789-
assert!(77 == *cow1);
790-
assert!(78 == *cow2);
791-
792-
// none should point to the same backing memory
793-
assert!(*cow0 != *cow1);
794-
assert!(*cow0 != *cow2);
795-
assert!(*cow1 != *cow2);
796-
}
760+
let mut cow0 = Arc::new(75);
761+
let mut cow1 = cow0.clone();
762+
let mut cow2 = cow1.clone();
763+
764+
assert!(75 == *cow0.make_unique());
765+
assert!(75 == *cow1.make_unique());
766+
assert!(75 == *cow2.make_unique());
767+
768+
*cow0.make_unique() += 1;
769+
*cow1.make_unique() += 2;
770+
*cow2.make_unique() += 3;
771+
772+
assert!(76 == *cow0);
773+
assert!(77 == *cow1);
774+
assert!(78 == *cow2);
775+
776+
// none should point to the same backing memory
777+
assert!(*cow0 != *cow1);
778+
assert!(*cow0 != *cow2);
779+
assert!(*cow1 != *cow2);
797780
}
798781

799782
#[test]
@@ -806,9 +789,7 @@ mod tests {
806789
assert!(75 == *cow1);
807790
assert!(75 == *cow2);
808791

809-
unsafe {
810-
*cow0.make_unique() += 1;
811-
}
792+
*cow0.make_unique() += 1;
812793

813794
assert!(76 == *cow0);
814795
assert!(75 == *cow1);
@@ -829,9 +810,7 @@ mod tests {
829810
assert!(75 == *cow0);
830811
assert!(75 == *cow1_weak.upgrade().unwrap());
831812

832-
unsafe {
833-
*cow0.make_unique() += 1;
834-
}
813+
*cow0.make_unique() += 1;
835814

836815
assert!(76 == *cow0);
837816
assert!(cow1_weak.upgrade().is_none());

branches/beta/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! You can get a non-`'static` `&str` by taking a slice of a `String`:
3131
//!
3232
//! ```
33-
//! let some_string = "Hello, world.".to_string();
33+
//! # let some_string = "Hello, world.".to_string();
3434
//! let s = &some_string;
3535
//! ```
3636
//!

branches/beta/src/libcore/option.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl<T> Option<T> {
422422
}
423423
}
424424

425-
/// Applies a function to the contained value or returns a default.
425+
/// Applies a function to the contained value (if any),
426+
/// or returns a `default` (if not).
426427
///
427428
/// # Examples
428429
///
@@ -435,14 +436,15 @@ impl<T> Option<T> {
435436
/// ```
436437
#[inline]
437438
#[stable(feature = "rust1", since = "1.0.0")]
438-
pub fn map_or<U, F: FnOnce(T) -> U>(self, def: U, f: F) -> U {
439+
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
439440
match self {
440441
Some(t) => f(t),
441-
None => def
442+
None => default,
442443
}
443444
}
444445

445-
/// Applies a function to the contained value or computes a default.
446+
/// Applies a function to the contained value (if any),
447+
/// or computes a `default` (if not).
446448
///
447449
/// # Examples
448450
///
@@ -457,10 +459,10 @@ impl<T> Option<T> {
457459
/// ```
458460
#[inline]
459461
#[stable(feature = "rust1", since = "1.0.0")]
460-
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, def: D, f: F) -> U {
462+
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U {
461463
match self {
462464
Some(t) => f(t),
463-
None => def()
465+
None => default()
464466
}
465467
}
466468

branches/beta/src/libstd/collections/hash/table.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ fn test_rounding() {
528528

529529
// Returns a tuple of (key_offset, val_offset),
530530
// from the start of a mallocated array.
531-
#[inline]
532531
fn calculate_offsets(hashes_size: usize,
533532
keys_size: usize, keys_align: usize,
534533
vals_align: usize)

0 commit comments

Comments
 (0)