Skip to content

Commit

Permalink
Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514
Browse files Browse the repository at this point in the history
Update tests to remove old numeric constants

Part of #68490.

Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros.

For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
  • Loading branch information
bors committed Nov 29, 2020
2 parents 2e57231 + 90a2e5e commit af780e5
Show file tree
Hide file tree
Showing 106 changed files with 463 additions and 528 deletions.
68 changes: 34 additions & 34 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,133 +1173,133 @@ extern "rust-intrinsic" {
/// Returns the square root of an `f32`
///
/// The stabilized version of this intrinsic is
/// [`std::f32::sqrt`](../../std/primitive.f32.html#method.sqrt)
/// [`f32::sqrt`](../../std/primitive.f32.html#method.sqrt)
pub fn sqrtf32(x: f32) -> f32;
/// Returns the square root of an `f64`
///
/// The stabilized version of this intrinsic is
/// [`std::f64::sqrt`](../../std/primitive.f64.html#method.sqrt)
/// [`f64::sqrt`](../../std/primitive.f64.html#method.sqrt)
pub fn sqrtf64(x: f64) -> f64;

/// Raises an `f32` to an integer power.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::powi`](../../std/primitive.f32.html#method.powi)
/// [`f32::powi`](../../std/primitive.f32.html#method.powi)
pub fn powif32(a: f32, x: i32) -> f32;
/// Raises an `f64` to an integer power.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::powi`](../../std/primitive.f64.html#method.powi)
/// [`f64::powi`](../../std/primitive.f64.html#method.powi)
pub fn powif64(a: f64, x: i32) -> f64;

/// Returns the sine of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::sin`](../../std/primitive.f32.html#method.sin)
/// [`f32::sin`](../../std/primitive.f32.html#method.sin)
pub fn sinf32(x: f32) -> f32;
/// Returns the sine of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::sin`](../../std/primitive.f64.html#method.sin)
/// [`f64::sin`](../../std/primitive.f64.html#method.sin)
pub fn sinf64(x: f64) -> f64;

/// Returns the cosine of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::cos`](../../std/primitive.f32.html#method.cos)
/// [`f32::cos`](../../std/primitive.f32.html#method.cos)
pub fn cosf32(x: f32) -> f32;
/// Returns the cosine of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::cos`](../../std/primitive.f64.html#method.cos)
/// [`f64::cos`](../../std/primitive.f64.html#method.cos)
pub fn cosf64(x: f64) -> f64;

/// Raises an `f32` to an `f32` power.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::powf`](../../std/primitive.f32.html#method.powf)
/// [`f32::powf`](../../std/primitive.f32.html#method.powf)
pub fn powf32(a: f32, x: f32) -> f32;
/// Raises an `f64` to an `f64` power.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::powf`](../../std/primitive.f64.html#method.powf)
/// [`f64::powf`](../../std/primitive.f64.html#method.powf)
pub fn powf64(a: f64, x: f64) -> f64;

/// Returns the exponential of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::exp`](../../std/primitive.f32.html#method.exp)
/// [`f32::exp`](../../std/primitive.f32.html#method.exp)
pub fn expf32(x: f32) -> f32;
/// Returns the exponential of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::exp`](../../std/primitive.f64.html#method.exp)
/// [`f64::exp`](../../std/primitive.f64.html#method.exp)
pub fn expf64(x: f64) -> f64;

/// Returns 2 raised to the power of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::exp2`](../../std/primitive.f32.html#method.exp2)
/// [`f32::exp2`](../../std/primitive.f32.html#method.exp2)
pub fn exp2f32(x: f32) -> f32;
/// Returns 2 raised to the power of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::exp2`](../../std/primitive.f64.html#method.exp2)
/// [`f64::exp2`](../../std/primitive.f64.html#method.exp2)
pub fn exp2f64(x: f64) -> f64;

/// Returns the natural logarithm of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::ln`](../../std/primitive.f32.html#method.ln)
/// [`f32::ln`](../../std/primitive.f32.html#method.ln)
pub fn logf32(x: f32) -> f32;
/// Returns the natural logarithm of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::ln`](../../std/primitive.f64.html#method.ln)
/// [`f64::ln`](../../std/primitive.f64.html#method.ln)
pub fn logf64(x: f64) -> f64;

/// Returns the base 10 logarithm of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::log10`](../../std/primitive.f32.html#method.log10)
/// [`f32::log10`](../../std/primitive.f32.html#method.log10)
pub fn log10f32(x: f32) -> f32;
/// Returns the base 10 logarithm of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::log10`](../../std/primitive.f64.html#method.log10)
/// [`f64::log10`](../../std/primitive.f64.html#method.log10)
pub fn log10f64(x: f64) -> f64;

/// Returns the base 2 logarithm of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::log2`](../../std/primitive.f32.html#method.log2)
/// [`f32::log2`](../../std/primitive.f32.html#method.log2)
pub fn log2f32(x: f32) -> f32;
/// Returns the base 2 logarithm of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::log2`](../../std/primitive.f64.html#method.log2)
/// [`f64::log2`](../../std/primitive.f64.html#method.log2)
pub fn log2f64(x: f64) -> f64;

/// Returns `a * b + c` for `f32` values.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::mul_add`](../../std/primitive.f32.html#method.mul_add)
/// [`f32::mul_add`](../../std/primitive.f32.html#method.mul_add)
pub fn fmaf32(a: f32, b: f32, c: f32) -> f32;
/// Returns `a * b + c` for `f64` values.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::mul_add`](../../std/primitive.f64.html#method.mul_add)
/// [`f64::mul_add`](../../std/primitive.f64.html#method.mul_add)
pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;

/// Returns the absolute value of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::abs`](../../std/primitive.f32.html#method.abs)
/// [`f32::abs`](../../std/primitive.f32.html#method.abs)
pub fn fabsf32(x: f32) -> f32;
/// Returns the absolute value of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::abs`](../../std/primitive.f64.html#method.abs)
/// [`f64::abs`](../../std/primitive.f64.html#method.abs)
pub fn fabsf64(x: f64) -> f64;

/// Returns the minimum of two `f32` values.
Expand All @@ -1326,45 +1326,45 @@ extern "rust-intrinsic" {
/// Copies the sign from `y` to `x` for `f32` values.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::copysign`](../../std/primitive.f32.html#method.copysign)
/// [`f32::copysign`](../../std/primitive.f32.html#method.copysign)
pub fn copysignf32(x: f32, y: f32) -> f32;
/// Copies the sign from `y` to `x` for `f64` values.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::copysign`](../../std/primitive.f64.html#method.copysign)
/// [`f64::copysign`](../../std/primitive.f64.html#method.copysign)
pub fn copysignf64(x: f64, y: f64) -> f64;

/// Returns the largest integer less than or equal to an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::floor`](../../std/primitive.f32.html#method.floor)
/// [`f32::floor`](../../std/primitive.f32.html#method.floor)
pub fn floorf32(x: f32) -> f32;
/// Returns the largest integer less than or equal to an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::floor`](../../std/primitive.f64.html#method.floor)
/// [`f64::floor`](../../std/primitive.f64.html#method.floor)
pub fn floorf64(x: f64) -> f64;

/// Returns the smallest integer greater than or equal to an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::ceil`](../../std/primitive.f32.html#method.ceil)
/// [`f32::ceil`](../../std/primitive.f32.html#method.ceil)
pub fn ceilf32(x: f32) -> f32;
/// Returns the smallest integer greater than or equal to an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::ceil`](../../std/primitive.f64.html#method.ceil)
/// [`f64::ceil`](../../std/primitive.f64.html#method.ceil)
pub fn ceilf64(x: f64) -> f64;

/// Returns the integer part of an `f32`.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::trunc`](../../std/primitive.f32.html#method.trunc)
/// [`f32::trunc`](../../std/primitive.f32.html#method.trunc)
pub fn truncf32(x: f32) -> f32;
/// Returns the integer part of an `f64`.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::trunc`](../../std/primitive.f64.html#method.trunc)
/// [`f64::trunc`](../../std/primitive.f64.html#method.trunc)
pub fn truncf64(x: f64) -> f64;

/// Returns the nearest integer to an `f32`. May raise an inexact floating-point exception
Expand All @@ -1386,12 +1386,12 @@ extern "rust-intrinsic" {
/// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero.
///
/// The stabilized version of this intrinsic is
/// [`std::f32::round`](../../std/primitive.f32.html#method.round)
/// [`f32::round`](../../std/primitive.f32.html#method.round)
pub fn roundf32(x: f32) -> f32;
/// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero.
///
/// The stabilized version of this intrinsic is
/// [`std::f64::round`](../../std/primitive.f64.html#method.round)
/// [`f64::round`](../../std/primitive.f64.html#method.round)
pub fn roundf64(x: f64) -> f64;

/// Float addition that allows optimizations based on algebraic rules.
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/num/nan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#[test]
fn test_nan() {
use core::f64;
let x = "NaN".to_string();
assert_eq!(format!("{}", f64::NAN), x);
assert_eq!(format!("{:e}", f64::NAN), x);
Expand Down
8 changes: 4 additions & 4 deletions src/test/codegen/enum-discriminant-value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#[repr(i64)]
pub enum I64 {
I64Min = std::i64::MIN,
I64Max = std::i64::MAX,
I64Min = i64::MIN,
I64Max = i64::MAX,
}

#[repr(u64)]
pub enum U64 {
U64Min = std::u64::MIN,
U64Max = std::u64::MAX,
U64Min = u64::MIN,
U64Max = u64::MAX,
}

fn main() {
Expand Down
1 change: 0 additions & 1 deletion src/test/codegen/issue-56927.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type="rlib"]
use std::usize;

#[repr(align(16))]
pub struct S {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/consts/issue-55878.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

// error-pattern: are too big for the current architecture
fn main() {
println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
}
1 change: 1 addition & 0 deletions src/test/rustdoc/reexport-check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extern crate reexport_check;
// @!has 'foo/index.html' '//code' 'pub use self::i32;'
// @has 'foo/index.html' '//tr[@class="module-item"]' 'i32'
// @has 'foo/i32/index.html'
#[allow(deprecated, deprecated_in_future)]
pub use std::i32;
// @!has 'foo/index.html' '//code' 'pub use self::string::String;'
// @has 'foo/index.html' '//tr[@class="module-item"]' 'String'
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc/show-const-contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this");
pub use std::f32::consts::PI;

// @has show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32'
#[allow(deprecated, deprecated_in_future)]
pub use std::i32::MAX;

macro_rules! int_module {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/array-slice-vec/bounds-check-no-overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// error-pattern:index out of bounds
// ignore-emscripten no processes

use std::usize;
use std::mem::size_of;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
error: this arithmetic operation will overflow
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:22
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:27:22
|
LL | const NEG: i32 = -i32::MIN + T::NEG;
| ^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default

error: this arithmetic operation will overflow
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:31:35
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:35
|
LL | const NEG_REV: i32 = T::NEG + (-i32::MIN);
| ^^^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow

error: this arithmetic operation will overflow
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:22
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:32:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow

error: this arithmetic operation will overflow
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:36:36
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:36
|
LL | const ADD_REV: i32 = T::ADD + (i32::MAX+1);
| ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow

error: this operation will panic at runtime
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:22
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:37:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide `1_i32` by zero
|
= note: `#[deny(unconditional_panic)]` on by default

error: this operation will panic at runtime
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:41:35
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:35
|
LL | const DIV_REV: i32 = T::DIV + (1/0);
| ^^^^^ attempt to divide `1_i32` by zero

error: this operation will panic at runtime
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:22
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:42:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the length is 1 but the index is 1

error: this operation will panic at runtime
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:46:35
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:35
|
LL | const OOB_REV: i32 = T::OOB + [1][1];
| ^^^^^^ index out of bounds: the length is 1 but the index is 1
Expand Down
Loading

0 comments on commit af780e5

Please sign in to comment.