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

Beta next #42609

Merged
merged 7 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
20 changes: 11 additions & 9 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,20 @@ pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMet
return r;
}

// The third parameter is for an env vars, used to set up the path for MSVC
// to find its DLLs
// The third parameter is for env vars, used on windows to set up the
// path for MSVC to find its DLLs, and gcc to find its bundled
// toolchain
pub fn get_linker(sess: &Session) -> (String, Command, Vec<(OsString, OsString)>) {
let envs = vec![("PATH".into(), command_path(sess))];

if let Some(ref linker) = sess.opts.cg.linker {
(linker.clone(), Command::new(linker), vec![])
(linker.clone(), Command::new(linker), envs)
} else if sess.target.target.options.is_like_msvc {
let (cmd, envs) = msvc_link_exe_cmd(sess);
("link.exe".to_string(), cmd, envs)
} else {
(sess.target.target.options.linker.clone(),
Command::new(&sess.target.target.options.linker), vec![])
let linker = &sess.target.target.options.linker;
(linker.clone(), Command::new(&linker), envs)
}
}

Expand Down Expand Up @@ -182,15 +185,14 @@ pub fn get_ar_prog(sess: &Session) -> String {
})
}

fn command_path(sess: &Session, extra: Option<PathBuf>) -> OsString {
fn command_path(sess: &Session) -> OsString {
// The compiler's sysroot often has some bundled tools, so add it to the
// PATH for the child.
let mut new_path = sess.host_filesearch(PathKind::All)
.get_tools_search_paths();
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
new_path.extend(extra);
env::join_paths(new_path).unwrap()
}

Expand Down Expand Up @@ -451,7 +453,7 @@ fn archive_config<'a>(sess: &'a Session,
src: input.map(|p| p.to_path_buf()),
lib_search_paths: archive_search_paths(sess),
ar_prog: get_ar_prog(sess),
command_path: command_path(sess, None),
command_path: command_path(sess),
}
}

Expand Down Expand Up @@ -727,7 +729,7 @@ fn link_natively(sess: &Session,

// The invocations of cc share some flags across platforms
let (pname, mut cmd, envs) = get_linker(sess);
// This will set PATH on MSVC
// This will set PATH on windows
cmd.envs(envs);

let root = sess.target_filesearch(PathKind::Native).get_lib_path();
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