Skip to content

Commit f15d651

Browse files
committed
Auto merge of #52344 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 16 pull requests Successful merges: - #51962 (Provide llvm-strip in llvm-tools component) - #52003 (Implement `Option::replace` in the core library) - #52156 (Update std::ascii::ASCIIExt deprecation notes) - #52242 (NLL: Suggest `ref mut` and `&mut self`) - #52244 (Don't display default generic parameters in diagnostics that compare types) - #52290 (Deny bare trait objects in src/librustc_save_analysis) - #52293 (Deny bare trait objects in librustc_typeck) - #52299 (Deny bare trait objects in src/libserialize) - #52300 (Deny bare trait objects in librustc_target and libtest) - #52302 (Deny bare trait objects in the rest of rust) - #52310 (Backport 1.27.1 release notes to master) - #52314 (Fix ICE when using a pointer cast as array size) - #52315 (Resolve FIXME(#27942)) - #52316 (task: remove wrong comments about non-existent LocalWake trait) - #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade) - #52332 (dead-code lint: say "constructed", "called" for structs, functions) Failed merges: r? @ghost
2 parents bce32b5 + 9dff778 commit f15d651

File tree

85 files changed

+1076
-173
lines changed

Some content is hidden

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

85 files changed

+1076
-173
lines changed

RELEASES.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ Compatibility Notes
140140
[`{Any + Send + Sync}::downcast_ref`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref-2
141141
[`{Any + Send + Sync}::is`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.is-2
142142

143+
Version 1.27.1 (2018-07-10)
144+
===========================
145+
146+
Security Notes
147+
--------------
148+
149+
- rustdoc would execute plugins in the /tmp/rustdoc/plugins directory
150+
when running, which enabled executing code as some other user on a
151+
given machine. This release fixes that vulnerability; you can read
152+
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].
153+
154+
Thank you to Red Hat for responsibily disclosing this vulnerability to us.
155+
156+
Compatibility Notes
157+
-------------------
158+
159+
- The borrow checker was fixed to avoid an additional potential unsoundness when using
160+
match ergonomics: [#51415][51415], [#49534][49534].
161+
162+
[51415]: https://github.com/rust-lang/rust/issues/51415
163+
[49534]: https://github.com/rust-lang/rust/issues/49534
164+
[rustdoc-sec]: https://blog.rust-lang.org/2018/07/06/security-advisory-for-rustdoc.html
165+
[CVE-2018-1000622]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=%20CVE-2018-1000622
143166

144167
Version 1.27.0 (2018-06-21)
145168
==========================

src/bootstrap/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ const LLVM_TOOLS: &[&str] = &[
206206
"llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume
207207
"llvm-objdump", // used to disassemble programs
208208
"llvm-profdata", // used to inspect and merge files generated by profiles
209-
"llvm-size", // prints the size of the linker sections of a program
209+
"llvm-size", // used to prints the size of the linker sections of a program
210+
"llvm-strip", // used to discard symbols from binary files to reduce their size
210211
];
211212

212213
/// A structure representing a Rust compiler.

src/build_helper/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(bare_trait_objects)]
12+
1113
use std::fs::File;
1214
use std::path::{Path, PathBuf};
1315
use std::process::{Command, Stdio};

src/liballoc_jemalloc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![no_std]
1212
#![allow(unused_attributes)]
13+
#![deny(bare_trait_objects)]
1314
#![unstable(feature = "alloc_jemalloc",
1415
reason = "implementation detail of std, does not provide any public API",
1516
issue = "0")]

src/liballoc_system/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![no_std]
1212
#![allow(unused_attributes)]
13+
#![deny(bare_trait_objects)]
1314
#![unstable(feature = "alloc_system",
1415
reason = "this library is unlikely to be stabilized in its current \
1516
form or name",

src/libarena/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![cfg_attr(test, feature(test))]
3131

3232
#![allow(deprecated)]
33+
#![deny(bare_trait_objects)]
3334

3435
extern crate alloc;
3536
extern crate rustc_data_structures;

src/libcore/option.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,33 @@ impl<T> Option<T> {
845845
pub fn take(&mut self) -> Option<T> {
846846
mem::replace(self, None)
847847
}
848+
849+
/// Replaces the actual value in the option by the value given in parameter,
850+
/// returning the old value if present,
851+
/// leaving a [`Some`] in its place without deinitializing either one.
852+
///
853+
/// [`Some`]: #variant.Some
854+
///
855+
/// # Examples
856+
///
857+
/// ```
858+
/// #![feature(option_replace)]
859+
///
860+
/// let mut x = Some(2);
861+
/// let old = x.replace(5);
862+
/// assert_eq!(x, Some(5));
863+
/// assert_eq!(old, Some(2));
864+
///
865+
/// let mut x = None;
866+
/// let old = x.replace(3);
867+
/// assert_eq!(x, Some(3));
868+
/// assert_eq!(old, None);
869+
/// ```
870+
#[inline]
871+
#[unstable(feature = "option_replace", issue = "51998")]
872+
pub fn replace(&mut self, value: T) -> Option<T> {
873+
mem::replace(self, Some(value))
874+
}
848875
}
849876

850877
impl<'a, T: Clone> Option<&'a T> {

src/libcore/task/wake.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ impl LocalWaker {
113113
/// but you otherwise shouldn't call it directly.
114114
///
115115
/// If you're working with the standard library then it's recommended to
116-
/// use the `LocalWaker::from` function instead which works with the safe
117-
/// `Rc` type and the safe `LocalWake` trait.
116+
/// use the `local_waker_from_nonlocal` or `local_waker` to convert a `Waker`
117+
/// into a `LocalWaker`.
118118
///
119119
/// For this function to be used safely, it must be sound to call `inner.wake_local()`
120120
/// on the current thread.
@@ -197,9 +197,7 @@ impl Drop for LocalWaker {
197197
/// customization.
198198
///
199199
/// When using `std`, a default implementation of the `UnsafeWake` trait is provided for
200-
/// `Arc<T>` where `T: Wake` and `Rc<T>` where `T: LocalWake`.
201-
///
202-
/// Although the methods on `UnsafeWake` take pointers rather than references,
200+
/// `Arc<T>` where `T: Wake`.
203201
pub unsafe trait UnsafeWake: Send + Sync {
204202
/// Creates a clone of this `UnsafeWake` and stores it behind a `Waker`.
205203
///

src/libcore/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#![feature(reverse_bits)]
4545
#![feature(iterator_find_map)]
4646
#![feature(slice_internals)]
47+
#![feature(option_replace)]
4748

4849
extern crate core;
4950
extern crate test;

src/libcore/tests/option.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,18 @@ fn test_try() {
297297
}
298298
assert_eq!(try_option_err(), Err(NoneError));
299299
}
300+
301+
#[test]
302+
fn test_replace() {
303+
let mut x = Some(2);
304+
let old = x.replace(5);
305+
306+
assert_eq!(x, Some(5));
307+
assert_eq!(old, Some(2));
308+
309+
let mut x = None;
310+
let old = x.replace(3);
311+
312+
assert_eq!(x, Some(3));
313+
assert_eq!(old, None);
314+
}

0 commit comments

Comments
 (0)