From 8cdad627ae11d2b0f4a222c5db743b2030cda091 Mon Sep 17 00:00:00 2001 From: Steffen Date: Mon, 11 Jan 2016 23:45:33 +0100 Subject: [PATCH] add feature gate "abi_vectorcall" for the vectorcall calling convention --- src/doc/book/ffi.md | 1 + src/doc/reference.md | 3 +++ src/libsyntax/feature_gate.rs | 24 +++++++++++++++---- .../feature-gate-abi-vectorcall.rs | 19 +++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/test/compile-fail/feature-gate-abi-vectorcall.rs diff --git a/src/doc/book/ffi.md b/src/doc/book/ffi.md index e4a67112f18..c00e6c0a070 100644 --- a/src/doc/book/ffi.md +++ b/src/doc/book/ffi.md @@ -479,6 +479,7 @@ are: * `cdecl` * `fastcall` * `vectorcall` +This is currently hidden behind the `abi_vectorcall` gate and is subject to change. * `Rust` * `rust-intrinsic` * `system` diff --git a/src/doc/reference.md b/src/doc/reference.md index e7cc1436824..1daf42d293d 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2390,6 +2390,9 @@ The currently implemented features of the reference compiler are: * - `type_ascription` - Allows type ascription expressions `expr: Type`. +* - `abi_vectorcall` - Allows the usage of the vectorcall calling convention + (e.g. `extern "vectorcall" func fn_();`) + If a feature is promoted to a language feature, then all existing programs will start to receive compilation warnings about `#![feature]` directives which enabled the new feature (because the directive is no longer necessary). However, if a diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4ea0fd76fea..c168ea9ad75 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -239,6 +239,9 @@ // Allows cfg(target_thread_local) ("cfg_target_thread_local", "1.7.0", Some(29594), Active), + + // rustc internal + ("abi_vectorcall", "1.7.0", None, Active) ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -862,6 +865,11 @@ fn visit_item(&mut self, i: &ast::Item) { Abi::PlatformIntrinsic => { Some(("platform_intrinsics", "platform intrinsics are experimental and possibly buggy")) + }, + Abi::Vectorcall => { + Some(("abi_vectorcall", + "vectorcall is experimental and subject to change" + )) } _ => None }; @@ -1033,11 +1041,17 @@ fn visit_fn(&mut self, "intrinsics are subject to change") } FnKind::ItemFn(_, _, _, _, abi, _) | - FnKind::Method(_, &ast::MethodSig { abi, .. }, _) if abi == Abi::RustCall => { - self.gate_feature("unboxed_closures", - span, - "rust-call ABI is subject to change") - } + FnKind::Method(_, &ast::MethodSig { abi, .. }, _) => match abi { + Abi::RustCall => { + self.gate_feature("unboxed_closures", span, + "rust-call ABI is subject to change"); + }, + Abi::Vectorcall => { + self.gate_feature("abi_vectorcall", span, + "vectorcall is experimental and subject to change"); + }, + _ => {} + }, _ => {} } visit::walk_fn(self, fn_kind, fn_decl, block, span); diff --git a/src/test/compile-fail/feature-gate-abi-vectorcall.rs b/src/test/compile-fail/feature-gate-abi-vectorcall.rs new file mode 100644 index 00000000000..79f3c8dc776 --- /dev/null +++ b/src/test/compile-fail/feature-gate-abi-vectorcall.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern "vectorcall" { //~ ERROR vectorcall is experimental and subject to change + fn bar(); +} + +extern "vectorcall" fn baz() { //~ ERROR vectorcall is experimental and subject to change +} + +fn main() { +} -- GitLab