Feature gate

This commit is contained in:
Vadim Chugunov 2016-12-15 23:46:21 -08:00
parent 91f8144906
commit 3ae2174fc5
5 changed files with 28 additions and 0 deletions

View file

@ -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();

View file

@ -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);
}

View file

@ -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)),
);

View file

@ -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 <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.
#[link(name="foo", kind="static-nobundle")]
//~^ ERROR: kind="static-nobundle" is feature gated
extern {}

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![crate_type = "rlib"]
#![feature(static_nobundle)]
#[link(name = "foo", kind = "static-nobundle")]
extern {