Skip to content

Commit

Permalink
Auto merge of #42609 - brson:beta-next, r=alexcrichton
Browse files Browse the repository at this point in the history
Beta next

- #42521
- #42512
- #42482
- #42481
- #42480

r? @nikomatsakis remember to untag 'beta-nominated' on linked issues
  • Loading branch information
bors committed Jun 15, 2017
2 parents 0cd6b0d + 3a2f62d commit a175ee5
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 20 deletions.
26 changes: 16 additions & 10 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bootstrap/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const CFG_RELEASE_NUM: &'static str = "1.19.0";
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
// Be sure to make this starts with a dot to conform to semver pre-release
// versions (section 9)
pub const CFG_PRERELEASE_VERSION: &'static str = ".1";
pub const CFG_PRERELEASE_VERSION: &'static str = ".2";

pub struct GitInfo {
inner: Option<Info>,
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,13 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
for verify in self.verifys.borrow().iter() {
debug!("collect_errors: verify={:?}", verify);
let sub = normalize(self.tcx, var_data, verify.region);

// This was an inference variable which didn't get
// constrained, therefore it can be assume to hold.
if let ty::ReEmpty = *sub {
continue;
}

if verify.bound.is_met(region_rels, var_data, sub) {
continue;
}
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_typeck/check/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,13 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
// overloaded lvalue ops, and will be fixed by them in order to get
// the correct region.
let mut source = self.node_ty(expr.id);
if let Some(adjustments) = self.tables.borrow_mut().adjustments.get_mut(&expr.id) {
// Do not mutate adjustments in place, but rather take them,
// and replace them after mutating them, to avoid having the
// tables borrowed during (`deref_mut`) method resolution.
let previous_adjustments = self.tables.borrow_mut().adjustments.remove(&expr.id);
if let Some(mut adjustments) = previous_adjustments {
let pref = LvaluePreference::PreferMutLvalue;
for adjustment in adjustments {
for adjustment in &mut adjustments {
if let Adjust::Deref(Some(ref mut deref)) = adjustment.kind {
if let Some(ok) = self.try_overloaded_deref(expr.span, source, pref) {
let method = self.register_infer_ok_obligations(ok);
Expand All @@ -462,6 +466,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
}
source = adjustment.target;
}
self.tables.borrow_mut().adjustments.insert(expr.id, adjustments);
}

match expr.node {
Expand Down
29 changes: 23 additions & 6 deletions src/libstd/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
use io;
use libc::{self, c_int};
use mem;
use sys::{cvt, cvt_r};
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
use sys::fd::FileDesc;
use sys::{cvt, cvt_r};

////////////////////////////////////////////////////////////////////////////////
// Anonymous pipes
Expand All @@ -21,6 +22,9 @@ use sys::fd::FileDesc;
pub struct AnonPipe(FileDesc);

pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
weak! { fn pipe2(*mut c_int, c_int) -> c_int }
static INVALID: AtomicBool = ATOMIC_BOOL_INIT;

let mut fds = [0; 2];

// Unfortunately the only known way right now to create atomically set the
Expand All @@ -31,13 +35,26 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))
target_os = "openbsd")) &&
!INVALID.load(Ordering::SeqCst)
{
weak! { fn pipe2(*mut c_int, c_int) -> c_int }

if let Some(pipe) = pipe2.get() {
cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) })?;
return Ok((AnonPipe(FileDesc::new(fds[0])),
AnonPipe(FileDesc::new(fds[1]))));
// Note that despite calling a glibc function here we may still
// get ENOSYS. Glibc has `pipe2` since 2.9 and doesn't try to
// emulate on older kernels, so if you happen to be running on
// an older kernel you may see `pipe2` as a symbol but still not
// see the syscall.
match cvt(unsafe { pipe(fds.as_mut_ptr(), libc::O_CLOEXEC) }) {
Ok(_) => {
return Ok((AnonPipe(FileDesc::new(fds[0])),
AnonPipe(FileDesc::new(fds[1]))));
}
Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {
INVALID.store(true, Ordering::SeqCst);
}
Err(e) => return Err(e),
}
}
}
cvt(unsafe { libc::pipe(fds.as_mut_ptr()) })?;
Expand Down
41 changes: 41 additions & 0 deletions src/test/run-pass/issue-42463.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::ops::{Deref, DerefMut};

struct CheckedDeref<T, F> {
value: T,
check: F
}

impl<F: Fn(&T) -> bool, T> Deref for CheckedDeref<T, F> {
type Target = T;
fn deref(&self) -> &T {
assert!((self.check)(&self.value));
&self.value
}
}

impl<F: Fn(&T) -> bool, T> DerefMut for CheckedDeref<T, F> {
fn deref_mut(&mut self) -> &mut T {
assert!((self.check)(&self.value));
&mut self.value
}
}


fn main() {
let mut v = CheckedDeref {
value: vec![0],
check: |v: &Vec<_>| !v.is_empty()
};
v.push(1);
assert_eq!(*v, vec![0, 1]);
}
32 changes: 32 additions & 0 deletions src/test/run-pass/issue-42467.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Foo<T>(T);

struct IntoIter<T>(T);

impl<'a, T: 'a> Iterator for IntoIter<T> {
type Item = ();

fn next(&mut self) -> Option<()> {
None
}
}

impl<T> IntoIterator for Foo<T> {
type Item = ();
type IntoIter = IntoIter<T>;

fn into_iter(self) -> IntoIter<T> {
IntoIter(self.0)
}
}

fn main() {}
2 changes: 1 addition & 1 deletion src/tools/cargo

0 comments on commit a175ee5

Please sign in to comment.