Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #46130

Merged
merged 20 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1bfc6c1
impl From<T> for Mutex<T>
Enet4 Nov 18, 2017
0855ea1
impl From<T> for RwLock<T>
Enet4 Nov 18, 2017
44da4a0
Add doc for `Read`ing from `&str` and some related cleanup
vitiral Nov 18, 2017
1e42d5f
Add process::parent_id
sfackler Nov 19, 2017
0f29e71
Fixes spelling error in COMPILER_TESTS.md
nyanzebra Nov 20, 2017
998e3c1
Fix typo in MRI "cannot move out of borrowed content"
ritiek Nov 20, 2017
941852e
Fix some docs summary nits
malbarbo Oct 6, 2017
296aa96
[rustllvm] Use report_fatal_error over llvm_unreachable
Nov 20, 2017
cbcaf73
Print the address of the pointed value in Pointer impl for Rc and Arc
malbarbo Nov 20, 2017
b3baa83
Fix doc tests for trim_right_matches
Arzte Nov 20, 2017
f69d4d4
Fix result for assert_eq
Arzte Nov 20, 2017
2c16502
Rollup merge of #46082 - Enet4:mutex_from, r=sfackler
kennytm Nov 20, 2017
3b1cf4d
Rollup merge of #46088 - vitiral:read_doc, r=steveklabnik
kennytm Nov 20, 2017
fe2ec73
Rollup merge of #46092 - sfackler:ppid, r=alexcrichton
kennytm Nov 20, 2017
ac92ea5
Rollup merge of #46107 - nyanzebra:develop, r=kennytm
kennytm Nov 20, 2017
b32d9ad
Rollup merge of #46119 - ritiek:master, r=arielb1
kennytm Nov 20, 2017
04b9c25
Rollup merge of #46121 - malbarbo:rc_arc_pointer, r=dtolnay
kennytm Nov 20, 2017
07d16a7
Rollup merge of #46122 - malbarbo:docs, r=steveklabnik
kennytm Nov 20, 2017
2a2b2f4
Rollup merge of #46124 - rkruppe:no-llvm_unreachable, r=arielb1
kennytm Nov 20, 2017
079a6e4
Rollup merge of #46128 - Coding-Doctors:patch-1, r=dtolnay
kennytm Nov 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> fmt::Pointer for Arc<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&self.ptr, f)
fmt::Pointer::fmt(&(&**self as *const T), f)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Utilities for formatting and printing `String`s
//! Utilities for formatting and printing `String`s.
//!
//! This module contains the runtime support for the [`format!`] syntax extension.
//! This macro is implemented in the compiler to emit calls to this module in
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Rc<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> fmt::Pointer for Rc<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&self.ptr, f)
fmt::Pointer::fmt(&(&**self as *const T), f)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ impl str {
/// A more complex pattern, using a closure:
///
/// ```
/// assert_eq!("1fooX".trim_left_matches(|c| c == '1' || c == 'X'), "fooX");
/// assert_eq!("1fooX".trim_right_matches(|c| c == '1' || c == 'X'), "1foo");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ macro_rules! try {
})
}

/// Write formatted data into a buffer
/// Write formatted data into a buffer.
///
/// This macro accepts a format string, a list of arguments, and a 'writer'. Arguments will be
/// formatted according to the specified format string and the result will be passed to the writer.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
IllegalMoveOriginKind::Static =>
tcx.cannot_move_out_of(span, "static item", origin),
IllegalMoveOriginKind::BorrowedContent =>
tcx.cannot_move_out_of(span, "borrowed_content", origin),
tcx.cannot_move_out_of(span, "borrowed content", origin),
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } =>
tcx.cannot_move_out_of_interior_of_drop(span, ty, origin),
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>
Expand Down
5 changes: 3 additions & 2 deletions src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// except according to those terms.

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

Expand Down
5 changes: 3 additions & 2 deletions src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// except according to those terms.

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

Expand Down
34 changes: 27 additions & 7 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,8 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
///
/// [`File`]s implement `Read`:
///
/// [`read()`]: trait.Read.html#tymethod.read
/// [`std::io`]: ../../std/io/index.html
/// [`File`]: ../fs/struct.File.html
/// [`BufRead`]: trait.BufRead.html
/// [`BufReader`]: struct.BufReader.html
///
/// ```
/// use std::io;
/// # use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
///
Expand All @@ -449,6 +443,32 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
/// # Ok(())
/// # }
/// ```
///
/// Read from `&str` because [`&[u8]`] implements [`Read`]:
///
/// ```
/// # use std::io;
/// use std::io::prelude::*;
///
/// # fn foo() -> io::Result<()> {
/// let mut b = "This string will be read".as_bytes();
/// let mut buffer = [0; 10];
///
/// // read up to 10 bytes
/// b.read(&mut buffer)?;
///
/// // etc... it works exactly as a File does!
/// # Ok(())
/// # }
/// ```
///
/// [`read()`]: trait.Read.html#tymethod.read
/// [`std::io`]: ../../std/io/index.html
/// [`File`]: ../fs/struct.File.html
/// [`BufRead`]: trait.BufRead.html
/// [`BufReader`]: struct.BufReader.html
/// [`&[u8]`]: primitive.slice.html
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Read {
/// Pull some bytes from this source into the specified buffer, returning
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Panic support in the standard library
//! Panic support in the standard library.

#![stable(feature = "std_panic", since = "1.9.0")]

Expand Down
11 changes: 11 additions & 0 deletions src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
}
}

