Skip to content
Permalink
Browse files

Add feature gate for raw_dylib.

  • Loading branch information...
crlf0710 committed Aug 27, 2019
1 parent 7e0afda commit d783ca3f5ff4f84fdf45f21357b7892704ab1704
@@ -96,6 +96,8 @@ pub enum NativeLibraryKind {
NativeStaticNobundle,
/// macOS-specific
NativeFramework,
/// windows dynamic library without import library
NativeRawDylib,
/// default way to specify a dynamic library
NativeUnknown,
}
@@ -263,7 +263,11 @@ pub fn provide(providers: &mut Providers<'_>) {
// resolve! Does this work? Unsure! That's what the issue is about
*providers = Providers {
is_dllimport_foreign_item: |tcx, id| {
tcx.native_library_kind(id) == Some(NativeLibraryKind::NativeUnknown)
match tcx.native_library_kind(id) {
Some(NativeLibraryKind::NativeUnknown) |
Some(NativeLibraryKind::NativeRawDylib) => true,
_ => false,
}
},
is_statically_included_foreign_item: |tcx, id| {
match tcx.native_library_kind(id) {
@@ -73,6 +73,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
"static-nobundle" => cstore::NativeStaticNobundle,
"dylib" => cstore::NativeUnknown,
"framework" => cstore::NativeFramework,
"raw-dylib" => cstore::NativeRawDylib,
k => {
struct_span_err!(self.tcx.sess, item.span(), E0458,
"unknown kind: `{}`", k)
@@ -169,6 +170,14 @@ impl Collector<'tcx> {
GateIssue::Language,
"kind=\"static-nobundle\" is feature gated");
}
if lib.kind == cstore::NativeRawDylib &&
!self.tcx.features().raw_dylib {
feature_gate::emit_feature_err(&self.tcx.sess.parse_sess,
sym::raw_dylib,
span.unwrap_or_else(|| syntax_pos::DUMMY_SP),
GateIssue::Language,
"kind=\"raw-dylib\" is feature gated");
}
self.libs.push(lib);
}

@@ -532,6 +532,12 @@ declare_features! (
/// Allows the use of or-patterns, e.g. `0 | 1`.
(active, or_patterns, "1.38.0", Some(54883), None),

// Allows the use of raw-dylibs (RFC 2627).
(active, raw_dylib, "1.39.0", Some(58713), None),

// Allows the use of link ordinal for raw-dylibs (RFC 2627).
(active, link_ordinal, "1.39.0", Some(58713), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
@@ -275,6 +275,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
"the `link_args` attribute is experimental and not portable across platforms, \
it is recommended to use `#[link(name = \"foo\")] instead",
),
gated!(link_ordinal, Whitelisted, template!(Word), experimental!(link_ordinal)),

// Plugins:
ungated!(plugin_registrar, Normal, template!(Word)),
@@ -387,6 +387,7 @@ symbols! {
link_cfg,
link_llvm_intrinsics,
link_name,
link_ordinal,
link_section,
LintPass,
lint_reasons,
@@ -529,6 +530,7 @@ symbols! {
RangeInclusive,
RangeTo,
RangeToInclusive,
raw_dylib,
raw_identifiers,
Ready,
reason,
@@ -0,0 +1,5 @@
#[link(name="foo", kind="raw-dylib")]
//~^ ERROR: kind="raw-dylib" is feature gated
extern {}

fn main() {}
@@ -0,0 +1,12 @@
error[E0658]: kind="raw-dylib" is feature gated
--> $DIR/feature-gate-raw-dylib.rs:1:1
|
LL | #[link(name="foo", kind="raw-dylib")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/58713
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

0 comments on commit d783ca3

Please sign in to comment.
You can’t perform that action at this time.