rebase
This commit is contained in:
parent
e6381a7f37
commit
cdea63058a
@ -120,6 +120,13 @@
|
|||||||
#![feature(const_slice_len)]
|
#![feature(const_slice_len)]
|
||||||
#![feature(const_str_as_bytes)]
|
#![feature(const_str_as_bytes)]
|
||||||
#![feature(const_str_len)]
|
#![feature(const_str_len)]
|
||||||
|
#![feature(const_let)]
|
||||||
|
#![feature(const_int_rotate)]
|
||||||
|
#![feature(const_int_wrapping)]
|
||||||
|
#![feature(const_int_sign)]
|
||||||
|
#![feature(const_int_conversion)]
|
||||||
|
#![feature(const_transmute)]
|
||||||
|
#![feature(reverse_bits)]
|
||||||
#![feature(non_exhaustive)]
|
#![feature(non_exhaustive)]
|
||||||
|
|
||||||
#[prelude_import]
|
#[prelude_import]
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,7 @@
|
|||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use rustc::ty;
|
use rustc::ty;
|
||||||
use rustc::ty::layout::{LayoutOf, Primitive};
|
use rustc::ty::layout::{LayoutOf, Primitive};
|
||||||
|
use rustc::mir::BinOp;
|
||||||
use rustc::mir::interpret::{
|
use rustc::mir::interpret::{
|
||||||
EvalResult, EvalErrorKind, Scalar,
|
EvalResult, EvalErrorKind, Scalar,
|
||||||
};
|
};
|
||||||
@ -39,6 +40,7 @@ fn numeric_intrinsic<'tcx>(
|
|||||||
"ctlz" => bits.leading_zeros() as u128 - extra,
|
"ctlz" => bits.leading_zeros() as u128 - extra,
|
||||||
"cttz" => (bits << extra).trailing_zeros() as u128 - extra,
|
"cttz" => (bits << extra).trailing_zeros() as u128 - extra,
|
||||||
"bswap" => (bits << extra).swap_bytes(),
|
"bswap" => (bits << extra).swap_bytes(),
|
||||||
|
"bitreverse" => (bits << extra).reverse_bits(),
|
||||||
_ => bug!("not a numeric intrinsic: {}", name),
|
_ => bug!("not a numeric intrinsic: {}", name),
|
||||||
};
|
};
|
||||||
Ok(Scalar::from_uint(bits_out, size))
|
Ok(Scalar::from_uint(bits_out, size))
|
||||||
@ -76,7 +78,13 @@ pub fn emulate_intrinsic(
|
|||||||
let id_val = Scalar::from_uint(type_id, dest.layout.size);
|
let id_val = Scalar::from_uint(type_id, dest.layout.size);
|
||||||
self.write_scalar(id_val, dest)?;
|
self.write_scalar(id_val, dest)?;
|
||||||
}
|
}
|
||||||
"ctpop" | "cttz" | "cttz_nonzero" | "ctlz" | "ctlz_nonzero" | "bswap" => {
|
| "ctpop"
|
||||||
|
| "cttz"
|
||||||
|
| "cttz_nonzero"
|
||||||
|
| "ctlz"
|
||||||
|
| "ctlz_nonzero"
|
||||||
|
| "bswap"
|
||||||
|
| "bitreverse" => {
|
||||||
let ty = substs.type_at(0);
|
let ty = substs.type_at(0);
|
||||||
let layout_of = self.layout_of(ty)?;
|
let layout_of = self.layout_of(ty)?;
|
||||||
let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?;
|
let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?;
|
||||||
@ -94,6 +102,33 @@ pub fn emulate_intrinsic(
|
|||||||
};
|
};
|
||||||
self.write_scalar(out_val, dest)?;
|
self.write_scalar(out_val, dest)?;
|
||||||
}
|
}
|
||||||
|
| "overflowing_add"
|
||||||
|
| "overflowing_sub"
|
||||||
|
| "overflowing_mul"
|
||||||
|
| "unchecked_shl"
|
||||||
|
| "unchecked_shr"
|
||||||
|
| "add_with_overflow"
|
||||||
|
| "sub_with_overflow"
|
||||||
|
| "mul_with_overflow" => {
|
||||||
|
let lhs = self.read_value(args[0])?;
|
||||||
|
let rhs = self.read_value(args[1])?;
|
||||||
|
let (bin_op, ignore_overflow) = match intrinsic_name {
|
||||||
|
"overflowing_add" => (BinOp::Add, true),
|
||||||
|
"overflowing_sub" => (BinOp::Sub, true),
|
||||||
|
"overflowing_mul" => (BinOp::Mul, true),
|
||||||
|
"unchecked_shl" => (BinOp::Shl, true),
|
||||||
|
"unchecked_shr" => (BinOp::Shr, true),
|
||||||
|
"add_with_overflow" => (BinOp::Add, false),
|
||||||
|
"sub_with_overflow" => (BinOp::Sub, false),
|
||||||
|
"mul_with_overflow" => (BinOp::Mul, false),
|
||||||
|
_ => bug!("Already checked for int ops")
|
||||||
|
};
|
||||||
|
if ignore_overflow {
|
||||||
|
self.binop_ignore_overflow(bin_op, lhs, rhs, dest)?;
|
||||||
|
} else {
|
||||||
|
self.binop_with_overflow(bin_op, lhs, rhs, dest)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
"transmute" => {
|
"transmute" => {
|
||||||
// Go through an allocation, to make sure the completely different layouts
|
// Go through an allocation, to make sure the completely different layouts
|
||||||
// do not pose a problem. (When the user transmutes through a union,
|
// do not pose a problem. (When the user transmutes through a union,
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#![feature(slice_concat_ext)]
|
#![feature(slice_concat_ext)]
|
||||||
#![feature(if_while_or_patterns)]
|
#![feature(if_while_or_patterns)]
|
||||||
#![feature(try_from)]
|
#![feature(try_from)]
|
||||||
|
#![feature(reverse_bits)]
|
||||||
|
|
||||||
#![recursion_limit="256"]
|
#![recursion_limit="256"]
|
||||||
|
|
||||||
|
@ -826,11 +826,20 @@ fn visit_terminator_kind(&mut self,
|
|||||||
| "min_align_of"
|
| "min_align_of"
|
||||||
| "type_id"
|
| "type_id"
|
||||||
| "bswap"
|
| "bswap"
|
||||||
|
| "bitreverse"
|
||||||
| "ctpop"
|
| "ctpop"
|
||||||
| "cttz"
|
| "cttz"
|
||||||
| "cttz_nonzero"
|
| "cttz_nonzero"
|
||||||
| "ctlz"
|
| "ctlz"
|
||||||
| "ctlz_nonzero" => is_const_fn = Some(def_id),
|
| "ctlz_nonzero"
|
||||||
|
| "overflowing_add"
|
||||||
|
| "overflowing_sub"
|
||||||
|
| "overflowing_mul"
|
||||||
|
| "unchecked_shl"
|
||||||
|
| "unchecked_shr"
|
||||||
|
| "add_with_overflow"
|
||||||
|
| "sub_with_overflow"
|
||||||
|
| "mul_with_overflow" => is_const_fn = Some(def_id),
|
||||||
"transmute" => {
|
"transmute" => {
|
||||||
if self.mode != Mode::Fn {
|
if self.mode != Mode::Fn {
|
||||||
is_const_fn = Some(def_id);
|
is_const_fn = Some(def_id);
|
||||||
|
30
src/test/run-pass/const-int-conversion.rs
Normal file
30
src/test/run-pass/const-int-conversion.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// 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 main() {
|
||||||
|
assert_eq!(REVERSE, 0x1e6a2c48);
|
||||||
|
assert_eq!(FROM_BE_BYTES, 0x12_34_56_78);
|
||||||
|
assert_eq!(FROM_LE_BYTES, 0x78_56_34_12);
|
||||||
|
assert_eq!(FROM_NE_BYTES, i32::min_value());
|
||||||
|
assert_eq!(TO_BE_BYTES, [0x12, 0x34, 0x56, 0x78]);
|
||||||
|
assert_eq!(TO_LE_BYTES, [0x78, 0x56, 0x34, 0x12]);
|
||||||
|
assert_eq!(TO_NE_BYTES, [0x80, 0, 0, 0]);
|
||||||
|
}
|
||||||
|
|
43
src/test/run-pass/const-int-overflowing.rs
Normal file
43
src/test/run-pass/const-int-overflowing.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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 main() {
|
||||||
|
assert_eq!(ADD_A, (7, false));
|
||||||
|
assert_eq!(ADD_B, (0, true));
|
||||||
|
|
||||||
|
assert_eq!(SUB_A, (3, false));
|
||||||
|
assert_eq!(SUB_B, (u32::max_value(), true));
|
||||||
|
|
||||||
|
assert_eq!(MUL_A, (10, false));
|
||||||
|
assert_eq!(MUL_B, (1410065408, true));
|
||||||
|
|
||||||
|
assert_eq!(SHL_A, (0x10, false));
|
||||||
|
assert_eq!(SHL_B, (0x10, true));
|
||||||
|
|
||||||
|
assert_eq!(SHR_A, (0x1, false));
|
||||||
|
assert_eq!(SHR_B, (0x1, true));
|
||||||
|
}
|
19
src/test/run-pass/const-int-rotate.rs
Normal file
19
src/test/run-pass/const-int-rotate.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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 main() {
|
||||||
|
assert_eq!(LEFT, 0xb301);
|
||||||
|
assert_eq!(RIGHT, 0x10000b3);
|
||||||
|
}
|
23
src/test/run-pass/const-int-sign.rs
Normal file
23
src/test/run-pass/const-int-sign.rs
Normal file
@ -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);
|
||||||
|
}
|
43
src/test/run-pass/const-int-wrapping.rs
Normal file
43
src/test/run-pass/const-int-wrapping.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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 main() {
|
||||||
|
assert_eq!(ADD_A, 255);
|
||||||
|
assert_eq!(ADD_B, 199);
|
||||||
|
|
||||||
|
assert_eq!(SUB_A, 0);
|
||||||
|
assert_eq!(SUB_B, 101);
|
||||||
|
|
||||||
|
assert_eq!(MUL_A, 120);
|
||||||
|
assert_eq!(MUL_B, 44);
|
||||||
|
|
||||||
|
assert_eq!(SHL_A, 128);
|
||||||
|
assert_eq!(SHL_B, 1);
|
||||||
|
|
||||||
|
assert_eq!(SHR_A, 1);
|
||||||
|
assert_eq!(SHR_B, 128);
|
||||||
|
}
|
28
src/test/ui/consts/const-int-conversion.rs
Normal file
28
src/test/ui/consts/const-int-conversion.rs
Normal file
@ -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
|
||||||
|
}
|
80
src/test/ui/consts/const-int-conversion.stderr
Normal file
80
src/test/ui/consts/const-int-conversion.stderr
Normal file
@ -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`.
|
15
src/test/ui/consts/const-int-overflowing.rs
Normal file
15
src/test/ui/consts/const-int-overflowing.rs
Normal file
@ -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
|
||||||
|
}
|
35
src/test/ui/consts/const-int-overflowing.stderr
Normal file
35
src/test/ui/consts/const-int-overflowing.stderr
Normal file
@ -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`.
|
14
src/test/ui/consts/const-int-rotate.rs
Normal file
14
src/test/ui/consts/const-int-rotate.rs
Normal file
@ -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
|
||||||
|
}
|
24
src/test/ui/consts/const-int-rotate.stderr
Normal file
24
src/test/ui/consts/const-int-rotate.stderr
Normal file
@ -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`.
|
14
src/test/ui/consts/const-int-sign.rs
Normal file
14
src/test/ui/consts/const-int-sign.rs
Normal file
@ -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
|
||||||
|
}
|
24
src/test/ui/consts/const-int-sign.stderr
Normal file
24
src/test/ui/consts/const-int-sign.stderr
Normal file
@ -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`.
|
17
src/test/ui/consts/const-int-wrapping.rs
Normal file
17
src/test/ui/consts/const-int-wrapping.rs
Normal file
@ -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
|
||||||
|
}
|
57
src/test/ui/consts/const-int-wrapping.stderr
Normal file
57
src/test/ui/consts/const-int-wrapping.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user