Skip to content

Commit 7936242

Browse files
committed
auto merge of #18999 : aturon/rust/stab-floats, r=alexcrichton,alexcrichton
This commit adds stability markers for the APIs that have recently been aligned with [numerics reform](rust-lang/rfcs#369). For APIs that were changed as part of that reform, `#[unstable]` is used to reflect the recency, but the APIs will become `#[stable]` in a follow-up pass. In addition, a few aspects of the APIs not explicitly covered by the RFC are marked here -- in particular, constants for floats. This commit does not mark the `uint` or `int` modules as `#[stable]`, given the ongoing debate out the names and roles of these types. Due to some deprecation (see the RFC for details), this is a: [breaking-change] r? @alexcrichton cc @bjz
2 parents 399ff25 + e7fab22 commit 7936242

23 files changed

+131
-41
lines changed

src/libcore/num/f32.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,57 @@
1414
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
1515
#![allow(overflowing_literals)]
1616

17+
#![stable]
18+
1719
use intrinsics;
1820
use mem;
1921
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
2022
use num::from_str_radix;
2123
use option::Option;
2224

25+
#[stable]
2326
pub const RADIX: uint = 2u;
2427

28+
#[stable]
2529
pub const MANTISSA_DIGITS: uint = 24u;
30+
#[stable]
2631
pub const DIGITS: uint = 6u;
2732

33+
#[stable]
2834
pub const EPSILON: f32 = 1.19209290e-07_f32;
2935

3036
/// Smallest finite f32 value
37+
#[stable]
3138
pub const MIN_VALUE: f32 = -3.40282347e+38_f32;
3239
/// Smallest positive, normalized f32 value
40+
#[stable]
3341
pub const MIN_POS_VALUE: f32 = 1.17549435e-38_f32;
3442
/// Largest finite f32 value
43+
#[stable]
3544
pub const MAX_VALUE: f32 = 3.40282347e+38_f32;
3645

46+
#[stable]
3747
pub const MIN_EXP: int = -125;
48+
#[stable]
3849
pub const MAX_EXP: int = 128;
3950

51+
#[stable]
4052
pub const MIN_10_EXP: int = -37;
53+
#[stable]
4154
pub const MAX_10_EXP: int = 38;
4255

56+
#[stable]
4357
pub const NAN: f32 = 0.0_f32/0.0_f32;
58+
#[stable]
4459
pub const INFINITY: f32 = 1.0_f32/0.0_f32;
60+
#[stable]
4561
pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32;
4662

4763
/// Various useful constants.
64+
#[unstable = "naming scheme needs to be revisited"]
4865
pub mod consts {
4966
// FIXME: replace with mathematical constants from cmath.
5067

51-
// FIXME(#5527): These constants should be deprecated once associated
52-
// constants are implemented in favour of referencing the respective members
53-
// of `Float`.
54-
5568
/// Archimedes' constant
5669
pub const PI: f32 = 3.14159265358979323846264338327950288_f32;
5770

@@ -104,6 +117,7 @@ pub mod consts {
104117
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
105118
}
106119

120+
#[unstable = "trait is unstable"]
107121
impl Float for f32 {
108122
#[inline]
109123
fn nan() -> f32 { NAN }
@@ -415,12 +429,12 @@ impl Float for f32 {
415429

416430
/// Converts to degrees, assuming the number is in radians.
417431
#[inline]
418-
fn to_degrees(self) -> f32 { self * (180.0f32 / Float::pi()) }
432+
fn to_degrees(self) -> f32 { self * (180.0f32 / consts::PI) }
419433

420434
/// Converts to radians, assuming the number is in degrees.
421435
#[inline]
422436
fn to_radians(self) -> f32 {
423-
let value: f32 = Float::pi();
437+
let value: f32 = consts::PI;
424438
self * (value / 180.0f32)
425439
}
426440
}

src/libcore/num/f64.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
1515
#![allow(overflowing_literals)]
1616

17+
#![stable]
18+
1719
use intrinsics;
1820
use mem;
1921
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
@@ -24,33 +26,46 @@ use option::Option;
2426
// constants are implemented in favour of referencing the respective
2527
// members of `Bounded` and `Float`.
2628

29+
#[stable]
2730
pub const RADIX: uint = 2u;
2831

32+
#[stable]
2933
pub const MANTISSA_DIGITS: uint = 53u;
34+
#[stable]
3035
pub const DIGITS: uint = 15u;
3136

37+
#[stable]
3238
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;
3339

3440
/// Smallest finite f64 value
41+
#[stable]
3542
pub const MIN_VALUE: f64 = -1.7976931348623157e+308_f64;
3643
/// Smallest positive, normalized f64 value
44+
#[stable]
3745
pub const MIN_POS_VALUE: f64 = 2.2250738585072014e-308_f64;
3846
/// Largest finite f64 value
47+
#[stable]
3948
pub const MAX_VALUE: f64 = 1.7976931348623157e+308_f64;
4049

50+
#[stable]
4151
pub const MIN_EXP: int = -1021;
52+
#[stable]
4253
pub const MAX_EXP: int = 1024;
4354

55+
#[stable]
4456
pub const MIN_10_EXP: int = -307;
57+
#[stable]
4558
pub const MAX_10_EXP: int = 308;
4659

60+
#[stable]
4761
pub const NAN: f64 = 0.0_f64/0.0_f64;
48-
62+
#[stable]
4963
pub const INFINITY: f64 = 1.0_f64/0.0_f64;
50-
64+
#[stable]
5165
pub const NEG_INFINITY: f64 = -1.0_f64/0.0_f64;
5266

5367
/// Various useful constants.
68+
#[unstable = "naming scheme needs to be revisited"]
5469
pub mod consts {
5570
// FIXME: replace with mathematical constants from cmath.
5671

@@ -110,6 +125,7 @@ pub mod consts {
110125
pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;
111126
}
112127

128+
#[unstable = "trait is unstable"]
113129
impl Float for f64 {
114130
#[inline]
115131
fn nan() -> f64 { NAN }
@@ -421,12 +437,12 @@ impl Float for f64 {
421437

422438
/// Converts to degrees, assuming the number is in radians.
423439
#[inline]
424-
fn to_degrees(self) -> f64 { self * (180.0f64 / Float::pi()) }
440+
fn to_degrees(self) -> f64 { self * (180.0f64 / consts::PI) }
425441

426442
/// Converts to radians, assuming the number is in degrees.
427443
#[inline]
428444
fn to_radians(self) -> f64 {
429-
let value: f64 = Float::pi();
445+
let value: f64 = consts::PI;
430446
self * (value / 180.0)
431447
}
432448
}

src/libcore/num/i16.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
//! Operations and constants for signed 16-bits integers (`i16` type)
1212
13-
#![unstable]
13+
#![stable]
1414
#![doc(primitive = "i16")]
1515

1616
int_module!(i16, 16)
17-

src/libcore/num/i32.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
//! Operations and constants for signed 32-bits integers (`i32` type)
1212
13-
#![unstable]
13+
#![stable]
1414
#![doc(primitive = "i32")]
1515

1616
int_module!(i32, 32)
17-

src/libcore/num/i64.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
//! Operations and constants for signed 64-bits integers (`i64` type)
1212
13-
#![unstable]
13+
#![stable]
1414
#![doc(primitive = "i64")]
1515

1616
int_module!(i64, 64)
17-

src/libcore/num/i8.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
//! Operations and constants for signed 8-bits integers (`i8` type)
1212
13-
#![unstable]
13+
#![stable]
1414
#![doc(primitive = "i8")]
1515

1616
int_module!(i8, 8)
17-

0 commit comments

Comments
 (0)