Skip to content

Commit 1e44fee

Browse files
committed
Auto merge of #46130 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #46082, #46088, #46092, #46107, #46119, #46121, #46122, #46124, #46128 - Failed merges:
2 parents 33374fa + 079a6e4 commit 1e44fee

File tree

21 files changed

+114
-49
lines changed

21 files changed

+114
-49
lines changed

src/liballoc/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
13281328
#[stable(feature = "rust1", since = "1.0.0")]
13291329
impl<T: ?Sized> fmt::Pointer for Arc<T> {
13301330
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1331-
fmt::Pointer::fmt(&self.ptr, f)
1331+
fmt::Pointer::fmt(&(&**self as *const T), f)
13321332
}
13331333
}
13341334

src/liballoc/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Utilities for formatting and printing `String`s
11+
//! Utilities for formatting and printing `String`s.
1212
//!
1313
//! This module contains the runtime support for the [`format!`] syntax extension.
1414
//! This macro is implemented in the compiler to emit calls to this module in

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Rc<T> {
10721072
#[stable(feature = "rust1", since = "1.0.0")]
10731073
impl<T: ?Sized> fmt::Pointer for Rc<T> {
10741074
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1075-
fmt::Pointer::fmt(&self.ptr, f)
1075+
fmt::Pointer::fmt(&(&**self as *const T), f)
10761076
}
10771077
}
10781078

src/liballoc/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ impl str {
17341734
/// A more complex pattern, using a closure:
17351735
///
17361736
/// ```
1737-
/// assert_eq!("1fooX".trim_left_matches(|c| c == '1' || c == 'X'), "fooX");
1737+
/// assert_eq!("1fooX".trim_right_matches(|c| c == '1' || c == 'X'), "1foo");
17381738
/// ```
17391739
#[stable(feature = "rust1", since = "1.0.0")]
17401740
pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str

src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ macro_rules! try {
361361
})
362362
}
363363

364-
/// Write formatted data into a buffer
364+
/// Write formatted data into a buffer.
365365
///
366366
/// This macro accepts a format string, a list of arguments, and a 'writer'. Arguments will be
367367
/// formatted according to the specified format string and the result will be passed to the writer.

src/librustc_mir/borrow_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
9191
IllegalMoveOriginKind::Static =>
9292
tcx.cannot_move_out_of(span, "static item", origin),
9393
IllegalMoveOriginKind::BorrowedContent =>
94-
tcx.cannot_move_out_of(span, "borrowed_content", origin),
94+
tcx.cannot_move_out_of(span, "borrowed content", origin),
9595
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } =>
9696
tcx.cannot_move_out_of_interior_of_drop(span, ty, origin),
9797
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>

src/libstd/f32.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
// except according to those terms.
1010

1111
//! This module provides constants which are specific to the implementation
12-
//! of the `f32` floating point data type. Mathematically significant
13-
//! numbers are provided in the `consts` sub-module.
12+
//! of the `f32` floating point data type.
13+
//!
14+
//! Mathematically significant numbers are provided in the `consts` sub-module.
1415
//!
1516
//! *[See also the `f32` primitive type](../primitive.f32.html).*
1617

src/libstd/f64.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
// except according to those terms.
1010

1111
//! This module provides constants which are specific to the implementation
12-
//! of the `f64` floating point data type. Mathematically significant
13-
//! numbers are provided in the `consts` sub-module.
12+
//! of the `f64` floating point data type.
13+
//!
14+
//! Mathematically significant numbers are provided in the `consts` sub-module.
1415
//!
1516
//! *[See also the `f64` primitive type](../primitive.f64.html).*
1617

src/libstd/io/mod.rs

