From 76421c0a0b469e8fffd6b6cf9d8e07f9f27adee5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Jun 2017 18:31:35 -0700 Subject: [PATCH 1/7] std: Handle ENOSYS when calling `pipe2` Should help fix an accidental regression from #39386. --- src/libstd/sys/unix/pipe.rs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index 706256ff10ec9..ca5ef4bcfc5f4 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -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 @@ -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 @@ -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()) })?; From 18a556cd9240ebd31ca3935df2ea8be42e00cd87 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 7 Jun 2017 21:42:17 +0200 Subject: [PATCH 2/7] update git2 Fixes build with libressl Signed-off-by: Marc-Antoine Perennou --- src/Cargo.lock | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d72ffa14a2a24..8bf4b6ad3e0c7 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -103,6 +103,11 @@ name = "bitflags" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bootstrap" version = "0.0.0" @@ -160,14 +165,14 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -197,7 +202,7 @@ dependencies = [ "cargo 0.20.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -466,12 +471,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "git2" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.12 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -483,7 +488,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -602,7 +607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1994,6 +1999,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" +"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" "checksum cargo 0.20.0 (git+https://github.com/rust-lang/cargo)" = "" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" @@ -2018,7 +2024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)" = "5f837c392f2ea61cb1576eac188653df828c861b7137d74ea4a5caa89621f9e6" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" -"checksum git2 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9de9df4358c17e448a778d90cd0272e1dab5eae30244502333fa2001c4e24357" +"checksum git2 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa01936ac96555c083c0e8553f672616274408d9d3fc5b8696603fbf63ff43ee" "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" @@ -2030,7 +2036,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum languageserver-types 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97c2985bfcbbcb0189cfa25e1c10c1ac7111df2b6214b652c690127aefdf4e5b" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502" -"checksum libgit2-sys 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d9dc31ee90fb179b706d35fb672e91d0b74e950d7fb4ea7eae3c0f5ecbf2d3d3" +"checksum libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "df18a822100352d9863b302faf6f8f25c0e77f0e60feb40e5dbe1238b7f13b1d" "checksum libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0db4ec23611747ef772db1c4d650f8bd762f07b461727ec998f953c614024b75" "checksum libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e5ee912a45d686d393d5ac87fac15ba0ba18daae14e8e7543c63ebf7fb7e970c" "checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" From c0080598f96467ba7f18662afae8641ad4faff40 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 6 Jun 2017 19:50:01 +0300 Subject: [PATCH 3/7] rustc: T: 'empty always holds forall T. --- src/librustc/infer/region_inference/mod.rs | 7 +++++ src/test/run-pass/issue-42467.rs | 32 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/run-pass/issue-42467.rs diff --git a/src/librustc/infer/region_inference/mod.rs b/src/librustc/infer/region_inference/mod.rs index acc1a397b4560..c1adba5d84f58 100644 --- a/src/librustc/infer/region_inference/mod.rs +++ b/src/librustc/infer/region_inference/mod.rs @@ -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; } diff --git a/src/test/run-pass/issue-42467.rs b/src/test/run-pass/issue-42467.rs new file mode 100644 index 0000000000000..1b2ee959b2def --- /dev/null +++ b/src/test/run-pass/issue-42467.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo(T); + +struct IntoIter(T); + +impl<'a, T: 'a> Iterator for IntoIter { + type Item = (); + + fn next(&mut self) -> Option<()> { + None + } +} + +impl IntoIterator for Foo { + type Item = (); + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter(self.0) + } +} + +fn main() {} From b28867f5e34c80a632aa23bcc2c6686e51a9e43d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 5 Jun 2017 19:07:43 -0700 Subject: [PATCH 4/7] Fix setting PATH during linkage on windows-gnu --- src/librustc_trans/back/link.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index ee92a4b4a2dfe..e57cbb1c91013 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -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) } } @@ -182,7 +185,7 @@ pub fn get_ar_prog(sess: &Session) -> String { }) } -fn command_path(sess: &Session, extra: Option) -> 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) @@ -190,7 +193,6 @@ fn command_path(sess: &Session, extra: Option) -> OsString { 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() } @@ -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), } } @@ -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(); From c66bd6f67df5897da458b42fd3310240e8c44fb6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 6 Jun 2017 18:50:21 +0300 Subject: [PATCH 5/7] rustc_typeck: do not overlap a borrow of TypeckTables with method lookup. --- src/librustc_typeck/check/method/confirm.rs | 9 ++++- src/test/run-pass/issue-42463.rs | 41 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-42463.rs diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index c8815f3df5aa2..36bd665738951 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -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); @@ -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 { diff --git a/src/test/run-pass/issue-42463.rs b/src/test/run-pass/issue-42463.rs new file mode 100644 index 0000000000000..7182fc213f74a --- /dev/null +++ b/src/test/run-pass/issue-42463.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::{Deref, DerefMut}; + +struct CheckedDeref { + value: T, + check: F +} + +impl bool, T> Deref for CheckedDeref { + type Target = T; + fn deref(&self) -> &T { + assert!((self.check)(&self.value)); + &self.value + } +} + +impl bool, T> DerefMut for CheckedDeref { + 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]); +} From 242ab0e8a005c8a22801a5bd1136e0de2a9fe243 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 13 Jun 2017 17:03:12 +0000 Subject: [PATCH 6/7] Bump beta prerelease version --- src/bootstrap/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 1b9536fba357a..0a26c94b8b97a 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -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, From 3a2f62d40de6b2f76020f4cc9a506bc890fa9463 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 14 Jun 2017 19:30:02 -0700 Subject: [PATCH 7/7] Update cargo submodule Pulls in two beta fixes for cargo: * rust-lang/cargo#4169 * rust-lang/cargo#4170 --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index bbfe9b3a9d64a..c9bdd3e9bd77d 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit bbfe9b3a9d64aa8698b18cbb3803b3fa00ee3f44 +Subproject commit c9bdd3e9bd77debf4715a074ee90d19f5551000e