From 1bfc6c1296c0b174577d6817557d0d1ed77687fb Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 18 Nov 2017 16:49:04 +0000 Subject: [PATCH 01/11] impl From for Mutex --- src/libstd/sync/mutex.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index eb507858b92b2..81f5594bc5231 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex { } } +#[stable(feature = "mutex_from", since = "1.22.0")] +impl From for Mutex { + /// 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 Default for Mutex { /// Creates a `Mutex`, with the `Default` value for T. From 0855ea18324f06896818c7df920a5091aa931ff6 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 18 Nov 2017 21:05:06 +0000 Subject: [PATCH 02/11] impl From for RwLock --- src/libstd/sync/rwlock.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 6216d78528dbb..fd6cff6b69c40 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -457,6 +457,17 @@ impl Default for RwLock { } } +#[stable(feature = "rw_lock_from", since = "1.22.0")] +impl From for RwLock { + /// Creates a new instance of an `RwLock` 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) -> LockResult> { From 44da4a0656b8f4197e67798fc93bd13b267a5b7a Mon Sep 17 00:00:00 2001 From: Garrett Berg Date: Sat, 18 Nov 2017 16:10:14 -0700 Subject: [PATCH 03/11] Add doc for `Read`ing from `&str` and some related cleanup --- src/libstd/io/mod.rs | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 57f8c39756e3c..62313d7d3a6e8 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -419,14 +419,8 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result /// /// [`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; /// @@ -449,6 +443,32 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result /// # 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 From 1e42d5f2e1ab05f0f5d07f7c09644574c13e9a12 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 18 Nov 2017 21:09:18 -0800 Subject: [PATCH 04/11] Add process::parent_id I have this as a Unix-only API since it seems like Windows doesn't have a similar API. --- src/libstd/sys/redox/os.rs | 4 ++++ src/libstd/sys/unix/ext/process.rs | 6 ++++++ src/libstd/sys/unix/os.rs | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index c27e2ee172c6b..480765b77a028 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -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 +} diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index cde21b089a20d..60309bec6d4fc 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -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() +} diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 40b73f1b30704..7e965b4b4c5b2 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -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 } +} From 0f29e7103d0a5538ea87b57c3a5229ef119d5a33 Mon Sep 17 00:00:00 2001 From: Robert T Baldwin Date: Sun, 19 Nov 2017 18:59:00 -0800 Subject: [PATCH 05/11] Fixes spelling error in COMPILER_TESTS.md --- src/test/COMPILER_TESTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/COMPILER_TESTS.md b/src/test/COMPILER_TESTS.md index 0380454b8278d..0bc29e8b5aa9e 100644 --- a/src/test/COMPILER_TESTS.md +++ b/src/test/COMPILER_TESTS.md @@ -106,7 +106,7 @@ result is then compared against reference files named those files doesn't exist, the output must be empty. If the test run fails, we will print out the current output, but it is also saved in `build//test/ui/hello_world/main.stdout` (this path is -printed as part of the test failure mesage), so you can run `diff` and +printed as part of the test failure message), so you can run `diff` and so forth. ### Editing and updating the reference files From 998e3c1aaa0b6b8961b0f685f1bd76f76fc43b67 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Mon, 20 Nov 2017 21:26:21 +0530 Subject: [PATCH 06/11] Fix typo in MRI "cannot move out of borrowed content" --- src/librustc_mir/borrow_check.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index 4f0fff5891809..dcc633122f341 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -90,7 +90,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 } => From 941852eef300b3bee42fc6e2ee48cbf40cb9fc3f Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Fri, 6 Oct 2017 11:41:04 -0300 Subject: [PATCH 07/11] Fix some docs summary nits --- src/liballoc/fmt.rs | 2 +- src/libcore/macros.rs | 2 +- src/libstd/f32.rs | 5 +++-- src/libstd/f64.rs | 5 +++-- src/libstd/panic.rs | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 58299d5d8361e..77f65412bd3e1 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -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 diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index c410c2d900470..122baec8e58dc 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -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. diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 14f0edc369058..645a4c2115095 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -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).* diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index e0f0acc6ac441..7fd798155bd59 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -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).* diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 385076e50ddea..219e55d6c1206 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -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")] From 296aa96deb7e7676455db22dcdbaab83d21736ce Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Mon, 20 Nov 2017 17:47:29 +0100 Subject: [PATCH 08/11] [rustllvm] Use report_fatal_error over llvm_unreachable This makes it more robust when assertions are disabled, crashing instead of causing UB. Also introduces a tidy check to enforce this rule, which in turn necessitated making tidy run on src/rustllvm. Fixes #44020 --- src/rustllvm/ArchiveWrapper.cpp | 2 +- src/rustllvm/PassWrapper.cpp | 32 ++++++++++++++++---------------- src/rustllvm/RustWrapper.cpp | 22 +++++++++++----------- src/tools/tidy/src/lib.rs | 1 - src/tools/tidy/src/style.rs | 10 +++++++++- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/rustllvm/ArchiveWrapper.cpp b/src/rustllvm/ArchiveWrapper.cpp index 7f76861c0777d..591ebdc9ddb25 100644 --- a/src/rustllvm/ArchiveWrapper.cpp +++ b/src/rustllvm/ArchiveWrapper.cpp @@ -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."); } } diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index d0c042e6451c7..4a359fb3ad306 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -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."); } } @@ -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."); } } @@ -302,7 +302,7 @@ static Optional fromRust(LLVMRustRelocMode RustReloc) { break; #endif } - llvm_unreachable("Bad RelocModel."); + report_fatal_error("Bad RelocModel."); } #if LLVM_RUSTLLVM @@ -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."); } } @@ -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 { @@ -1211,32 +1211,32 @@ 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 { @@ -1244,22 +1244,22 @@ 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 @@ -1267,6 +1267,6 @@ 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) diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 9aa172591b86f..424b226bcf778 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -54,7 +54,7 @@ static AtomicOrdering fromRust(LLVMAtomicOrdering Ordering) { return AtomicOrdering::SequentiallyConsistent; } - llvm_unreachable("Invalid LLVMAtomicOrdering value!"); + report_fatal_error("Invalid LLVMAtomicOrdering value!"); } static LLVM_THREAD_LOCAL char *LastError; @@ -161,7 +161,7 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) { case SanitizeMemory: return Attribute::SanitizeMemory; } - llvm_unreachable("bad AttributeKind"); + report_fatal_error("bad AttributeKind"); } extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned Index, @@ -356,7 +356,7 @@ static SyncScope::ID fromRust(LLVMRustSynchronizationScope Scope) { case LLVMRustSynchronizationScope::CrossThread: return SyncScope::System; default: - llvm_unreachable("bad SynchronizationScope."); + report_fatal_error("bad SynchronizationScope."); } } #else @@ -367,7 +367,7 @@ static SynchronizationScope fromRust(LLVMRustSynchronizationScope Scope) { case LLVMRustSynchronizationScope::CrossThread: return CrossThread; default: - llvm_unreachable("bad SynchronizationScope."); + report_fatal_error("bad SynchronizationScope."); } } #endif @@ -397,7 +397,7 @@ static InlineAsm::AsmDialect fromRust(LLVMRustAsmDialect Dialect) { case LLVMRustAsmDialect::Intel: return InlineAsm::AD_Intel; default: - llvm_unreachable("bad AsmDialect."); + report_fatal_error("bad AsmDialect."); } } @@ -748,7 +748,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable( unwrapDI(Ty), AlwaysPreserve, fromRust(Flags) #if LLVM_VERSION_GE(4, 0) , - AlignInBits + AlignInBits #endif )); } else { @@ -1149,7 +1149,7 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) { return LLVMTokenTypeKind; #endif } - llvm_unreachable("Unhandled TypeID."); + report_fatal_error("Unhandled TypeID."); } extern "C" void LLVMRustWriteDebugLocToString(LLVMContextRef C, @@ -1370,7 +1370,7 @@ static LLVMRustLinkage toRust(LLVMLinkage Linkage) { case LLVMCommonLinkage: return LLVMRustLinkage::CommonLinkage; default: - llvm_unreachable("Invalid LLVMRustLinkage value!"); + report_fatal_error("Invalid LLVMRustLinkage value!"); } } @@ -1399,7 +1399,7 @@ static LLVMLinkage fromRust(LLVMRustLinkage Linkage) { case LLVMRustLinkage::CommonLinkage: return LLVMCommonLinkage; } - llvm_unreachable("Invalid LLVMRustLinkage value!"); + report_fatal_error("Invalid LLVMRustLinkage value!"); } extern "C" LLVMRustLinkage LLVMRustGetLinkage(LLVMValueRef V) { @@ -1447,7 +1447,7 @@ static LLVMRustVisibility toRust(LLVMVisibility Vis) { case LLVMProtectedVisibility: return LLVMRustVisibility::Protected; } - llvm_unreachable("Invalid LLVMRustVisibility value!"); + report_fatal_error("Invalid LLVMRustVisibility value!"); } static LLVMVisibility fromRust(LLVMRustVisibility Vis) { @@ -1459,7 +1459,7 @@ static LLVMVisibility fromRust(LLVMRustVisibility Vis) { case LLVMRustVisibility::Protected: return LLVMProtectedVisibility; } - llvm_unreachable("Invalid LLVMRustVisibility value!"); + report_fatal_error("Invalid LLVMRustVisibility value!"); } extern "C" LLVMRustVisibility LLVMRustGetVisibility(LLVMValueRef V) { diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 598620fa29392..bd49f288eb2eb 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -57,7 +57,6 @@ fn filter_dirs(path: &Path) -> bool { "src/libbacktrace", "src/libcompiler_builtins", "src/compiler-rt", - "src/rustllvm", "src/liblibc", "src/vendor", "src/rt/hoedown", diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index a689d8a8be411..40d84b98d3a7d 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -50,6 +50,11 @@ const UNEXPLAINED_IGNORE_DOCTEST_INFO: &str = r#"unexplained "```ignore" doctest "#; +const LLVM_UNREACHABLE_INFO: &str = r"\ +C++ code used llvm_unreachable, which triggers undefined behavior +when executed when assertions are disabled. +Use llvm::report_fatal_error for increased robustness."; + /// Parser states for line_is_url. #[derive(PartialEq)] #[allow(non_camel_case_types)] @@ -108,7 +113,7 @@ pub fn check(path: &Path, bad: &mut bool) { let mut contents = String::new(); super::walk(path, &mut super::filter_dirs, &mut |file| { let filename = file.file_name().unwrap().to_string_lossy(); - let extensions = [".rs", ".py", ".js", ".sh", ".c", ".h"]; + let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h"]; if extensions.iter().all(|e| !filename.ends_with(e)) || filename.starts_with(".#") { return @@ -153,6 +158,9 @@ pub fn check(path: &Path, bad: &mut bool) { if line.ends_with("```ignore") || line.ends_with("```rust,ignore") { err(UNEXPLAINED_IGNORE_DOCTEST_INFO); } + if filename.ends_with(".cpp") && line.contains("llvm_unreachable") { + err(LLVM_UNREACHABLE_INFO); + } } if !licenseck(file, &contents) { tidy_error!(bad, "{}: incorrect license", file.display()); From cbcaf736f820f33f619d3c9fe3d997e9e69d779e Mon Sep 17 00:00:00 2001 From: Marco A L Barbosa Date: Mon, 20 Nov 2017 14:41:53 -0200 Subject: [PATCH 09/11] Print the address of the pointed value in Pointer impl for Rc and Arc --- src/liballoc/arc.rs | 2 +- src/liballoc/rc.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 9481cd4e1a4f1..fc0a3c0fd881a 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -1328,7 +1328,7 @@ impl fmt::Debug for Arc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Arc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&self.ptr, f) + fmt::Pointer::fmt(&(&**self as *const T), f) } } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 2f8620cc75051..72b9fa0eb4721 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1072,7 +1072,7 @@ impl fmt::Debug for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Rc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&self.ptr, f) + fmt::Pointer::fmt(&(&**self as *const T), f) } } From b3baa835fc4f92376c1528fc7f0ea7e988773fee Mon Sep 17 00:00:00 2001 From: Benjamin Hoffmeyer Date: Mon, 20 Nov 2017 13:37:56 -0500 Subject: [PATCH 10/11] Fix doc tests for trim_right_matches --- src/liballoc/str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index f68ee847eb3ab..026825b327564 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -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'), "fooX"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str From f69d4d44d8de9edbf94e240bbd2ba252c6937179 Mon Sep 17 00:00:00 2001 From: Benjamin Hoffmeyer Date: Mon, 20 Nov 2017 13:47:42 -0500 Subject: [PATCH 11/11] Fix result for assert_eq --- src/liballoc/str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 026825b327564..6e8515f0b3625 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -1734,7 +1734,7 @@ impl str { /// A more complex pattern, using a closure: /// /// ``` - /// assert_eq!("1fooX".trim_right_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