Skip to content

Commit

Permalink
Feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimcn committed Jan 19, 2017
1 parent 91f8144 commit 3ae2174
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_metadata/creader.rs
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -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)),
);
Expand Down
13 changes: 13 additions & 0 deletions 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 <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 {}
1 change: 1 addition & 0 deletions src/test/run-make/static-nobundle/bar.rs
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![crate_type = "rlib"]
#![feature(static_nobundle)]

#[link(name = "foo", kind = "static-nobundle")]
extern {
Expand Down

0 comments on commit 3ae2174

Please sign in to comment.