From ee469058e1676bcf5d36c8754aa48f83733f9bdb Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Thu, 9 Jun 2016 23:03:14 +0100 Subject: [PATCH 1/7] Implement Binary, Octal, LowerHex and UpperHex for Wrapping --- src/libcore/num/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 883e9206dde1d..06398fc094e85 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -66,6 +66,34 @@ impl fmt::Display for Wrapping { } } +#[stable(feature = "wrapping_fmt", since = "1.11.0")] +impl fmt::Binary for Wrapping { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +#[stable(feature = "wrapping_fmt", since = "1.11.0")] +impl fmt::Octal for Wrapping { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +#[stable(feature = "wrapping_fmt", since = "1.11.0")] +impl fmt::LowerHex for Wrapping { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +#[stable(feature = "wrapping_fmt", since = "1.11.0")] +impl fmt::UpperHex for Wrapping { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + mod wrapping; // All these modules are technically private and only exposed for libcoretest: From 3c778953d559ca420449421f9415589ef2976a18 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 20 Jun 2016 10:02:48 -0700 Subject: [PATCH 2/7] configure: Remove clang version checks We no C++ and an incredibly small amount of C code as part of the build, so there's not really much need for us to strictly check the version of compilers as we're not really stressing anything. LLVM is a pretty huge chunk of C++ but it should be the responsibility of LLVM to ensure that it can build with a particular clang/gcc version, not ours (as this logic changes over time). These version checks seem to basically just by us a regular stream of PRs every six weeks or so when a new version is releases, so they're not really buying us much. As a result, remove them and we can add then back piecemeal perhaps as a blacklist if we really need to. --- configure | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/configure b/configure index b2334740f937e..c08e8d39154dc 100755 --- a/configure +++ b/configure @@ -1040,37 +1040,6 @@ if [ -n "$CFG_ENABLE_CLANG" ] then case "$CC" in (''|*clang) - CFG_CLANG_REPORTED_VERSION=$($CFG_CC --version | grep version) - - if echo $CFG_CLANG_REPORTED_VERSION | grep -q "(based on LLVM "; then - CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*(based on LLVM \(.*\))/\1/') - elif echo $CFG_CLANG_REPORTED_VERSION | grep -q "Apple LLVM"; then - CFG_OSX_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/') - else - CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/') - fi - - if [ -n "$CFG_OSX_CLANG_VERSION" ] - then - case $CFG_OSX_CLANG_VERSION in - (7.0* | 7.1* | 7.2* | 7.3* | 8.0*) - step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION" - ;; - (*) - err "bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION, need >=7.0" - ;; - esac - else - case $CFG_CLANG_VERSION in - (3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8* | 3.9*) - step_msg "found ok version of CLANG: $CFG_CLANG_VERSION" - ;; - (*) - err "bad CLANG version: $CFG_CLANG_VERSION, need >=3.0svn" - ;; - esac - fi - if [ -z "$CC" ] then CFG_CC="clang" From 03d86ba2f55f74d72a22b3a67a50bb586fcd1930 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 19 Jun 2016 13:50:37 -0400 Subject: [PATCH 3/7] Add regression test for #23281 Closes #23281 --- src/test/compile-fail/issue-23281.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/compile-fail/issue-23281.rs diff --git a/src/test/compile-fail/issue-23281.rs b/src/test/compile-fail/issue-23281.rs new file mode 100644 index 0000000000000..5feeb36b1e4d4 --- /dev/null +++ b/src/test/compile-fail/issue-23281.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +// ignore-tidy-linelength + +pub struct Struct; + +impl Struct { + pub fn function(funs: Vec ()>) {} + //~^ ERROR the trait bound `std::ops::Fn() + 'static: std::marker::Sized` is not satisfied +} + +fn main() {} From ebfdd110c3ae32e91627f1d75bf089560bf98c9b Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sat, 18 Jun 2016 18:41:13 +0100 Subject: [PATCH 4/7] rustdoc: Fix a couple of issues with src links to external crates - src links/redirects to extern fn from another crate had an extra '/'. - src links to `pub use` of a crate module had an extra '/'. - src links to renamed reexports from another crate used the new name for the link but should use the original name. --- src/librustdoc/clean/inline.rs | 10 +++++++-- src/librustdoc/html/render.rs | 15 ++++++++----- src/test/rustdoc/auxiliary/issue-34274.rs | 13 +++++++++++ .../rustdoc/auxiliary/src-links-external.rs | 11 ++++++++++ src/test/rustdoc/issue-34274.rs | 20 +++++++++++++++++ src/test/rustdoc/src-links-external.rs | 22 +++++++++++++++++++ 6 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 src/test/rustdoc/auxiliary/issue-34274.rs create mode 100644 src/test/rustdoc/auxiliary/src-links-external.rs create mode 100644 src/test/rustdoc/issue-34274.rs create mode 100644 src/test/rustdoc/src-links-external.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e49b96cbfd02e..8ffbd6be41878 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -143,8 +143,14 @@ pub fn load_attrs<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) { if let Some(tcx) = cx.tcx_opt() { let crate_name = tcx.sess.cstore.crate_name(did.krate).to_string(); - let relative = tcx.def_path(did).data.into_iter().map(|elem| { - elem.data.to_string() + let relative = tcx.def_path(did).data.into_iter().filter_map(|elem| { + // extern blocks have an empty name + let s = elem.data.to_string(); + if !s.is_empty() { + Some(s) + } else { + None + } }); let fqn = once(crate_name).chain(relative).collect(); cx.renderinfo.borrow_mut().external_paths.insert(did, (fqn, kind)); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 493d3d6abc9f9..0d390a87d2050 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1519,20 +1519,23 @@ impl<'a> Item<'a> { // located, then we return `None`. } else { let cache = cache(); - let path = match cache.external_paths.get(&self.item.def_id) { + let external_path = match cache.external_paths.get(&self.item.def_id) { Some(path) => path, None => return None, }; - let root = match cache.extern_locations.get(&self.item.def_id.krate) { + let mut path = match cache.extern_locations.get(&self.item.def_id.krate) { Some(&(_, Remote(ref s))) => s.to_string(), Some(&(_, Local)) => self.cx.root_path.clone(), Some(&(_, Unknown)) => return None, None => return None, }; - Some(format!("{root}{path}/{file}?gotosrc={goto}", - root = root, - path = path[..path.len() - 1].join("/"), - file = item_path(shortty(self.item), self.item.name.as_ref().unwrap()), + for item in &external_path[..external_path.len() - 1] { + path.push_str(item); + path.push_str("/"); + } + Some(format!("{path}{file}?gotosrc={goto}", + path = path, + file = item_path(shortty(self.item), external_path.last().unwrap()), goto = self.item.def_id.index.as_usize())) } } diff --git a/src/test/rustdoc/auxiliary/issue-34274.rs b/src/test/rustdoc/auxiliary/issue-34274.rs new file mode 100644 index 0000000000000..72026b6085604 --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-34274.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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. + +extern { + pub fn extern_c_fn(); +} diff --git a/src/test/rustdoc/auxiliary/src-links-external.rs b/src/test/rustdoc/auxiliary/src-links-external.rs new file mode 100644 index 0000000000000..94b7278e9904b --- /dev/null +++ b/src/test/rustdoc/auxiliary/src-links-external.rs @@ -0,0 +1,11 @@ +// Copyright 2016 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. + +pub struct Foo; diff --git a/src/test/rustdoc/issue-34274.rs b/src/test/rustdoc/issue-34274.rs new file mode 100644 index 0000000000000..971c89b1619ed --- /dev/null +++ b/src/test/rustdoc/issue-34274.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +// aux-build:issue-34274.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name = "foo"] + +extern crate issue_34274; + +// @has foo/fn.extern_c_fn.html '//a/@href' '../issue_34274/fn.extern_c_fn.html?gotosrc=' +pub use issue_34274::extern_c_fn; diff --git a/src/test/rustdoc/src-links-external.rs b/src/test/rustdoc/src-links-external.rs new file mode 100644 index 0000000000000..e9db4f519ed97 --- /dev/null +++ b/src/test/rustdoc/src-links-external.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +// aux-build:src-links-external.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name = "foo"] + +extern crate src_links_external; + +// @has foo/bar/index.html '//a/@href' '../src_links_external/index.html?gotosrc=' +pub use src_links_external as bar; + +// @has foo/bar/struct.Foo.html '//a/@href' '../src_links_external/struct.Foo.html?gotosrc=' From 0de72bba3634efb9d7b637b274c8f2ec1a335bf4 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 21 Jun 2016 10:08:31 +0200 Subject: [PATCH 5/7] don't warn on casting byte strs to slices --- src/librustc_const_eval/eval.rs | 1 + src/test/run-pass/const-byte-str-cast.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/run-pass/const-byte-str-cast.rs diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 7551bc5c234ef..34dce44004823 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -1116,6 +1116,7 @@ fn cast_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstVal, ty: ty::Ty) ty::TyRawPtr(_) => { Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr")) }, + ty::TyRef(..) => Err(ErrKind::UnimplementedConstVal("casting a bytestr to slice")), _ => Err(CannotCast), }, _ => Err(CannotCast), diff --git a/src/test/run-pass/const-byte-str-cast.rs b/src/test/run-pass/const-byte-str-cast.rs new file mode 100644 index 0000000000000..2f265b9112b98 --- /dev/null +++ b/src/test/run-pass/const-byte-str-cast.rs @@ -0,0 +1,15 @@ +// Copyright 2013 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. + +#[deny(warnings)] + +pub fn main() { + let _ = b"x" as &[u8]; +} From c02414e9bd4326d3db8d54a1cf4707089737b414 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 19 Jun 2016 15:58:40 +0200 Subject: [PATCH 6/7] Fix overflow error in thread::sleep --- src/libstd/sys/unix/thread.rs | 21 +++++++++++++++------ src/test/run-pass/sleep.rs | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 src/test/run-pass/sleep.rs diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index cb34d1a5fbcd1..371319a93d2f2 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -125,16 +125,25 @@ impl Thread { } pub fn sleep(dur: Duration) { - let mut ts = libc::timespec { - tv_sec: dur.as_secs() as libc::time_t, - tv_nsec: dur.subsec_nanos() as libc::c_long, - }; + let mut secs = dur.as_secs(); + let mut nsecs = dur.subsec_nanos() as libc::c_long; // If we're awoken with a signal then the return value will be -1 and // nanosleep will fill in `ts` with the remaining time. unsafe { - while libc::nanosleep(&ts, &mut ts) == -1 { - assert_eq!(os::errno(), libc::EINTR); + while secs > 0 || nsecs > 0 { + let mut ts = libc::timespec { + tv_sec: cmp::min(libc::time_t::max_value() as u64, secs) as libc::time_t, + tv_nsec: nsecs, + }; + secs -= ts.tv_sec as u64; + if libc::nanosleep(&ts, &mut ts) == -1 { + assert_eq!(os::errno(), libc::EINTR); + secs += ts.tv_sec as u64; + nsecs = ts.tv_nsec; + } else { + nsecs = 0; + } } } } diff --git a/src/test/run-pass/sleep.rs b/src/test/run-pass/sleep.rs new file mode 100644 index 0000000000000..8b06b02f3cba5 --- /dev/null +++ b/src/test/run-pass/sleep.rs @@ -0,0 +1,25 @@ +// Copyright 2016 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::thread::{self, sleep}; +use std::time::Duration; +use std::sync::{Arc, Mutex}; +use std::u64; + +fn main() { + let finished = Arc::new(Mutex::new(false)); + let t_finished = finished.clone(); + thread::spawn(move || { + sleep(Duration::new(u64::MAX, 0)); + *t_finished.lock().unwrap() = true; + }); + sleep(Duration::from_millis(100)); + assert_eq!(*finished.lock().unwrap(), false); +} From 1cc54d03270740d797c498cd29536565602dc2dd Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Tue, 21 Jun 2016 23:30:15 +0100 Subject: [PATCH 7/7] Mark concat_idents! unstable This is mostly just a documentation fix as I don't think stability attributes have any effect on macros. --- src/libstd/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index d69789cedaf2c..26cf8a3199d1b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -276,7 +276,7 @@ pub mod builtin { /// // fn concat_idents!(new, fun, name) { } // not usable in this way! /// # } /// ``` - #[stable(feature = "rust1", since = "1.0.0")] + #[unstable(feature = "concat_idents", issue = "29599")] #[macro_export] macro_rules! concat_idents { ($($e:ident),*) => ({ /* compiler built-in */ })