Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b0bd5f2

Browse files
committedJul 6, 2019
Auto merge of #62452 - Centril:rollup-5jww3h7, r=Centril
Rollup of 5 pull requests Successful merges: - #60081 (Refactor unicode.py script) - #61862 (Make the Weak::{into,as}_raw methods) - #62243 (Improve documentation for built-in macros) - #62422 (Remove some uses of mem::uninitialized) - #62436 (normalize use of backticks/lowercase in compiler messages for librustc_mir) Failed merges: r? @ghost
2 parents dfd52ba + 7ef02dc commit b0bd5f2

File tree

64 files changed

+1745
-702
lines changed

Some content is hidden

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

64 files changed

+1745
-702
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ __pycache__/
3636
/src/libcore/unicode/Scripts.txt
3737
/src/libcore/unicode/SpecialCasing.txt
3838
/src/libcore/unicode/UnicodeData.txt
39+
/src/libcore/unicode/downloaded
3940
/stage[0-9]+/
4041
/target
4142
target/

‎src/liballoc/rc.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,26 +1291,26 @@ impl<T> Weak<T> {
12911291
/// ```
12921292
/// #![feature(weak_into_raw)]
12931293
///
1294-
/// use std::rc::{Rc, Weak};
1294+
/// use std::rc::Rc;
12951295
/// use std::ptr;
12961296
///
12971297
/// let strong = Rc::new("hello".to_owned());
12981298
/// let weak = Rc::downgrade(&strong);
12991299
/// // Both point to the same object
1300-
/// assert!(ptr::eq(&*strong, Weak::as_raw(&weak)));
1300+
/// assert!(ptr::eq(&*strong, weak.as_raw()));
13011301
/// // The strong here keeps it alive, so we can still access the object.
1302-
/// assert_eq!("hello", unsafe { &*Weak::as_raw(&weak) });
1302+
/// assert_eq!("hello", unsafe { &*weak.as_raw() });
13031303
///
13041304
/// drop(strong);
1305-
/// // But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to
1305+
/// // But not any more. We can do weak.as_raw(), but accessing the pointer would lead to
13061306
/// // undefined behaviour.
1307-
/// // assert_eq!("hello", unsafe { &*Weak::as_raw(&weak) });
1307+
/// // assert_eq!("hello", unsafe { &*weak.as_raw() });
13081308
/// ```
13091309
///
13101310
/// [`null`]: ../../std/ptr/fn.null.html
13111311
#[unstable(feature = "weak_into_raw", issue = "60728")]
1312-
pub fn as_raw(this: &Self) -> *const T {
1313-
match this.inner() {
1312+
pub fn as_raw(&self) -> *const T {
1313+
match self.inner() {
13141314
None => ptr::null(),
13151315
Some(inner) => {
13161316
let offset = data_offset_sized::<T>();
@@ -1341,7 +1341,7 @@ impl<T> Weak<T> {
13411341
///
13421342
/// let strong = Rc::new("hello".to_owned());
13431343
/// let weak = Rc::downgrade(&strong);
1344-
/// let raw = Weak::into_raw(weak);
1344+
/// let raw = weak.into_raw();
13451345
///
13461346
/// assert_eq!(1, Rc::weak_count(&strong));
13471347
/// assert_eq!("hello", unsafe { &*raw });
@@ -1353,9 +1353,9 @@ impl<T> Weak<T> {
13531353
/// [`from_raw`]: struct.Weak.html#method.from_raw
13541354
/// [`as_raw`]: struct.Weak.html#method.as_raw
13551355
#[unstable(feature = "weak_into_raw", issue = "60728")]
1356-
pub fn into_raw(this: Self) -> *const T {
1357-
let result = Self::as_raw(&this);
1358-
mem::forget(this);
1356+
pub fn into_raw(self) -> *const T {
1357+
let result = self.as_raw();
1358+
mem::forget(self);
13591359
result
13601360
}
13611361

@@ -1382,18 +1382,18 @@ impl<T> Weak<T> {
13821382
///
13831383
/// let strong = Rc::new("hello".to_owned());
13841384
///
1385-
/// let raw_1 = Weak::into_raw(Rc::downgrade(&strong));
1386-
/// let raw_2 = Weak::into_raw(Rc::downgrade(&strong));
1385+
/// let raw_1 = Rc::downgrade(&strong).into_raw();
1386+
/// let raw_2 = Rc::downgrade(&strong).into_raw();
13871387
///
13881388
/// assert_eq!(2, Rc::weak_count(&strong));
13891389
///
1390-
/// assert_eq!("hello", &*Weak::upgrade(&unsafe { Weak::from_raw(raw_1) }).unwrap());
1390+
/// assert_eq!("hello", &*unsafe { Weak::from_raw(raw_1) }.upgrade().unwrap());
13911391
/// assert_eq!(1, Rc::weak_count(&strong));
13921392
///
13931393
/// drop(strong);
13941394
///
13951395
/// // Decrement the last weak count.
1396-
/// assert!(Weak::upgrade(&unsafe { Weak::from_raw(raw_2) }).is_none());
1396+
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
13971397
/// ```
13981398
///
13991399
/// [`null`]: ../../std/ptr/fn.null.html

0 commit comments

Comments
 (0)
Please sign in to comment.