Skip to content

Commit a175ee5

Browse files
committed
Auto merge of #42609 - brson:beta-next, r=alexcrichton
Beta next - #42521 - #42512 - #42482 - #42481 - #42480 r? @nikomatsakis remember to untag 'beta-nominated' on linked issues
2 parents 0cd6b0d + 3a2f62d commit a175ee5

File tree

8 files changed

+128
-20
lines changed

8 files changed

+128
-20
lines changed

src/Cargo.lock

+16-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub const CFG_RELEASE_NUM: &'static str = "1.19.0";
2828
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
2929
// Be sure to make this starts with a dot to conform to semver pre-release
3030
// versions (section 9)
31-
pub const CFG_PRERELEASE_VERSION: &'static str = ".1";
31+
pub const CFG_PRERELEASE_VERSION: &'static str = ".2";
3232

3333
pub struct GitInfo {
3434
inner: Option<Info>,

src/librustc/infer/region_inference/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,13 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
12001200
for verify in self.verifys.borrow().iter() {
12011201
debug!("collect_errors: verify={:?}", verify);
12021202
let sub = normalize(self.tcx, var_data, verify.region);
1203+
1204+
// This was an inference variable which didn't get
1205+
// constrained, therefore it can be assume to hold.
1206+
if let ty::ReEmpty = *sub {
1207+
continue;
1208+
}
1209+
12031210
if verify.bound.is_met(region_rels, var_data, sub) {
12041211
continue;
12051212
}

src/librustc_typeck/check/method/confirm.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,13 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
446446
// overloaded lvalue ops, and will be fixed by them in order to get
447447
// the correct region.
448448
let mut source = self.node_ty(expr.id);
449-
if let Some(adjustments) = self.tables.borrow_mut().adjustments.get_mut(&expr.id) {
449+
// Do not mutate adjustments in place, but rather take them,
450+
// and replace them after mutating them, to avoid having the
451+
// tables borrowed during (`deref_mut`) method resolution.
452+
let previous_adjustments = self.tables.borrow_mut().adjustments.remove(&expr.id);
453+
if let Some(mut adjustments) = previous_adjustments {
450454
let pref = LvaluePreference::PreferMutLvalue;
451-
for adjustment in adjustments {
455+
for adjustment in &mut adjustments {
452456
if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind {
453457
if let Some(ok) = self.try_overloaded_deref(expr.span, source, pref) {
454458
let method = self.register_infer_ok_obligations(ok);
@@ -462,6 +466,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
462466
}
463467
source = adjustment.target;
464468
}
469+
self.tables.borrow_mut().adjustments.insert(expr.id, adjustments);
465470
}
466471

467472
match expr.node {

src/libstd/sys/unix/pipe.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use io;
1212
use libc::{self, c_int};
1313
use mem;
14-
use sys::{cvt, cvt_r};
14+
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
1515
use sys::fd::FileDesc;
16+
use sys::{cvt, cvt_r};
1617

1718
////////////////////////////////////////////////////////////////////////////////
1819
// Anonymous pipes
@@ -21,6 +22,9 @@ use sys::fd::FileDesc;
2122
pub struct AnonPipe(FileDesc);
2223

2324
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
25+
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
26+
static INVALID: AtomicBool = ATOMIC_BOOL_INIT;
27+
2428
let mut fds = [0; 2];
2529

2630
// Unfortunately the only known way right now to create atomically set the
@@ -31,13 +35,26 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
3135
target_os = "freebsd",
3236
target_os = "linux",
3337
target_os = "netbsd",
34-
target_os = "openbsd"))
38+
target_os = "openbsd")) &&
39+
!INVALID.load(Ordering::SeqCst)
3540
{
36-
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
41+
3742
if let Some(pipe) = pipe2.get() {
38-
cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) })?;
39-
return Ok((AnonPipe(FileDesc::new(fds[0])),
40-
AnonPipe(FileDesc::new(fds[1]))));
43+
// Note that despite calling a glibc function here we may still
44+
// get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
45+
// emulate on older kernels, so if you happen to be running on
46+
// an older kernel you may see `pipe2` as a symbol but still not
47+
// see the syscall.
48+
match cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
49+
Ok(_) => {
50+
return Ok((AnonPipe(FileDesc::new(fds[0])),
51+
AnonPipe(FileDesc::new(fds[1]))));
52+
}
53+
Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
54+
INVALID.store(true, Ordering::SeqCst);
55+
}
56+
Err(e) => return Err(e),
57+
}
4158
}
4259
}
4360
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;

src/test/run-pass/issue-42463.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::ops::{Deref, DerefMut};
12+
13+
struct CheckedDeref<T, F> {
14+
value: T,
15+
check: F
16+
}
17+
18+
impl<F: Fn(&T) -> bool, T> Deref for CheckedDeref<T, F> {
19+
type Target = T;
20+
fn deref(&self) -> &T {
21+
assert!((self.check)(&self.value));
22+
&self.value
23+
}
24+
}
25+
26+
impl<F: Fn(&T) -> bool, T> DerefMut for CheckedDeref<T, F> {
27+
fn deref_mut(&mut self) -> &mut T {
28+
assert!((self.check)(&self.value));
29+
&mut self.value
30+
}
31+
}
32+
33+
34+
fn main() {
35+
let mut v = CheckedDeref {
36+
value: vec![0],
37+
check: |v: &Vec<_>| !v.is_empty()
38+
};
39+
v.push(1);
40+
assert_eq!(*v, vec![0, 1]);
41+
}

src/test/run-pass/issue-42467.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo<T>(T);
12+
13+
struct IntoIter<T>(T);
14+
15+
impl<'a, T: 'a> Iterator for IntoIter<T> {
16+
type Item = ();
17+
18+
fn next(&mut self) -> Option<()> {
19+
None
20+
}
21+
}
22+
23+
impl<T> IntoIterator for Foo<T> {
24+
type Item = ();
25+
type IntoIter = IntoIter<T>;
26+
27+
fn into_iter(self) -> IntoIter<T> {
28+
IntoIter(self.0)
29+
}
30+
}
31+
32+
fn main() {}

0 commit comments

Comments
 (0)