about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-07 11:36:57 +0000
committerbors <bors@rust-lang.org>2015-12-07 11:36:57 +0000
commit4dbdfb493357427a0f94ce09badef581f5d62bbd (patch)
tree18cc48159fad29fd2eaac7bf4a7c2ea4a56b507e /src/test
parent7b77f67d1942620d550f0067c92d781c623aef58 (diff)
parentbaa8ce7efdb84022809644c0bd5fed8ef476829e (diff)
downloadrust-4dbdfb493357427a0f94ce09badef581f5d62bbd.tar.gz
rust-4dbdfb493357427a0f94ce09badef581f5d62bbd.zip
Auto merge of #30202 - oli-obk:fix/const_index_feature_gate, r=Aatch
see https://github.com/rust-lang/rust/issues/29947#issuecomment-161781257

I also added some missing tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/const-index-feature-gate.rs15
-rw-r--r--src/test/compile-fail/lint-exceeding-bitshifts.rs5
-rw-r--r--src/test/run-pass/check_const-feature-gated.rs15
3 files changed, 34 insertions, 1 deletions
diff --git a/src/test/compile-fail/const-index-feature-gate.rs b/src/test/compile-fail/const-index-feature-gate.rs
new file mode 100644
index 00000000000..09822e46cc1
--- /dev/null
+++ b/src/test/compile-fail/const-index-feature-gate.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 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.
+
+const ARR: [usize; 1] = [2];
+const ARR2: [i32; ARR[0]] = [5, 6]; //~ ERROR unstable
+
+fn main() {
+}
diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs
index 160551b81cb..ce1406e8010 100644
--- a/src/test/compile-fail/lint-exceeding-bitshifts.rs
+++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs
@@ -11,7 +11,7 @@
 #![deny(exceeding_bitshifts)]
 #![allow(unused_variables)]
 #![allow(dead_code)]
-#![feature(num_bits_bytes)]
+#![feature(num_bits_bytes, const_indexing)]
 
 fn main() {
       let n = 1u8 << 7;
@@ -62,4 +62,7 @@ fn main() {
 
 
       let n = 1i8<<(1isize+-1);
+
+      let n = 1i64 >> [63][0];
+      let n = 1i64 >> [64][0]; //~ ERROR: bitshift exceeds the type's number of bits
 }
diff --git a/src/test/run-pass/check_const-feature-gated.rs b/src/test/run-pass/check_const-feature-gated.rs
new file mode 100644
index 00000000000..ae27b76c747
--- /dev/null
+++ b/src/test/run-pass/check_const-feature-gated.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 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.
+
+const ARR: [usize; 1] = [2];
+
+fn main() {
+    let _ = 5 << ARR[0];
+}