#[stable(feature = "mutex_from", since = "1.22.0")]
impl<T> From<T> for Mutex<T> {
/// Creates a new mutex in an unlocked state ready for use.
/// This is equivalent to [`Mutex::new`].
///
/// [`Mutex::new`]: #method.new
fn from(t: T) -> Self {
Mutex::new(t)
}
}

#[stable(feature = "mutex_default", since = "1.10.0")]
impl<T: ?Sized + Default> Default for Mutex<T> {
/// Creates a `Mutex<T>`, with the `Default` value for T.
Expand Down
11 changes: 11 additions & 0 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> {
}
}

#[stable(feature = "rw_lock_from", since = "1.22.0")]
impl<T> From<T> for RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
/// This is equivalent to [`RwLock::new`].
///
/// [`RwLock::new`]: #method.new
fn from(t: T) -> Self {
RwLock::new(t)
}
}

impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
unsafe fn new(lock: &'rwlock RwLock<T>)
-> LockResult<RwLockReadGuard<'rwlock, T>> {
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/sys/redox/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,7 @@ pub fn exit(code: i32) -> ! {
pub fn getpid() -> u32 {
syscall::getpid().unwrap() as u32
}

pub fn getppid() -> u32 {
syscall::getppid().unwrap() as u32
}
6 changes: 6 additions & 0 deletions src/libstd/sys/unix/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ impl IntoRawFd for process::ChildStderr {
self.into_inner().into_fd().into_raw()
}
}

/// Returns the OS-assigned process identifier associated with this process's parent.
#[unstable(feature = "unix_ppid", issue = "46104")]
pub fn parent_id() -> u32 {
::sys::os::getppid()
}
4 changes: 4 additions & 0 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,7 @@ pub fn exit(code: i32) -> ! {
pub fn getpid() -> u32 {
unsafe { libc::getpid() as u32 }
}

pub fn getppid() -> u32 {
unsafe { libc::getppid() as u32 }
}
2 changes: 1 addition & 1 deletion src/rustllvm/ArchiveWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static Archive::Kind fromRust(LLVMRustArchiveKind Kind) {
case LLVMRustArchiveKind::COFF:
return Archive::K_COFF;
default:
llvm_unreachable("Bad ArchiveKind.");
report_fatal_error("Bad ArchiveKind.");
}
}

Expand Down
32 changes: 16 additions & 16 deletions src/rustllvm/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
case LLVMRustCodeModel::Large:
return CodeModel::Large;
default:
llvm_unreachable("Bad CodeModel.");
report_fatal_error("Bad CodeModel.");
}
}

Expand All @@ -258,7 +258,7 @@ static CodeGenOpt::Level fromRust(LLVMRustCodeGenOptLevel Level) {
case LLVMRustCodeGenOptLevel::Aggressive:
return CodeGenOpt::Aggressive;
default:
llvm_unreachable("Bad CodeGenOptLevel.");
report_fatal_error("Bad CodeGenOptLevel.");
}
}

Expand Down Expand Up @@ -302,7 +302,7 @@ static Optional<Reloc::Model> fromRust(LLVMRustRelocMode RustReloc) {
break;
#endif
}
llvm_unreachable("Bad RelocModel.");
report_fatal_error("Bad RelocModel.");
}

#if LLVM_RUSTLLVM
Expand Down Expand Up @@ -511,7 +511,7 @@ static TargetMachine::CodeGenFileType fromRust(LLVMRustFileType Type) {
case LLVMRustFileType::ObjectFile:
return TargetMachine::CGFT_ObjectFile;
default:
llvm_unreachable("Bad FileType.");
report_fatal_error("Bad FileType.");
}
}

Expand Down Expand Up @@ -1197,7 +1197,7 @@ extern "C" bool
LLVMRustWriteThinBitcodeToFile(LLVMPassManagerRef PMR,
LLVMModuleRef M,
const char *BcFile) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

struct LLVMRustThinLTOData {
Expand All @@ -1211,62 +1211,62 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
int num_modules,
const char **preserved_symbols,
int num_symbols) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" bool
LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" bool
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" bool
LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" bool
LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" void
LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

struct LLVMRustThinLTOBuffer {
};

extern "C" LLVMRustThinLTOBuffer*
LLVMRustThinLTOBufferCreate(LLVMModuleRef M) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" void
LLVMRustThinLTOBufferFree(LLVMRustThinLTOBuffer *Buffer) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" const void*
LLVMRustThinLTOBufferPtr(const LLVMRustThinLTOBuffer *Buffer) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" size_t
LLVMRustThinLTOBufferLen(const LLVMRustThinLTOBuffer *Buffer) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}

extern "C" LLVMModuleRef
LLVMRustParseBitcodeForThinLTO(LLVMContextRef Context,
const char *data,
size_t len,
const char *identifier) {
llvm_unreachable("ThinLTO not available");
report_fatal_error("ThinLTO not available");
}
#endif // LLVM_VERSION_GE(4, 0)
Loading