+27-7
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,8 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
419419
///
420420
/// [`File`]s implement `Read`:
421421
///
422-
/// [`read()`]: trait.Read.html#tymethod.read
423-
/// [`std::io`]: ../../std/io/index.html
424-
/// [`File`]: ../fs/struct.File.html
425-
/// [`BufRead`]: trait.BufRead.html
426-
/// [`BufReader`]: struct.BufReader.html
427-
///
428422
/// ```
429-
/// use std::io;
423+
/// # use std::io;
430424
/// use std::io::prelude::*;
431425
/// use std::fs::File;
432426
///
@@ -449,6 +443,32 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
449443
/// # Ok(())
450444
/// # }
451445
/// ```
446+
///
447+
/// Read from `&str` because [`&[u8]`] implements [`Read`]:
448+
///
449+
/// ```
450+
/// # use std::io;
451+
/// use std::io::prelude::*;
452+
///
453+
/// # fn foo() -> io::Result<()> {
454+
/// let mut b = "This string will be read".as_bytes();
455+
/// let mut buffer = [0; 10];
456+
///
457+
/// // read up to 10 bytes
458+
/// b.read(&mut buffer)?;
459+
///
460+
/// // etc... it works exactly as a File does!
461+
/// # Ok(())
462+
/// # }
463+
/// ```
464+
///
465+
/// [`read()`]: trait.Read.html#tymethod.read
466+
/// [`std::io`]: ../../std/io/index.html
467+
/// [`File`]: ../fs/struct.File.html
468+
/// [`BufRead`]: trait.BufRead.html
469+
/// [`BufReader`]: struct.BufReader.html
470+
/// [`&[u8]`]: primitive.slice.html
471+
///
452472
#[stable(feature = "rust1", since = "1.0.0")]
453473
pub trait Read {
454474
/// Pull some bytes from this source into the specified buffer, returning

src/libstd/panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Panic support in the standard library
11+
//! Panic support in the standard library.
1212
1313
#![stable(feature = "std_panic", since = "1.9.0")]
1414

src/libstd/sync/mutex.rs

+11
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
382382
}
383383
}
384384

385+
#[stable(feature = "mutex_from", since = "1.22.0")]
386+
impl<T> From<T> for Mutex<T> {
387+
/// Creates a new mutex in an unlocked state ready for use.
388+
/// This is equivalent to [`Mutex::new`].
389+
///
390+
/// [`Mutex::new`]: #method.new
391+
fn from(t: T) -> Self {
392+
Mutex::new(t)
393+
}
394+
}
395+
385396
#[stable(feature = "mutex_default", since = "1.10.0")]
386397
impl<T: ?Sized + Default> Default for Mutex<T> {
387398
/// Creates a `Mutex<T>`, with the `Default` value for T.

src/libstd/sync/rwlock.rs

+11
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> {
457457
}
458458
}
459459

460+
#[stable(feature = "rw_lock_from", since = "1.22.0")]
461+
impl<T> From<T> for RwLock<T> {
462+
/// Creates a new instance of an `RwLock<T>` which is unlocked.
463+
/// This is equivalent to [`RwLock::new`].
464+
///
465+
/// [`RwLock::new`]: #method.new
466+
fn from(t: T) -> Self {
467+
RwLock::new(t)
468+
}
469+
}
470+
460471
impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
461472
unsafe fn new(lock: &'rwlock RwLock<T>)
462473
-> LockResult<RwLockReadGuard<'rwlock, T>> {

src/libstd/sys/redox/os.rs

+4
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,7 @@ pub fn exit(code: i32) -> ! {
213213
pub fn getpid() -> u32 {
214214
syscall::getpid().unwrap() as u32
215215
}
216+
217+
pub fn getppid() -> u32 {
218+
syscall::getppid().unwrap() as u32
219+
}

src/libstd/sys/unix/ext/process.rs

+6
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,9 @@ impl IntoRawFd for process::ChildStderr {
191191
self.into_inner().into_fd().into_raw()
192192
}
193193
}
194+
195+
/// Returns the OS-assigned process identifier associated with this process's parent.
196+
#[unstable(feature = "unix_ppid", issue = "46104")]
197+
pub fn parent_id() -> u32 {
198+
::sys::os::getppid()
199+
}

src/libstd/sys/unix/os.rs

+4
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,7 @@ pub fn exit(code: i32) -> ! {
515515
pub fn getpid() -> u32 {
516516
unsafe { libc::getpid() as u32 }
517517
}
518+
519+
pub fn getppid() -> u32 {
520+
unsafe { libc::getppid() as u32 }
521+
}

src/rustllvm/ArchiveWrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static Archive::Kind fromRust(LLVMRustArchiveKind Kind) {
6666
case LLVMRustArchiveKind::COFF:
6767
return Archive::K_COFF;
6868
default:
69-
llvm_unreachable("Bad ArchiveKind.");
69+
report_fatal_error("Bad ArchiveKind.");
7070
}
7171
}
7272

src/rustllvm/PassWrapper.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
235235
case LLVMRustCodeModel::Large:
236236
return CodeModel::Large;
237237
default:
238-
llvm_unreachable("Bad CodeModel.");
238+
report_fatal_error("Bad CodeModel.");
239239
}
240240
}
241241

