about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-24 14:40:33 +0000
committerbors <bors@rust-lang.org>2019-12-24 14:40:33 +0000
commitf6dca76be55dd6bb8d0d7d3b6bc39ae8373db506 (patch)
tree7a11fc8bb67b4bdcdc6c49860d1f41381411f64f /src/libcore
parent84d8f9ddd3819501735d30b3c584c6935ef6c9da (diff)
parent811bdeee002827fbc950ac52a6175e933567823c (diff)
downloadrust-f6dca76be55dd6bb8d0d7d3b6bc39ae8373db506.tar.gz
rust-f6dca76be55dd6bb8d0d7d3b6bc39ae8373db506.zip
Auto merge of #66221 - ohadravid:doc-constants, r=Dylan-DPC
Show the actual value of constant values in the documentation

Fixes #66099, making rustdoc show evaluated constant scalar values.

![image](https://user-images.githubusercontent.com/2358365/68474827-c7a95e80-0226-11ea-818a-ded7bbff861f.png)

where `main.rs` is
```
pub const VAL3: i32 = i32::max_value();
pub const VAL4: i32 = i32::max_value() - 1;
```

As a fallback, when a constant value is not evaluated (either because of an error or because it isn't a scalar), the original expression is used for consistency.

I mimicked the way min/max values of integers are [`pretty_print`ed](https://github.com/rust-lang/rust/blob/master/src/librustc/ty/print/pretty.rs#L900), to show both the value a the "hint". While a little goofy for `std`, in user crates I think it's actually rather helpful.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/num/f32.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index e1e6c57a0fb..fd7b7cf0b34 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -30,7 +30,7 @@ pub const DIGITS: u32 = 6;
 ///
 /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const EPSILON: f32 = 1.19209290e-07_f32;
+pub const EPSILON: f32 = 1.1920929e-7_f32;
 
 /// Smallest finite `f32` value.
 #[stable(feature = "rust1", since = "1.0.0")]