diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index ef68b2f76b07f..550f6eb12a7bd 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1480,6 +1480,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) s)); } }; + if kind == cstore::NativeStaticNobundle && !nightly_options::is_nightly_build() { + early_error(error_format, &format!("the library kind 'static-nobundle' is only \ + accepted on the nightly compiler")); + } let mut name_parts = name.splitn(2, ':'); let name = name_parts.next().unwrap(); let new_name = name_parts.next(); diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index d9c64d3e7b343..87ba2edbfda7d 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -111,6 +111,13 @@ fn register_native_lib(sess: &Session, GateIssue::Language, "is feature gated"); } + if lib.kind == cstore::NativeStaticNobundle && !sess.features.borrow().static_nobundle { + feature_gate::emit_feature_err(&sess.parse_sess, + "static_nobundle", + span.unwrap(), + GateIssue::Language, + "kind=\"static-nobundle\" is feature gated"); + } cstore.add_used_library(lib); } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 924f51fd95251..cf2905e913108 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -322,6 +322,9 @@ declare_features! ( // Allows attributes on struct literal fields. (active, struct_field_attributes, "1.16.0", Some(38814)), + // Allows #[link(kind="static-nobundle"...] + (active, static_nobundle, "1.16.0", Some(37403)), + // `extern "msp430-interrupt" fn()` (active, abi_msp430_interrupt, "1.16.0", Some(38487)), ); diff --git a/src/test/compile-fail/feature-gate-static-nobundle.rs b/src/test/compile-fail/feature-gate-static-nobundle.rs new file mode 100644 index 0000000000000..bc0025c7c9581 --- /dev/null +++ b/src/test/compile-fail/feature-gate-static-nobundle.rs @@ -0,0 +1,13 @@ +// 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. + +#[link(name="foo", kind="static-nobundle")] +//~^ ERROR: kind="static-nobundle" is feature gated +extern {} diff --git a/src/test/run-make/static-nobundle/bar.rs b/src/test/run-make/static-nobundle/bar.rs index e14b5a669f440..c5d6237c9d594 100644 --- a/src/test/run-make/static-nobundle/bar.rs +++ b/src/test/run-make/static-nobundle/bar.rs @@ -9,6 +9,7 @@ // except according to those terms. #![crate_type = "rlib"] +#![feature(static_nobundle)] #[link(name = "foo", kind = "static-nobundle")] extern {