From 75e34ac476664937c249c99127517e5cfdccd21d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 Jul 2018 11:31:14 -0700 Subject: [PATCH] rustc: Stabilize #[wasm_import_module] This commit stabilizes the `#[wasm_import_module]` attribute. Tracked by #52090 this issue can be attached to foreign modules (`extern { ... }` blocks) and is used to configured the module name that the imports are listed with. The WebAssembly specification indicates two utf-8 names are associated with all imported items, one for the module the item comes from and one for the item itself. The item itself is configurable in Rust via its identifier or `#[link_name = "..."]`, but the module name was previously not configurable and defaulted to `"env"`. This commit ensures that this is also configurable. Closes #52090 --- src/libsyntax/feature_gate.rs | 10 +++------- src/test/run-make/wasm-import-module/bar.rs | 1 - src/test/run-make/wasm-import-module/foo.rs | 1 - src/test/ui/feature-gate-wasm_import_module.rs | 15 --------------- .../ui/feature-gate-wasm_import_module.stderr | 11 ----------- src/test/ui/wasm-import-module.rs | 2 +- 6 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 src/test/ui/feature-gate-wasm_import_module.rs delete mode 100644 src/test/ui/feature-gate-wasm_import_module.stderr diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f033c5006c53a..2ef04083fc159 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -420,9 +420,6 @@ declare_features! ( // The #[wasm_custom_section] attribute (active, wasm_custom_section, "1.26.0", Some(51088), None), - // The #![wasm_import_module] attribute - (active, wasm_import_module, "1.26.0", Some(52090), None), - // Allows keywords to be escaped for use as identifiers (active, raw_identifiers, "1.26.0", Some(48589), None), @@ -626,6 +623,8 @@ declare_features! ( (accepted, global_allocator, "1.28.0", Some(27389), None), // Allows `#[repr(transparent)]` attribute on newtype structs (accepted, repr_transparent, "1.28.0", Some(43036), None), + // The #![wasm_import_module] attribute + (accepted, wasm_import_module, "1.29.0", Some(52090), None), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -980,10 +979,7 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "the `#[no_debug]` attribute was an experimental feature that has been \ deprecated due to lack of demand", cfg_fn!(no_debug))), - ("wasm_import_module", Normal, Gated(Stability::Unstable, - "wasm_import_module", - "experimental attribute", - cfg_fn!(wasm_import_module))), + ("wasm_import_module", Normal, Ungated), ("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable, "omit_gdb_pretty_printer_section", "the `#[omit_gdb_pretty_printer_section]` \ diff --git a/src/test/run-make/wasm-import-module/bar.rs b/src/test/run-make/wasm-import-module/bar.rs index 9e659223c651c..603ed01b37075 100644 --- a/src/test/run-make/wasm-import-module/bar.rs +++ b/src/test/run-make/wasm-import-module/bar.rs @@ -9,7 +9,6 @@ // except according to those terms. #![crate_type = "cdylib"] -#![feature(wasm_import_module)] #![deny(warnings)] extern crate foo; diff --git a/src/test/run-make/wasm-import-module/foo.rs b/src/test/run-make/wasm-import-module/foo.rs index bcd2ca70befaa..1111ab16bee63 100644 --- a/src/test/run-make/wasm-import-module/foo.rs +++ b/src/test/run-make/wasm-import-module/foo.rs @@ -9,7 +9,6 @@ // except according to those terms. #![crate_type = "rlib"] -#![feature(wasm_import_module)] #![deny(warnings)] #[wasm_import_module = "./dep"] diff --git a/src/test/ui/feature-gate-wasm_import_module.rs b/src/test/ui/feature-gate-wasm_import_module.rs deleted file mode 100644 index c5898a9c12697..0000000000000 --- a/src/test/ui/feature-gate-wasm_import_module.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2018 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. - -#[wasm_import_module = "test"] //~ ERROR: experimental -extern { -} - -fn main() {} diff --git a/src/test/ui/feature-gate-wasm_import_module.stderr b/src/test/ui/feature-gate-wasm_import_module.stderr deleted file mode 100644 index 5430f6b5825eb..0000000000000 --- a/src/test/ui/feature-gate-wasm_import_module.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: experimental attribute (see issue #52090) - --> $DIR/feature-gate-wasm_import_module.rs:11:1 - | -LL | #[wasm_import_module = "test"] //~ ERROR: experimental - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(wasm_import_module)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/wasm-import-module.rs b/src/test/ui/wasm-import-module.rs index 0b743d9e486b6..b097b543de658 100644 --- a/src/test/ui/wasm-import-module.rs +++ b/src/test/ui/wasm-import-module.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(wasm_import_module)] + #[wasm_import_module] //~ ERROR: must be of the form extern {}