Skip to content

Commit c5b0003

Browse files
author
Kyle Strand
committed
Annotate functions taking extra args
1 parent ba2a1fa commit c5b0003

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/libstd/f32.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ impl f32 {
220220
///
221221
/// assert!(f32::NAN.copysign(1.0).is_nan());
222222
/// ```
223-
#[inline]
224223
#[must_use = "method returns a new number and does not mutate the original value"]
224+
#[inline]
225225
#[stable(feature = "copysign", since = "1.35.0")]
226226
pub fn copysign(self, sign: f32) -> f32 {
227227
unsafe { intrinsics::copysignf32(self, sign) }
@@ -247,6 +247,7 @@ impl f32 {
247247
///
248248
/// assert!(abs_difference <= f32::EPSILON);
249249
/// ```
250+
#[must_use = "method returns a new number and does not mutate the original value"]
250251
#[stable(feature = "rust1", since = "1.0.0")]
251252
#[inline]
252253
pub fn mul_add(self, a: f32, b: f32) -> f32 {
@@ -270,6 +271,7 @@ impl f32 {
270271
/// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0
271272
/// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
272273
/// ```
274+
#[must_use = "method returns a new number and does not mutate the original value"]
273275
#[inline]
274276
#[stable(feature = "euclidean_division", since = "1.38.0")]
275277
pub fn div_euclid(self, rhs: f32) -> f32 {
@@ -303,6 +305,7 @@ impl f32 {
303305
/// // limitation due to round-off error
304306
/// assert!((-std::f32::EPSILON).rem_euclid(3.0) != 0.0);
305307
/// ```
308+
#[must_use = "method returns a new number and does not mutate the original value"]
306309
#[inline]
307310
#[stable(feature = "euclidean_division", since = "1.38.0")]
308311
pub fn rem_euclid(self, rhs: f32) -> f32 {
@@ -329,6 +332,7 @@ impl f32 {
329332
///
330333
/// assert!(abs_difference <= f32::EPSILON);
331334
/// ```
335+
#[must_use = "method returns a new number and does not mutate the original value"]
332336
#[stable(feature = "rust1", since = "1.0.0")]
333337
#[inline]
334338
pub fn powi(self, n: i32) -> f32 {
@@ -347,6 +351,7 @@ impl f32 {
347351
///
348352
/// assert!(abs_difference <= f32::EPSILON);
349353
/// ```
354+
#[must_use = "method returns a new number and does not mutate the original value"]
350355
#[stable(feature = "rust1", since = "1.0.0")]
351356
#[inline]
352357
pub fn powf(self, n: f32) -> f32 {
@@ -478,6 +483,7 @@ impl f32 {
478483
///
479484
/// assert!(abs_difference <= f32::EPSILON);
480485
/// ```
486+
#[must_use = "method returns a new number and does not mutate the original value"]
481487
#[stable(feature = "rust1", since = "1.0.0")]
482488
#[inline]
483489
pub fn log(self, base: f32) -> f32 { self.ln() / base.ln() }
@@ -550,6 +556,7 @@ impl f32 {
550556
/// assert!(abs_difference_x <= f32::EPSILON);
551557
/// assert!(abs_difference_y <= f32::EPSILON);
552558
/// ```
559+
#[must_use = "method returns a new number and does not mutate the original value"]
553560
#[stable(feature = "rust1", since = "1.0.0")]
554561
#[inline]
555562
#[rustc_deprecated(since = "1.10.0",
@@ -601,6 +608,7 @@ impl f32 {
601608
///
602609
/// assert!(abs_difference <= f32::EPSILON);
603610
/// ```
611+
#[must_use = "method returns a new number and does not mutate the original value"]
604612
#[stable(feature = "rust1", since = "1.0.0")]
605613
#[inline]
606614
pub fn hypot(self, other: f32) -> f32 {
@@ -770,6 +778,7 @@ impl f32 {
770778
/// assert!(abs_difference_1 <= f32::EPSILON);
771779
/// assert!(abs_difference_2 <= f32::EPSILON);
772780
/// ```
781+
#[must_use = "method returns a new number and does not mutate the original value"]
773782
#[stable(feature = "rust1", since = "1.0.0")]
774783
#[inline]
775784
pub fn atan2(self, other: f32) -> f32 {
@@ -1006,6 +1015,7 @@ impl f32 {
10061015
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
10071016
/// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan());
10081017
/// ```
1018+
#[must_use = "method returns a new number and does not mutate the original value"]
10091019
#[unstable(feature = "clamp", issue = "44095")]
10101020
#[inline]
10111021
pub fn clamp(self, min: f32, max: f32) -> f32 {

src/libstd/f64.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ impl f64 {
198198
///
199199
/// assert!(f64::NAN.copysign(1.0).is_nan());
200200
/// ```
201-
#[inline]
202201
#[must_use = "method returns a new number and does not mutate the original value"]
203202
#[stable(feature = "copysign", since = "1.35.0")]
203+
#[inline]
204204
pub fn copysign(self, sign: f64) -> f64 {
205205
unsafe { intrinsics::copysignf64(self, sign) }
206206
}
@@ -223,6 +223,7 @@ impl f64 {
223223
///
224224
/// assert!(abs_difference < 1e-10);
225225
/// ```
226+
#[must_use = "method returns a new number and does not mutate the original value"]
226227
#[stable(feature = "rust1", since = "1.0.0")]
227228
#[inline]
228229
pub fn mul_add(self, a: f64, b: f64) -> f64 {
@@ -246,6 +247,7 @@ impl f64 {
246247
/// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0
247248
/// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
248249
/// ```
250+
#[must_use = "method returns a new number and does not mutate the original value"]
249251
#[inline]
250252
#[stable(feature = "euclidean_division", since = "1.38.0")]
251253
pub fn div_euclid(self, rhs: f64) -> f64 {
@@ -279,6 +281,7 @@ impl f64 {
279281
/// // limitation due to round-off error
280282
/// assert!((-std::f64::EPSILON).rem_euclid(3.0) != 0.0);
281283
/// ```
284+
#[must_use = "method returns a new number and does not mutate the original value"]
282285
#[inline]
283286
#[stable(feature = "euclidean_division", since = "1.38.0")]
284287
pub fn rem_euclid(self, rhs: f64) -> f64 {
@@ -302,6 +305,7 @@ impl f64 {
302305
///
303306
/// assert!(abs_difference < 1e-10);
304307
/// ```
308+
#[must_use = "method returns a new number and does not mutate the original value"]
305309
#[stable(feature = "rust1", since = "1.0.0")]
306310
#[inline]
307311
pub fn powi(self, n: i32) -> f64 {
@@ -318,6 +322,7 @@ impl f64 {
318322
///
319323
/// assert!(abs_difference < 1e-10);
320324
/// ```
325+
#[must_use = "method returns a new number and does not mutate the original value"]
321326
#[stable(feature = "rust1", since = "1.0.0")]
322327
#[inline]
323328
pub fn powf(self, n: f64) -> f64 {
@@ -427,6 +432,7 @@ impl f64 {
427432
///
428433
/// assert!(abs_difference < 1e-10);
429434
/// ```
435+
#[must_use = "method returns a new number and does not mutate the original value"]
430436
#[stable(feature = "rust1", since = "1.0.0")]
431437
#[inline]
432438
pub fn log(self, base: f64) -> f64 { self.ln() / base.ln() }
@@ -491,6 +497,7 @@ impl f64 {
491497
/// assert!(abs_difference_x < 1e-10);
492498
/// assert!(abs_difference_y < 1e-10);
493499
/// ```
500+
#[must_use = "method returns a new number and does not mutate the original value"]
494501
#[stable(feature = "rust1", since = "1.0.0")]
495502
#[inline]
496503
#[rustc_deprecated(since = "1.10.0",
@@ -538,6 +545,7 @@ impl f64 {
538545
///
539546
/// assert!(abs_difference < 1e-10);
540547
/// ```
548+
#[must_use = "method returns a new number and does not mutate the original value"]
541549
#[stable(feature = "rust1", since = "1.0.0")]
542550
#[inline]
543551
pub fn hypot(self, other: f64) -> f64 {
@@ -697,6 +705,7 @@ impl f64 {
697705
/// assert!(abs_difference_1 < 1e-10);
698706
/// assert!(abs_difference_2 < 1e-10);
699707
/// ```
708+
#[must_use = "method returns a new number and does not mutate the original value"]
700709
#[stable(feature = "rust1", since = "1.0.0")]
701710
#[inline]
702711
pub fn atan2(self, other: f64) -> f64 {

0 commit comments

Comments
 (0)