Skip to content

Commit cfc9109

Browse files
committed
Auto merge of rust-lang#21745 - chris-morgan:add-missing-unstable-attributes, r=huonw
I’d kind of like to be able to use HashState in AnyMap, which I can’t do without a stability attribute on it. While I was at it I looked around and found a few more missing.
2 parents 336c8d2 + 9836742 commit cfc9109

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

src/libstd/collections/hash/map.rs

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use super::table::BucketState::{
4646
use super::state::HashState;
4747

4848
const INITIAL_LOG2_CAP: uint = 5;
49+
#[unstable(feature = "std_misc")]
4950
pub const INITIAL_CAPACITY: uint = 1 << INITIAL_LOG2_CAP; // 2^5
5051

5152
/// The default behavior of HashMap implements a load factor of 90.9%.
@@ -1622,6 +1623,8 @@ impl Default for RandomState {
16221623
/// typically declare an ability to explicitly hash into this particular type,
16231624
/// but rather in a `H: hash::Writer` type parameter.
16241625
#[allow(missing_copy_implementations)]
1626+
#[unstable(feature = "std_misc",
1627+
reason = "hashing an hash maps may be altered")]
16251628
pub struct Hasher { inner: SipHasher }
16261629

16271630
impl hash::Writer for Hasher {

src/libstd/collections/hash/state.rs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use hash;
2424
/// algorithm can implement the `Default` trait and create hash maps with the
2525
/// `DefaultState` structure. This state is 0-sized and will simply delegate
2626
/// to `Default` when asked to create a hasher.
27+
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
2728
pub trait HashState {
2829
type Hasher: hash::Hasher;
2930

@@ -35,6 +36,7 @@ pub trait HashState {
3536
/// default trait.
3637
///
3738
/// This struct has is 0-sized and does not need construction.
39+
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
3840
pub struct DefaultState<H>;
3941

4042
impl<H: Default + hash::Hasher> HashState for DefaultState<H> {

src/libstd/time/duration.rs

+31
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,22 @@ macro_rules! try_opt {
4545

4646
/// ISO 8601 time duration with nanosecond precision.
4747
/// This also allows for the negative duration; see individual methods for details.
48+
#[unstable(feature = "std_misc")]
4849
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
4950
pub struct Duration {
5051
secs: i64,
5152
nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC
5253
}
5354

5455
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
56+
#[unstable(feature = "std_misc")]
5557
pub const MIN: Duration = Duration {
5658
secs: i64::MIN / MILLIS_PER_SEC - 1,
5759
nanos: NANOS_PER_SEC + (i64::MIN % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
5860
};
5961

6062
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
63+
#[unstable(feature = "std_misc")]
6164
pub const MAX: Duration = Duration {
6265
secs: i64::MAX / MILLIS_PER_SEC,
6366
nanos: (i64::MAX % MILLIS_PER_SEC) as i32 * NANOS_PER_MILLI
@@ -68,6 +71,7 @@ impl Duration {
6871
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
6972
/// Panics when the duration is out of bounds.
7073
#[inline]
74+
#[unstable(feature = "std_misc")]
7175
pub fn weeks(weeks: i64) -> Duration {
7276
let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
7377
Duration::seconds(secs)
@@ -77,6 +81,7 @@ impl Duration {
7781
/// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
7882
/// Panics when the duration is out of bounds.
7983
#[inline]
84+
#[unstable(feature = "std_misc")]
8085
pub fn days(days: i64) -> Duration {
8186
let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
8287
Duration::seconds(secs)
@@ -86,6 +91,7 @@ impl Duration {
8691
/// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
8792
/// Panics when the duration is out of bounds.
8893
#[inline]
94+
#[unstable(feature = "std_misc")]
8995
pub fn hours(hours: i64) -> Duration {
9096
let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
9197
Duration::seconds(secs)
@@ -95,6 +101,7 @@ impl Duration {
95101
/// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
96102
/// Panics when the duration is out of bounds.
97103
#[inline]
104+
#[unstable(feature = "std_misc")]
98105
pub fn minutes(minutes: i64) -> Duration {
99106
let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
100107
Duration::seconds(secs)
@@ -104,6 +111,7 @@ impl Duration {
104111
/// Panics when the duration is more than `i64::MAX` milliseconds
105112
/// or less than `i64::MIN` milliseconds.
106113
#[inline]
114+
#[unstable(feature = "std_misc")]
107115
pub fn seconds(seconds: i64) -> Duration {
108116
let d = Duration { secs: seconds, nanos: 0 };
109117
if d < MIN || d > MAX {
@@ -114,6 +122,7 @@ impl Duration {
114122

115123
/// Makes a new `Duration` with given number of milliseconds.
116124
#[inline]
125+
#[unstable(feature = "std_misc")]
117126
pub fn milliseconds(milliseconds: i64) -> Duration {
118127
let (secs, millis) = div_mod_floor_64(milliseconds, MILLIS_PER_SEC);
119128
let nanos = millis as i32 * NANOS_PER_MILLI;
@@ -122,6 +131,7 @@ impl Duration {
122131

123132
/// Makes a new `Duration` with given number of microseconds.
124133
#[inline]
134+
#[unstable(feature = "std_misc")]
125135
pub fn microseconds(microseconds: i64) -> Duration {
126136
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
127137
let nanos = micros as i32 * NANOS_PER_MICRO;
@@ -130,13 +140,15 @@ impl Duration {
130140

131141
/// Makes a new `Duration` with given number of nanoseconds.
132142
#[inline]
143+
#[unstable(feature = "std_misc")]
133144
pub fn nanoseconds(nanos: i64) -> Duration {
134145
let (secs, nanos) = div_mod_floor_64(nanos, NANOS_PER_SEC as i64);
135146
Duration { secs: secs, nanos: nanos as i32 }
136147
}
137148

138149
/// Runs a closure, returning the duration of time it took to run the
139150
/// closure.
151+
#[unstable(feature = "std_misc")]
140152
pub fn span<F>(f: F) -> Duration where F: FnOnce() {
141153
let before = super::precise_time_ns();
142154
f();
@@ -145,28 +157,33 @@ impl Duration {
145157

146158
/// Returns the total number of whole weeks in the duration.
147159
#[inline]
160+
#[unstable(feature = "std_misc")]
148161
pub fn num_weeks(&self) -> i64 {
149162
self.num_days() / 7
150163
}
151164

152165
/// Returns the total number of whole days in the duration.
166+
#[unstable(feature = "std_misc")]
153167
pub fn num_days(&self) -> i64 {
154168
self.num_seconds() / SECS_PER_DAY
155169
}
156170

157171
/// Returns the total number of whole hours in the duration.
158172
#[inline]
173+
#[unstable(feature = "std_misc")]
159174
pub fn num_hours(&self) -> i64 {
160175
self.num_seconds() / SECS_PER_HOUR
161176
}
162177

163178
/// Returns the total number of whole minutes in the duration.
164179
#[inline]
180+
#[unstable(feature = "std_misc")]
165181
pub fn num_minutes(&self) -> i64 {
166182
self.num_seconds() / SECS_PER_MINUTE
167183
}
168184

169185
/// Returns the total number of whole seconds in the duration.
186+
#[unstable(feature = "std_misc")]
170187
pub fn num_seconds(&self) -> i64 {
171188
// If secs is negative, nanos should be subtracted from the duration.
172189
if self.secs < 0 && self.nanos > 0 {
@@ -188,6 +205,7 @@ impl Duration {
188205
}
189206

190207
/// Returns the total number of whole milliseconds in the duration,
208+
#[unstable(feature = "std_misc")]
191209
pub fn num_milliseconds(&self) -> i64 {
192210
// A proper Duration will not overflow, because MIN and MAX are defined
193211
// such that the range is exactly i64 milliseconds.
@@ -198,6 +216,7 @@ impl Duration {
198216

199217
/// Returns the total number of whole microseconds in the duration,
200218
/// or `None` on overflow (exceeding 2^63 microseconds in either direction).
219+
#[unstable(feature = "std_misc")]
201220
pub fn num_microseconds(&self) -> Option<i64> {
202221
let secs_part = try_opt!(self.num_seconds().checked_mul(MICROS_PER_SEC));
203222
let nanos_part = self.nanos_mod_sec() / NANOS_PER_MICRO;
@@ -206,13 +225,15 @@ impl Duration {
206225

207226
/// Returns the total number of whole nanoseconds in the duration,
208227
/// or `None` on overflow (exceeding 2^63 nanoseconds in either direction).
228+
#[unstable(feature = "std_misc")]
209229
pub fn num_nanoseconds(&self) -> Option<i64> {
210230
let secs_part = try_opt!(self.num_seconds().checked_mul(NANOS_PER_SEC as i64));
211231
let nanos_part = self.nanos_mod_sec();
212232
secs_part.checked_add(nanos_part as i64)
213233
}
214234

215235
/// Add two durations, returning `None` if overflow occured.
236+
#[unstable(feature = "std_misc")]
216237
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration> {
217238
let mut secs = try_opt!(self.secs.checked_add(rhs.secs));
218239
let mut nanos = self.nanos + rhs.nanos;
@@ -227,6 +248,7 @@ impl Duration {
227248
}
228249

229250
/// Subtract two durations, returning `None` if overflow occured.
251+
#[unstable(feature = "std_misc")]
230252
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration> {
231253
let mut secs = try_opt!(self.secs.checked_sub(rhs.secs));
232254
let mut nanos = self.nanos - rhs.nanos;
@@ -242,25 +264,30 @@ impl Duration {
242264

243265
/// The minimum possible `Duration`: `i64::MIN` milliseconds.
244266
#[inline]
267+
#[unstable(feature = "std_misc")]
245268
pub fn min_value() -> Duration { MIN }
246269

247270
/// The maximum possible `Duration`: `i64::MAX` milliseconds.
248271
#[inline]
272+
#[unstable(feature = "std_misc")]
249273
pub fn max_value() -> Duration { MAX }
250274

251275
/// A duration where the stored seconds and nanoseconds are equal to zero.
252276
#[inline]
277+
#[unstable(feature = "std_misc")]
253278
pub fn zero() -> Duration {
254279
Duration { secs: 0, nanos: 0 }
255280
}
256281

257282
/// Returns `true` if the duration equals `Duration::zero()`.
258283
#[inline]
284+
#[unstable(feature = "std_misc")]
259285
pub fn is_zero(&self) -> bool {
260286
self.secs == 0 && self.nanos == 0
261287
}
262288
}
263289

290+
#[unstable(feature = "std_misc")]
264291
impl Neg for Duration {
265292
type Output = Duration;
266293

@@ -274,6 +301,7 @@ impl Neg for Duration {
274301
}
275302
}
276303

304+
#[unstable(feature = "std_misc")]
277305
impl Add for Duration {
278306
type Output = Duration;
279307

@@ -288,6 +316,7 @@ impl Add for Duration {
288316
}
289317
}
290318

319+
#[unstable(feature = "std_misc")]
291320
impl Sub for Duration {
292321
type Output = Duration;
293322

@@ -302,6 +331,7 @@ impl Sub for Duration {
302331
}
303332
}
304333

334+
#[unstable(feature = "std_misc")]
305335
impl Mul<i32> for Duration {
306336
type Output = Duration;
307337

@@ -314,6 +344,7 @@ impl Mul<i32> for Duration {
314344
}
315345
}
316346

347+
#[unstable(feature = "std_misc")]
317348
impl Div<i32> for Duration {
318349
type Output = Duration;
319350

src/libstd/time/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Temporal quantification.
1212
13+
#![unstable(feature = "std_misc")]
14+
1315
use sys::time::SteadyTime;
1416

1517
pub use self::duration::Duration;

0 commit comments

Comments
 (0)