about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-03 16:31:34 +0000
committerbors <bors@rust-lang.org>2018-09-03 16:31:34 +0000
commitcd5c26f0eb48c8f32ea86e9f2434d905ff2cfc74 (patch)
tree155c8f01c3c62548c76441cb207504e1024345d3 /src/test
parentee73f80dc963707df3b3da82976556d64cac5752 (diff)
parent4811e5b6c71657772b4c12e6f5cbb5c1624bf669 (diff)
downloadrust-cd5c26f0eb48c8f32ea86e9f2434d905ff2cfc74.tar.gz
rust-cd5c26f0eb48c8f32ea86e9f2434d905ff2cfc74.zip
Auto merge of #53697 - Cyres:const-fn-int-ops, r=oli-obk
Add more const int ops

r? @oli-obk

Tracking Issue: #53718

list of `const fn`s in this PR:

- `feature = const_int_rotate`
  - `rotate_left`
  - `rotate_right`
- `feature = const_int_wrapping`
  - `wrapping_add`
  - `wrapping_sub`
  - `wrapping_mul`
  - `wrapping_shl`
  - `wrapping_shr`
- `feature = const_int_overflowing`
  - `overflowing_add`
  - `overflowing_sub`
  - `overflowing_mul`
  - `overflowing_shl`
  - `overflowing_shr`
- `feature = const_int_sign`
  - `is_positive`
  - `is_negative`
- `feature = const_int_conversion`
  - `reverse_bits`
  - `to_le_bytes`
  - `to_ne_bytes`
  - `from_be_bytes`
  - `from_le_bytes`
  - `from_ne_bytes`
  - `reverse_bits`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/const-int-conversion.rs34
