Auto merge of #68325 - faern:move-numeric-consts-to-associated-consts-step1, r=LukasKalbertodt

Move numeric consts to associated consts step1

A subset of #67913. Implements the first step of RFC https://github.com/rust-lang/rfcs/pull/2700

This PR adds the new constants as unstable constants and defines the old ones in terms of the new ones. Then fix a tiny bit of code that started having naming collisions because of the new assoc consts.

Removed a test that did not seem relevant any longer. Since doing just `u8::MIN` should now indeed be valid.
This commit is contained in:
bors 2020-01-30 08:55:07 +00:00
commit c4071d0919
10 changed files with 209 additions and 79 deletions

View file

@ -47,9 +47,9 @@ pub struct MyTypeWithStr(&'static str);
// @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '; //'
pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this");
// @has show_const_contents/constant.EPSILON.html '1.1920929e-7f32;'
// @!has show_const_contents/constant.EPSILON.html '; //'
pub use std::f32::EPSILON;
// @has show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;'
// @has show_const_contents/constant.PI.html '; // 3.14159274f32'
pub use std::f32::consts::PI;
// @has show_const_contents/constant.MAX.html '= i32::max_value(); // 2_147_483_647i32'
pub use std::i32::MAX;

View file

@ -1,4 +0,0 @@
const FOO: [u32; u8::MIN as usize] = [];
//~^ ERROR no associated item named `MIN` found
fn main() {}

View file

@ -1,14 +0,0 @@
error[E0599]: no associated item named `MIN` found for type `u8` in the current scope
--> $DIR/issue-22933-3.rs:1:22
|
LL | const FOO: [u32; u8::MIN as usize] = [];
| ^^^ associated item not found in `u8`
|
help: you are looking for the module in `std`, not the primitive type
|
LL | const FOO: [u32; std::u8::MIN as usize] = [];
| ^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.

View file

@ -0,0 +1,11 @@
// run-pass
// Make sure the module level constants are still there and accessible even after
// the corresponding associated constants have been added, and later stabilized.
use std::{u16, f32};
fn main() {
let _ = u16::MAX;
let _ = f32::EPSILON;
let _ = std::f64::MANTISSA_DIGITS;
}