about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-09-10 14:03:20 +0200
committerGitHub <noreply@github.com>2017-09-10 14:03:20 +0200
commit9af7de1cb842987e97677fdede4f538750ce8fa9 (patch)
tree9ffe1bebd47a1f736a37f44f0ab2f189ffebd54d
parent34035d23ff5acd9bd08602bfab5d667450243966 (diff)
parent51a478c90b31c1b2248a1d24fa933c570048593c (diff)
downloadrust-9af7de1cb842987e97677fdede4f538750ce8fa9.tar.gz
rust-9af7de1cb842987e97677fdede4f538750ce8fa9.zip
Rollup merge of #44262 - alexcrichton:repr-128-gate, r=nikomatsakis
rustc: Separately feature gate repr(i128)

Brought up during the discussion of #35118, the support for this is still
somewhat buggy and so stabilization likely wants to be considered independently
of the type itself.
-rw-r--r--src/librustc_typeck/check/mod.rs7
-rw-r--r--src/libsyntax/feature_gate.rs3
-rw-r--r--src/test/compile-fail/feature-gate-repr128.rs17
3 files changed, 25 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0a8d2129a89..8ddfb5b3050 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -1554,9 +1554,12 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     let repr_type_ty = def.repr.discr_type().to_ty(tcx);
     if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
-        if !tcx.sess.features.borrow().i128_type {
+        if !tcx.sess.features.borrow().repr128 {
             emit_feature_err(&tcx.sess.parse_sess,
-                             "i128_type", sp, GateIssue::Language, "128-bit type is unstable");
+                             "repr128",
+                             sp,
+                             GateIssue::Language,
+                             "repr with 128-bit type is unstable");
         }
     }
 
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 54d41a030fd..e9e9c6bf4ea 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -312,6 +312,9 @@ declare_features! (
     // The `i128` type
     (active, i128_type, "1.16.0", Some(35118)),
 
+    // The `repr(i128)` annotation for enums
+    (active, repr128, "1.16.0", Some(35118)),
+
     // The `unadjusted` ABI. Perma unstable.
     (active, abi_unadjusted, "1.16.0", None),
 
diff --git a/src/test/compile-fail/feature-gate-repr128.rs b/src/test/compile-fail/feature-gate-repr128.rs
new file mode 100644
index 00000000000..96fffa6cdd0
--- /dev/null
+++ b/src/test/compile-fail/feature-gate-repr128.rs
@@ -0,0 +1,17 @@
+// Copyright 2016 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.
+
+#[repr(u128)]
+enum A { //~ ERROR repr with 128-bit type is unstable
+    //~| HELP: add #![feature(repr128)]
+    A(u64)
+}
+
+fn main() {}