From 58d7340b576668ecd2a9303348e864b070d9c1d0 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 29 Jul 2015 10:17:47 -0700 Subject: [PATCH 1/4] Bump to .4 --- mk/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/main.mk b/mk/main.mk index 6dcb5d9948643..ff2ffb12ed270 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.2.0 # An optional number to put after the label, e.g. '.2' -> '-beta.2' # NB Make sure it starts with a dot to conform to semver pre-release # versions (section 9) -CFG_PRERELEASE_VERSION=.3 +CFG_PRERELEASE_VERSION=.4 # Append a version-dependent hash to each library, so we can install different # versions in the same place From 4fcb19dda999f8e1f97b98e170e87e47425e7dae Mon Sep 17 00:00:00 2001 From: Lee Jeffery Date: Thu, 16 Jul 2015 14:36:05 +0100 Subject: [PATCH 2/4] Fix typo in stability attribute. --- src/libstd/sys/windows/ext/raw.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/windows/ext/raw.rs b/src/libstd/sys/windows/ext/raw.rs index e1796d4b5f073..92d53e2e42884 100644 --- a/src/libstd/sys/windows/ext/raw.rs +++ b/src/libstd/sys/windows/ext/raw.rs @@ -10,7 +10,7 @@ //! Windows-specific primitives -#[stable(feature = "raw_ext", since = "1.1.0")] +#![stable(feature = "raw_ext", since = "1.1.0")] use os::raw::c_void; From e6b2f0cbaf4463f18936621b6e9fb44ecfb9f35f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 28 Jul 2015 21:13:02 -0700 Subject: [PATCH 3/4] std: Fix sub-second Condvar::wait_timeout_ms The API we're calling requires us to pass an absolute point in time as an argument (`pthread_cond_timedwait`) so we call `gettimeofday` ahead of time to then add the specified duration to. Unfortuantely the current "add the duration" logic forgot to take into account the current time's sub-second precision (e.g. the `tv_usec` field was ignored), causing sub-second duration waits to return spuriously. --- src/libstd/sys/unix/condvar.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index c8708190a2e18..beecb445e8d68 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -60,21 +60,22 @@ impl Condvar { let r = ffi::gettimeofday(&mut sys_now, ptr::null_mut()); debug_assert_eq!(r, 0); + let nsec = dur.extra_nanos() as libc::c_long + + (sys_now.tv_usec * 1000) as libc::c_long; + let extra = (nsec / 1_000_000_000) as libc::time_t; + let nsec = nsec % 1_000_000_000; let seconds = dur.secs() as libc::time_t; - let timeout = match sys_now.tv_sec.checked_add(seconds) { - Some(sec) => { - libc::timespec { - tv_sec: sec, - tv_nsec: dur.extra_nanos() as libc::c_long, - } - } - None => { - libc::timespec { - tv_sec: ::max_value(), - tv_nsec: 1_000_000_000 - 1, - } + + let timeout = sys_now.tv_sec.checked_add(extra).and_then(|s| { + s.checked_add(seconds) + }).map(|s| { + libc::timespec { tv_sec: s, tv_nsec: nsec } + }).unwrap_or_else(|| { + libc::timespec { + tv_sec: ::max_value(), + tv_nsec: 1_000_000_000 - 1, } - }; + }); // And wait! let r = ffi::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex), From 6e6d5b1ba036b0867f831ac1d771f9e1f826bb1c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 29 Jul 2015 12:01:09 -0700 Subject: [PATCH 4/4] Feature gate associated type defaults There are multiple issues with them as designed and implemented. cc #27364 Conflicts: src/libsyntax/feature_gate.rs src/test/auxiliary/xcrate_associated_type_defaults.rs --- src/libcore/lib.rs | 1 + src/libsyntax/feature_gate.rs | 7 +++++++ .../xcrate_associated_type_defaults.rs | 18 ++++++++++++++++++ .../feature-gate-assoc-type-defaults.rs | 15 +++++++++++++++ src/test/run-pass/default-associated-types.rs | 2 ++ src/test/run-pass/issue-25339.rs | 2 ++ 6 files changed, 45 insertions(+) create mode 100644 src/test/auxiliary/xcrate_associated_type_defaults.rs create mode 100644 src/test/compile-fail/feature-gate-assoc-type-defaults.rs diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 030d2a33f8f65..392eaf7801a91 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -65,6 +65,7 @@ #![allow(raw_pointer_derive)] #![deny(missing_docs)] +#![feature(associated_type_defaults)] #![feature(intrinsics)] #![feature(lang_items)] #![feature(on_unimplemented)] diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3d0cf9236c25c..e695be48d38be 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -155,6 +155,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // Allows the definition of `const fn` functions. ("const_fn", "1.2.0", Active), + + // Allows associated type defaults + ("associated_type_defaults", "1.2.0", Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -686,6 +689,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { self.gate_feature("const_fn", ti.span, "const fn is unstable"); } } + ast::TypeTraitItem(_, Some(_)) => { + self.gate_feature("associated_type_defaults", ti.span, + "associated type defaults are unstable"); + } _ => {} } visit::walk_trait_item(self, ti); diff --git a/src/test/auxiliary/xcrate_associated_type_defaults.rs b/src/test/auxiliary/xcrate_associated_type_defaults.rs new file mode 100644 index 0000000000000..43852a4e793f3 --- /dev/null +++ b/src/test/auxiliary/xcrate_associated_type_defaults.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. + +#![feature(associated_type_defaults)] + +pub trait Foo { + type Input = usize; + fn bar(&self, _: Self::Input) {} +} + +impl Foo for () {} diff --git a/src/test/compile-fail/feature-gate-assoc-type-defaults.rs b/src/test/compile-fail/feature-gate-assoc-type-defaults.rs new file mode 100644 index 0000000000000..fc4871a712dff --- /dev/null +++ b/src/test/compile-fail/feature-gate-assoc-type-defaults.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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. + +trait Foo { + type Bar = u8; //~ ERROR associated type defaults are unstable +} + +fn main() {} diff --git a/src/test/run-pass/default-associated-types.rs b/src/test/run-pass/default-associated-types.rs index b3def429b9b8c..3e6c72c993a0a 100644 --- a/src/test/run-pass/default-associated-types.rs +++ b/src/test/run-pass/default-associated-types.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(associated_type_defaults)] + trait Foo { type Out = T; fn foo(&self) -> Self::Out; diff --git a/src/test/run-pass/issue-25339.rs b/src/test/run-pass/issue-25339.rs index af172000fdb1a..381df7c5d5938 100644 --- a/src/test/run-pass/issue-25339.rs +++ b/src/test/run-pass/issue-25339.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(associated_type_defaults)] + use std::marker::PhantomData; pub trait Routing {