-rw-r--r--src/test/run-pass/const-int-overflowing.rs47
-rw-r--r--src/test/run-pass/const-int-rotate.rs23
-rw-r--r--src/test/run-pass/const-int-sign.rs23
-rw-r--r--src/test/run-pass/const-int-wrapping.rs47
-rw-r--r--src/test/ui/consts/const-int-conversion.rs28
-rw-r--r--src/test/ui/consts/const-int-conversion.stderr80
-rw-r--r--src/test/ui/consts/const-int-overflowing.rs15
-rw-r--r--src/test/ui/consts/const-int-overflowing.stderr35
-rw-r--r--src/test/ui/consts/const-int-rotate.rs14
-rw-r--r--src/test/ui/consts/const-int-rotate.stderr24
-rw-r--r--src/test/ui/consts/const-int-sign.rs14
-rw-r--r--src/test/ui/consts/const-int-sign.stderr24
-rw-r--r--src/test/ui/consts/const-int-wrapping.rs17
-rw-r--r--src/test/ui/consts/const-int-wrapping.stderr57
15 files changed, 482 insertions, 0 deletions
diff --git a/src/test/run-pass/const-int-conversion.rs b/src/test/run-pass/const-int-conversion.rs
new file mode 100644
index 00000000000..790c62288d3
--- /dev/null
+++ b/src/test/run-pass/const-int-conversion.rs
@@ -0,0 +1,34 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_int_conversion, const_int_ops, reverse_bits, int_to_from_bytes)]
+
+const REVERSE: u32 = 0x12345678_u32.reverse_bits();
+const FROM_BE_BYTES: i32 = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]);
+const FROM_LE_BYTES: i32 = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
+const FROM_NE_BYTES: i32 = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
+const TO_BE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_be_bytes();
+const TO_LE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_le_bytes();
+const TO_NE_BYTES: [u8; 4] = i32::min_value().to_be().to_ne_bytes();
+
+fn ident<T>(ident: T) -> T {
+    ident
+}
+
+fn main() {
+    assert_eq!(REVERSE, ident(0x1e6a2c48));
+    assert_eq!(FROM_BE_BYTES, ident(0x12_34_56_78));
+    assert_eq!(FROM_LE_BYTES, ident(0x78_56_34_12));
+    assert_eq!(FROM_NE_BYTES, ident(i32::min_value()));
+    assert_eq!(TO_BE_BYTES, ident([0x12, 0x34, 0x56, 0x78]));
+    assert_eq!(TO_LE_BYTES, ident([0x78, 0x56, 0x34, 0x12]));
+    assert_eq!(TO_NE_BYTES, ident([0x80, 0, 0, 0]));
+}
+
diff --git a/src/test/run-pass/const-int-overflowing.rs b/src/test/run-pass/const-int-overflowing.rs
new file mode 100644
index 00000000000..0f8f230f456
--- /dev/null
+++ b/src/test/run-pass/const-int-overflowing.rs
@@ -0,0 +1,47 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_int_overflowing)]
+
+const ADD_A: (u32, bool) = 5u32.overflowing_add(2);
+const ADD_B: (u32, bool) = u32::max_value().overflowing_add(1);
+
+const SUB_A: (u32, bool) = 5u32.overflowing_sub(2);
+const SUB_B: (u32, bool) = 0u32.overflowing_sub(1);
+
+const MUL_A: (u32, bool) = 5u32.overflowing_mul(2);
+const MUL_B: (u32, bool) = 1_000_000_000u32.overflowing_mul(10);
+
+const SHL_A: (u32, bool) = 0x1u32.overflowing_shl(4);
+const SHL_B: (u32, bool) = 0x1u32.overflowing_shl(132);
+
+const SHR_A: (u32, bool) = 0x10u32.overflowing_shr(4);
+const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132);
+
+fn ident<T>(ident: T) -> T {
+    ident
+}
+
+fn main() {
+    assert_eq!(ADD_A, ident((7, false)));
+    assert_eq!(ADD_B, ident((0, true)));
+
+    assert_eq!(SUB_A, ident((3, false)));
+    assert_eq!(SUB_B, ident((u32::max_value(), true)));
+
+    assert_eq!(MUL_A, ident((10, false)));
+    assert_eq!(MUL_B, ident((1410065408, true)));
+
+    assert_eq!(SHL_A, ident((0x10, false)));
+    assert_eq!(SHL_B, ident((0x10, true)));
+
+    assert_eq!(SHR_A, ident((0x1, false)));
+    assert_eq!(SHR_B, ident((0x1, true)));
+}
diff --git a/src/test/run-pass/const-int-rotate.rs b/src/test/run-pass/const-int-rotate.rs
new file mode 100644
index 00000000000..ee8e0b0b9dd
--- /dev/null
+++ b/src/test/run-pass/const-int-rotate.rs
@@ -0,0 +1,23 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_int_rotate)]
+
+const LEFT: u32 = 0x10000b3u32.rotate_left(8);
+const RIGHT: u32 = 0xb301u32.rotate_right(8);
+
+fn ident<T>(ident: T) -> T {
+    ident
+}
+
+fn main() {
+    assert_eq!(LEFT, ident(0xb301));
+    assert_eq!(RIGHT, ident(0x10000b3));
+}
diff --git a/src/test/run-pass/const-int-sign.rs b/src/test/run-pass/const-int-sign.rs
new file mode 100644
index 00000000000..e095cfb000c
--- /dev/null
+++ b/src/test/run-pass/const-int-sign.rs
@@ -0,0 +1,23 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_int_sign)]
+
+const NEGATIVE_A: bool = (-10i32).is_negative();
+const NEGATIVE_B: bool = 10i32.is_negative();
+const POSITIVE_A: bool= (-10i32).is_positive();
+const POSITIVE_B: bool= 10i32.is_positive();
+
+fn main() {
+    assert!(NEGATIVE_A);
+    assert!(!NEGATIVE_B);
+    assert!(!POSITIVE_A);
+    assert!(POSITIVE_B);
+}
diff --git a/src/test/run-pass/const-int-wrapping.rs b/src/test/run-pass/const-int-wrapping.rs
new file mode 100644
index 00000000000..ab7c98f9824
--- /dev/null
+++ b/src/test/run-pass/const-int-wrapping.rs
@@ -0,0 +1,47 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(const_int_wrapping)]
+
+const ADD_A: u32 = 200u32.wrapping_add(55);
+const ADD_B: u32 = 200u32.wrapping_add(u32::max_value());
+
+const SUB_A: u32 = 100u32.wrapping_sub(100);
+const SUB_B: u32 = 100u32.wrapping_sub(u32::max_value());
+
+const MUL_A: u8 = 10u8.wrapping_mul(12);
+const MUL_B: u8 = 25u8.wrapping_mul(12);
+
+const SHL_A: u32 = 1u32.wrapping_shl(7);
+const SHL_B: u32 = 1u32.wrapping_shl(128);
+
+const SHR_A: u32 = 128u32.wrapping_shr(7);
+const SHR_B: u32 = 128u32.wrapping_shr(128);
+
+fn ident<T>(ident: T) -> T {
+    ident
+}
+
+fn main() {
+    assert_eq!(ADD_A, ident(255));
+    assert_eq!(ADD_B, ident(199));
+
+    assert_eq!(SUB_A, ident(0));
+    assert_eq!(SUB_B, ident(101));
+
+    assert_eq!(MUL_A, ident(120));
+    assert_eq!(MUL_B, ident(44));
+
+    assert_eq!(SHL_A, ident(128));
+    assert_eq!(SHL_B, ident(1));
+
+    assert_eq!(SHR_A, ident(1));
+    assert_eq!(SHR_B, ident(128));
+}
diff --git a/src/test/ui/consts/const-int-conversion.rs b/src/test/ui/consts/const-int-conversion.rs
new file mode 100644
index 00000000000..0abe6b4a1e4
--- /dev/null
+++ b/src/test/ui/consts/const-int-conversion.rs
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(reverse_bits, int_to_from_bytes)]
+
+fn main() {
+    let x: &'static i32 = &(5_i32.reverse_bits());
+        //~^ ERROR does not live long enough
+    let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]));
+        //~^ ERROR does not live long enough
+    let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]));
+        //~^ ERROR does not live long enough
+    let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])));
+        //~^ ERROR does not live long enough
+    let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes());
+        //~^ ERROR does not live long enough
+    let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
+        //~^ ERROR does not live long enough
+    let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
+        //~^ ERROR does not live long enough
+}
diff --git a/src/test/ui/consts/const-int-conversion.stderr b/src/test/ui/consts/const-int-conversion.stderr
new file mode 100644
index 00000000000..fc2472a7b58
--- /dev/null
+++ b/src/test/ui/consts/const-int-conversion.stderr
@@ -0,0 +1,80 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:14:28
+   |
+LL |     let x: &'static i32 = &(5_i32.reverse_bits());
+   |                            ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:16:28
+   |
+LL |     let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:18:28
+   |
+LL |     let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:20:28
+   |
+LL |     let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])));
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:22:29
+   |
+LL |     let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:24:29
+   |
+LL |     let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-conversion.rs:26:29
+   |
+LL |     let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
+   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL |         //~^ ERROR does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/consts/const-int-overflowing.rs b/src/test/ui/consts/const-int-overflowing.rs
new file mode 100644
index 00000000000..7bff6b9adb0
--- /dev/null
+++ b/src/test/ui/consts/const-int-overflowing.rs
@@ -0,0 +1,15 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough
+    let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough
+    let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough
+}
diff --git a/src/test/ui/consts/const-int-overflowing.stderr b/src/test/ui/consts/const-int-overflowing.stderr
new file mode 100644
index 00000000000..e06fb6af1a6
--- /dev/null
+++ b/src/test/ui/consts/const-int-overflowing.stderr
@@ -0,0 +1,35 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-overflowing.rs:12:36
+   |
+LL |     let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-overflowing.rs:13:36
+   |
+LL |     let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL |     let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-overflowing.rs:14:36
+   |
+LL |     let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/consts/const-int-rotate.rs b/src/test/ui/consts/const-int-rotate.rs
new file mode 100644
index 00000000000..e6f05338c84
--- /dev/null
+++ b/src/test/ui/consts/const-int-rotate.rs
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough
+    let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough
+}
diff --git a/src/test/ui/consts/const-int-rotate.stderr b/src/test/ui/consts/const-int-rotate.stderr
new file mode 100644
index 00000000000..fa2f6255e01
--- /dev/null
+++ b/src/test/ui/consts/const-int-rotate.stderr
@@ -0,0 +1,24 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-rotate.rs:12:28
+   |
+LL |     let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL |     let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-rotate.rs:13:28
+   |
+LL |     let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/consts/const-int-sign.rs b/src/test/ui/consts/const-int-sign.rs
new file mode 100644
index 00000000000..1082c385cd4
--- /dev/null
+++ b/src/test/ui/consts/const-int-sign.rs
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough
+    let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough
+}
diff --git a/src/test/ui/consts/const-int-sign.stderr b/src/test/ui/consts/const-int-sign.stderr
new file mode 100644
index 00000000000..1d456287bd8
--- /dev/null
+++ b/src/test/ui/consts/const-int-sign.stderr
@@ -0,0 +1,24 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-sign.rs:12:29
+   |
+LL |     let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough
+   |                             ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL |     let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-sign.rs:13:29
+   |
+LL |     let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough
+   |                             ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/consts/const-int-wrapping.rs b/src/test/ui/consts/const-int-wrapping.rs
new file mode 100644
index 00000000000..bd11d5df232
--- /dev/null
+++ b/src/test/ui/consts/const-int-wrapping.rs
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough
+    let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough
+    let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough
+    let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough
+    let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough
+}
diff --git a/src/test/ui/consts/const-int-wrapping.stderr b/src/test/ui/consts/const-int-wrapping.stderr
new file mode 100644
index 00000000000..94974e09939
--- /dev/null
+++ b/src/test/ui/consts/const-int-wrapping.stderr
@@ -0,0 +1,57 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-wrapping.rs:12:28
+   |
+LL |     let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-wrapping.rs:13:28
+   |
+LL |     let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-wrapping.rs:14:28
+   |
+LL |     let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+...
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-wrapping.rs:15:28
+   |
+LL |     let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL |     let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/const-int-wrapping.rs:16:28
+   |
+LL |     let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough
+   |                            ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0597`.