@@ -258,7 +258,7 @@ static CodeGenOpt::Level fromRust(LLVMRustCodeGenOptLevel Level) {
258258
case LLVMRustCodeGenOptLevel::Aggressive:
259259
return CodeGenOpt::Aggressive;
260260
default:
261-
llvm_unreachable("Bad CodeGenOptLevel.");
261+
report_fatal_error("Bad CodeGenOptLevel.");
262262
}
263263
}
264264

@@ -302,7 +302,7 @@ static Optional<Reloc::Model> fromRust(LLVMRustRelocMode RustReloc) {
302302
break;
303303
#endif
304304
}
305-
llvm_unreachable("Bad RelocModel.");
305+
report_fatal_error("Bad RelocModel.");
306306
}
307307

308308
#if LLVM_RUSTLLVM
@@ -511,7 +511,7 @@ static TargetMachine::CodeGenFileType fromRust(LLVMRustFileType Type) {
511511
case LLVMRustFileType::ObjectFile:
512512
return TargetMachine::CGFT_ObjectFile;
513513
default:
514-
llvm_unreachable("Bad FileType.");
514+
report_fatal_error("Bad FileType.");
515515
}
516516
}
517517

@@ -1197,7 +1197,7 @@ extern "C" bool
11971197
LLVMRustWriteThinBitcodeToFile(LLVMPassManagerRef PMR,
11981198
LLVMModuleRef M,
11991199
const char *BcFile) {
1200-
llvm_unreachable("ThinLTO not available");
1200+
report_fatal_error("ThinLTO not available");
12011201
}
12021202

12031203
struct LLVMRustThinLTOData {
@@ -1211,62 +1211,62 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
12111211
int num_modules,
12121212
const char **preserved_symbols,
12131213
int num_symbols) {
1214-
llvm_unreachable("ThinLTO not available");
1214+
report_fatal_error("ThinLTO not available");
12151215
}
12161216

12171217
extern "C" bool
12181218
LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1219-
llvm_unreachable("ThinLTO not available");
1219+
report_fatal_error("ThinLTO not available");
12201220
}
12211221

12221222
extern "C" bool
12231223
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1224-
llvm_unreachable("ThinLTO not available");
1224+
report_fatal_error("ThinLTO not available");
12251225
}
12261226

12271227
extern "C" bool
12281228
LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1229-
llvm_unreachable("ThinLTO not available");
1229+
report_fatal_error("ThinLTO not available");
12301230
}
12311231

12321232
extern "C" bool
12331233
LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1234-
llvm_unreachable("ThinLTO not available");
1234+
report_fatal_error("ThinLTO not available");
12351235
}
12361236

12371237
extern "C" void
12381238
LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
1239-
llvm_unreachable("ThinLTO not available");
1239+
report_fatal_error("ThinLTO not available");
12401240
}
12411241

12421242
struct LLVMRustThinLTOBuffer {
12431243
};
12441244

12451245
extern "C" LLVMRustThinLTOBuffer*
12461246
LLVMRustThinLTOBufferCreate(LLVMModuleRef M) {
1247-
llvm_unreachable("ThinLTO not available");
1247+
report_fatal_error("ThinLTO not available");
12481248
}
12491249

12501250
extern "C" void
12511251
LLVMRustThinLTOBufferFree(LLVMRustThinLTOBuffer *Buffer) {
1252-
llvm_unreachable("ThinLTO not available");
1252+
report_fatal_error("ThinLTO not available");
12531253
}
12541254

12551255
extern "C" const void*
12561256
LLVMRustThinLTOBufferPtr(const LLVMRustThinLTOBuffer *Buffer) {
1257-
llvm_unreachable("ThinLTO not available");
1257+
report_fatal_error("ThinLTO not available");
12581258
}
12591259

12601260
extern "C" size_t
12611261
LLVMRustThinLTOBufferLen(const LLVMRustThinLTOBuffer *Buffer) {
1262-
llvm_unreachable("ThinLTO not available");
1262+
report_fatal_error("ThinLTO not available");
12631263
}
12641264

12651265
extern "C" LLVMModuleRef
12661266
LLVMRustParseBitcodeForThinLTO(LLVMContextRef Context,
12671267
const char *data,
12681268
size_t len,
12691269
const char *identifier) {
1270-
llvm_unreachable("ThinLTO not available");
1270+
report_fatal_error("ThinLTO not available");
12711271
}
12721272
#endif // LLVM_VERSION_GE(4, 0)

0 commit comments

Comments
 (0)