wasm-bindgen-macro-0.2.87/Cargo.toml0000644000000026530000000000100126100ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" rust-version = "1.56" name = "wasm-bindgen-macro" version = "0.2.87" authors = ["The wasm-bindgen Developers"] description = """ Definition of the `#[wasm_bindgen]` attribute, an internal dependency """ homepage = "https://rustwasm.github.io/wasm-bindgen/" documentation = "https://docs.rs/wasm-bindgen" readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro" resolver = "2" [lib] proc-macro = true [dependencies.quote] version = "1.0" [dependencies.wasm-bindgen-macro-support] version = "=0.2.87" [dev-dependencies.trybuild] version = "1.0" [dev-dependencies.wasm-bindgen] version = "0.2.87" [dev-dependencies.wasm-bindgen-futures] version = "0.4.37" [dev-dependencies.web-sys] version = "0.3.64" features = ["Worker"] [features] spans = ["wasm-bindgen-macro-support/spans"] strict-macro = ["wasm-bindgen-macro-support/strict-macro"] xxx_debug_only_print_generated_code = [] wasm-bindgen-macro-0.2.87/Cargo.toml.orig000064400000000000000000000017061046102023000162670ustar 00000000000000[package] name = "wasm-bindgen-macro" version = "0.2.87" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro" homepage = "https://rustwasm.github.io/wasm-bindgen/" documentation = "https://docs.rs/wasm-bindgen" description = """ Definition of the `#[wasm_bindgen]` attribute, an internal dependency """ edition = "2018" rust-version = "1.56" [lib] proc-macro = true [features] spans = ["wasm-bindgen-macro-support/spans"] xxx_debug_only_print_generated_code = [] strict-macro = ["wasm-bindgen-macro-support/strict-macro"] [dependencies] wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.87" } quote = "1.0" [dev-dependencies] trybuild = "1.0" wasm-bindgen = { path = "../..", version = "0.2.87" } wasm-bindgen-futures = { path = "../futures", version = "0.4.37" } web-sys = { path = "../web-sys", version = "0.3.64", features = ["Worker"] } wasm-bindgen-macro-0.2.87/LICENSE-APACHE000064400000000000000000000251371046102023000153300ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. wasm-bindgen-macro-0.2.87/LICENSE-MIT000064400000000000000000000020411046102023000150250ustar 00000000000000Copyright (c) 2014 Alex Crichton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. wasm-bindgen-macro-0.2.87/README.md000064400000000000000000000022201046102023000146470ustar 00000000000000# `wasm-bindgen-macro` Implementation of the `#[wasm_bindgen]` attribute. See the `wasm-bindgen` documentation for more information about what this macro does. ## Testing Testing of this macro is done through "ui tests" in the `ui-tests` subdirectory of this crate. Each Rust file in this folder is compiled with the `wasm_bindgen` crate, and the `*.stderr` file sitting next to it is the asserted output of the compiler. If the output matches, the test passes, and if the output doesn't match the test fails. Note that it is also considered a failure if a test actually compiles successfully. To add a test: * Create `ui-tests/my-awesome-test.rs` * Write an invalid `#[wasm_bindgen]` invocation, testing the error you're generating * Execute `cargo test -p ui-tests`, the test will fail * From within the `ui-tests` folder, execute `./update-all-references.sh`. This should create a `my-awesome-test.stderr` file. * Inspect `my-awesome-test.stderr` to make sure it looks ok * Rerun `cargo test -p ui-tests` and your tests should pass! Testing here is a work in progress, see [#601](https://github.com/rustwasm/wasm-bindgen/issues/601) for more information. wasm-bindgen-macro-0.2.87/src/lib.rs000064400000000000000000000041761046102023000153070ustar 00000000000000#![doc(html_root_url = "https://docs.rs/wasm-bindgen-macro/0.2")] extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; #[proc_macro_attribute] pub fn wasm_bindgen(attr: TokenStream, input: TokenStream) -> TokenStream { match wasm_bindgen_macro_support::expand(attr.into(), input.into()) { Ok(tokens) => { if cfg!(feature = "xxx_debug_only_print_generated_code") { println!("{}", tokens); } tokens.into() } Err(diagnostic) => (quote! { #diagnostic }).into(), } } /// This macro takes a JS module as input and returns a URL that can be used to /// access it at runtime. /// /// The module can be specified in a few ways: /// - You can use `inline_js = "..."` to create an inline JS file. /// - You can use `module = "/foo/bar"` to reference a file relative to the /// root of the crate the macro is invoked in. /// /// The returned URL can be used for things like creating workers/worklets: /// ```no_run /// use web_sys::Worker; /// let worker = Worker::new(&wasm_bindgen::link_to!(module = "/src/worker.js")); /// ``` #[proc_macro] pub fn link_to(input: TokenStream) -> TokenStream { match wasm_bindgen_macro_support::expand_link_to(input.into()) { Ok(tokens) => { if cfg!(feature = "xxx_debug_only_print_generated_code") { println!("{}", tokens); } tokens.into() } // This `String::clone` is here so that IDEs know this is supposed to be a // `String` and can keep type-checking the rest of the program even if the macro // fails. Err(diagnostic) => (quote! { String::clone(#diagnostic) }).into(), } } #[proc_macro_attribute] pub fn __wasm_bindgen_class_marker(attr: TokenStream, input: TokenStream) -> TokenStream { match wasm_bindgen_macro_support::expand_class_marker(attr.into(), input.into()) { Ok(tokens) => { if cfg!(feature = "xxx_debug_only_print_generated_code") { println!("{}", tokens); } tokens.into() } Err(diagnostic) => (quote! { #diagnostic }).into(), } } wasm-bindgen-macro-0.2.87/src/worker.js000064400000000000000000000000741046102023000160330ustar 00000000000000// This file is needed for the doctest of `crate::link_to`. wasm-bindgen-macro-0.2.87/tests/ui.rs000064400000000000000000000001411046102023000155150ustar 00000000000000#[test] fn ui() { let t = trybuild::TestCases::new(); t.compile_fail("ui-tests/*.rs"); } wasm-bindgen-macro-0.2.87/ui-tests/async-errors.rs000064400000000000000000000020621046102023000201460ustar 00000000000000#![allow(unreachable_code)] use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct MyType; #[wasm_bindgen] pub async fn good1() { loop {} } #[wasm_bindgen] pub async fn good2() -> JsValue { loop {} } #[wasm_bindgen] pub async fn good3() -> u32 { loop {} } #[wasm_bindgen] pub async fn good4() -> MyType { loop {} } #[wasm_bindgen] pub async fn good5() -> Result<(), JsValue> { loop {} } #[wasm_bindgen] pub async fn good6() -> Result { loop {} } #[wasm_bindgen] pub async fn good7() -> Result { loop {} } #[wasm_bindgen] pub async fn good8() -> Result { loop {} } #[wasm_bindgen] pub async fn good9() -> Result { loop {} } #[wasm_bindgen] pub async fn good10() -> Result { loop {} } pub struct BadType; #[wasm_bindgen] pub async fn bad1() -> Result<(), ()> { loop {} } #[wasm_bindgen] pub async fn bad2() -> Result<(), BadType> { loop {} } #[wasm_bindgen] pub async fn bad3() -> BadType { loop {} } #[wasm_bindgen] pub async fn bad4() -> Result { loop {} } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/async-errors.stderr000064400000000000000000000050051046102023000210250ustar 00000000000000error[E0277]: the trait bound `Result<(), ()>: IntoJsResult` is not satisfied --> ui-tests/async-errors.rs:30:1 | 30 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), ()>` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result<(), BadType>: IntoJsResult` is not satisfied --> ui-tests/async-errors.rs:32:1 | 32 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), BadType>` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `wasm_bindgen::JsValue: From` is not satisfied --> ui-tests/async-errors.rs:34:1 | 34 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `From` is not implemented for `wasm_bindgen::JsValue` | = help: the following other types implement trait `From`: > > > > > > > >> and 72 others = note: required for `BadType` to implement `Into` = note: required for `BadType` to implement `IntoJsResult` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: IntoJsResult` is not satisfied --> ui-tests/async-errors.rs:36:1 | 36 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) wasm-bindgen-macro-0.2.87/ui-tests/attribute-fails-to-parse.rs000064400000000000000000000001271046102023000223460ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(nonsense)] pub fn foo() {} fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/attribute-fails-to-parse.stderr000064400000000000000000000002021046102023000232170ustar 00000000000000error: unknown attribute --> $DIR/attribute-fails-to-parse.rs:3:16 | 3 | #[wasm_bindgen(nonsense)] | ^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/bad-signatures.rs000064400000000000000000000002451046102023000204300ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn foo() -> &u32 {} #[wasm_bindgen] extern "C" { fn foo(Foo(x): Foo); fn foo() -> &u32; } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/bad-signatures.stderr000064400000000000000000000007111046102023000213050ustar 00000000000000error: cannot return a borrowed ref with #[wasm_bindgen] --> $DIR/bad-signatures.rs:4:17 | 4 | pub fn foo() -> &u32 {} | ^^^^ error: unsupported pattern in #[wasm_bindgen] imported function --> $DIR/bad-signatures.rs:8:12 | 8 | fn foo(Foo(x): Foo); | ^^^^^^ error: cannot return references in #[wasm_bindgen] imports yet --> $DIR/bad-signatures.rs:10:17 | 10 | fn foo() -> &u32; | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/import-local.rs000064400000000000000000000002541046102023000201220ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "./foo.js")] extern { fn wut(); } #[wasm_bindgen(module = "../foo.js")] extern { fn wut2(); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/import-local.stderr000064400000000000000000000005151046102023000210010ustar 00000000000000error: relative module paths aren't supported yet --> $DIR/import-local.rs:3:25 | 3 | #[wasm_bindgen(module = "./foo.js")] | ^^^^^^^^^^ error: relative module paths aren't supported yet --> $DIR/import-local.rs:8:25 | 8 | #[wasm_bindgen(module = "../foo.js")] | ^^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/invalid-attr.rs000064400000000000000000000002751046102023000201210ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(x)] pub fn foo() {} #[wasm_bindgen] extern "C" { #[wasm_bindgen(y)] fn bar(); #[wasm_bindgen { }] fn bar(); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-attr.stderr000064400000000000000000000005461046102023000210010ustar 00000000000000error: unknown attribute --> $DIR/invalid-attr.rs:3:16 | 3 | #[wasm_bindgen(x)] | ^ error: unknown attribute --> $DIR/invalid-attr.rs:8:20 | 8 | #[wasm_bindgen(y)] | ^ error: malformed #[wasm_bindgen] attribute --> $DIR/invalid-attr.rs:11:5 | 11 | #[wasm_bindgen { }] | ^^^^^^^^^^^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/invalid-enums.rs000064400000000000000000000003261046102023000202730ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] enum A {} #[wasm_bindgen] pub enum B { D(u32), } #[wasm_bindgen] pub enum C { X = 1 + 3, } #[wasm_bindgen] pub enum D { X = 4294967296, } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-enums.stderr000064400000000000000000000010461046102023000211520ustar 00000000000000error: cannot export empty enums to JS --> $DIR/invalid-enums.rs:4:1 | 4 | enum A {} | ^^^^^^^^^ error: only C-Style enums allowed with #[wasm_bindgen] --> $DIR/invalid-enums.rs:8:6 | 8 | D(u32), | ^^^^^ error: enums with #[wasm_bindgen] may only have number literal values --> $DIR/invalid-enums.rs:13:9 | 13 | X = 1 + 3, | ^^^^^ error: enums with #[wasm_bindgen] can only support numbers that can be represented as u32 --> $DIR/invalid-enums.rs:18:9 | 18 | X = 4294967296, | ^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/invalid-imports.rs000064400000000000000000000014561046102023000206460ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { type A; fn f() -> &'static u32; #[wasm_bindgen(method)] fn f1(); #[wasm_bindgen(method)] fn f2(x: u32); #[wasm_bindgen(method)] fn f3(x: &&u32); #[wasm_bindgen(method)] fn f4(x: &foo::Bar); #[wasm_bindgen(method)] fn f4(x: &::Bar); #[wasm_bindgen(method)] fn f4(x: &Bar); #[wasm_bindgen(method)] fn f4(x: &dyn Fn(T)); #[wasm_bindgen(constructor)] fn f(); #[wasm_bindgen(constructor)] fn f() -> ::Bar; #[wasm_bindgen(constructor)] fn f() -> &Bar; #[wasm_bindgen(catch)] fn f() -> u32; #[wasm_bindgen(catch)] fn f() -> &u32; #[wasm_bindgen(catch)] fn f() -> Result<>; #[wasm_bindgen(catch)] fn f() -> Result<'a>; } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-imports.stderr000064400000000000000000000033411046102023000215200ustar 00000000000000error: it is currently not sound to use lifetimes in function signatures --> ui-tests/invalid-imports.rs:7:16 | 7 | fn f() -> &'static u32; | ^^^^^^^ error: imported methods must have at least one argument --> ui-tests/invalid-imports.rs:10:5 | 10 | fn f1(); | ^^^^^^^^ error: first argument of method must be a shared reference --> ui-tests/invalid-imports.rs:12:14 | 12 | fn f2(x: u32); | ^^^ error: first argument of method must be a path --> ui-tests/invalid-imports.rs:14:15 | 14 | fn f3(x: &&u32); | ^^^^ error: paths with type parameters are not supported yet --> ui-tests/invalid-imports.rs:20:15 | 20 | fn f4(x: &Bar); | ^^^^^^ error: first argument of method must be a path --> ui-tests/invalid-imports.rs:22:15 | 22 | fn f4(x: &dyn Fn(T)); | ^^^^^^^^^ error: constructor returns must be bare types --> ui-tests/invalid-imports.rs:25:5 | 25 | fn f(); | ^^^^^^^ error: return value of constructor must be a bare path --> ui-tests/invalid-imports.rs:29:5 | 29 | fn f() -> &Bar; | ^^^^^^^^^^^^^^^ error: must be Result<...> --> ui-tests/invalid-imports.rs:32:15 | 32 | fn f() -> u32; | ^^^ error: must be Result<...> --> ui-tests/invalid-imports.rs:34:15 | 34 | fn f() -> &u32; | ^^^^ error: must have at least one generic parameter --> ui-tests/invalid-imports.rs:36:15 | 36 | fn f() -> Result<>; | ^^^^^^^^ error: it is currently not sound to use lifetimes in function signatures --> ui-tests/invalid-imports.rs:38:22 | 38 | fn f() -> Result<'a>; | ^^ wasm-bindgen-macro-0.2.87/ui-tests/invalid-items.rs000064400000000000000000000006371046102023000202720ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] fn foo() {} #[wasm_bindgen] pub const fn foo2() {} #[wasm_bindgen] struct Foo(T); #[wasm_bindgen] extern "C" { static mut FOO: u32; pub fn foo3(x: i32, ...); } #[wasm_bindgen] extern "system" { } #[wasm_bindgen] pub fn foo4() {} #[wasm_bindgen] pub fn foo5<'a>() {} #[wasm_bindgen] pub fn foo6<'a, T>() {} #[wasm_bindgen] trait X {} fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-items.stderr000064400000000000000000000027131046102023000211460ustar 00000000000000error: can only #[wasm_bindgen] public functions --> $DIR/invalid-items.rs:4:1 | 4 | fn foo() {} | ^^^^^^^^^^^ error: can only #[wasm_bindgen] non-const functions --> $DIR/invalid-items.rs:7:5 | 7 | pub const fn foo2() {} | ^^^^^ error: structs with #[wasm_bindgen] cannot have lifetime or type parameters currently --> $DIR/invalid-items.rs:10:11 | 10 | struct Foo(T); | ^^^ error: cannot import mutable globals yet --> $DIR/invalid-items.rs:14:12 | 14 | static mut FOO: u32; | ^^^ error: can't #[wasm_bindgen] variadic functions --> $DIR/invalid-items.rs:16:25 | 16 | pub fn foo3(x: i32, ...); | ^^^ error: only foreign mods with the `C` ABI are allowed --> $DIR/invalid-items.rs:20:8 | 20 | extern "system" { | ^^^^^^^^ error: can't #[wasm_bindgen] functions with lifetime or type parameters --> $DIR/invalid-items.rs:24:12 | 24 | pub fn foo4() {} | ^^^ error: can't #[wasm_bindgen] functions with lifetime or type parameters --> $DIR/invalid-items.rs:26:12 | 26 | pub fn foo5<'a>() {} | ^^^^ error: can't #[wasm_bindgen] functions with lifetime or type parameters --> $DIR/invalid-items.rs:28:12 | 28 | pub fn foo6<'a, T>() {} | ^^^^^^^ error: #[wasm_bindgen] can only be applied to a function, struct, enum, impl, or extern block --> $DIR/invalid-items.rs:31:1 | 31 | trait X {} | ^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/invalid-methods.rs000064400000000000000000000007571046102023000206170ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct A; #[wasm_bindgen] default impl A { } #[wasm_bindgen] unsafe impl A { } #[wasm_bindgen] impl Clone for A { } #[wasm_bindgen] impl A { } #[wasm_bindgen] impl &'static A { } macro_rules! x { () => () } #[wasm_bindgen] impl A { const X: u32 = 3; type Y = u32; x!(); // pub default fn foo() {} // TODO: compiler's pretty printer totally broken } #[wasm_bindgen] impl A { pub const fn foo() {} } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-methods.stderr000064400000000000000000000026501046102023000214700ustar 00000000000000error: #[wasm_bindgen] default impls are not supported --> ui-tests/invalid-methods.rs:7:1 | 7 | default impl A { | ^^^^^^^ error: #[wasm_bindgen] unsafe impls are not supported --> ui-tests/invalid-methods.rs:11:1 | 11 | unsafe impl A { | ^^^^^^ error: #[wasm_bindgen] trait impls are not supported --> ui-tests/invalid-methods.rs:15:6 | 15 | impl Clone for A { | ^^^^^ error: #[wasm_bindgen] generic impls aren't supported --> ui-tests/invalid-methods.rs:19:5 | 19 | impl A { | ^^^ error: unsupported self type in #[wasm_bindgen] impl --> ui-tests/invalid-methods.rs:23:6 | 23 | impl &'static A { | ^^^^^^^^^^ error: const definitions aren't supported with #[wasm_bindgen] --> ui-tests/invalid-methods.rs:30:5 | 30 | const X: u32 = 3; | ^^^^^^^^^^^^^^^^^ error: type definitions in impls aren't supported with #[wasm_bindgen] --> ui-tests/invalid-methods.rs:31:5 | 31 | type Y = u32; | ^^^^^^^^^^^^^ error: macros in impls aren't supported --> ui-tests/invalid-methods.rs:32:5 | 32 | x!(); | ^^^^^ error: can only #[wasm_bindgen] non-const functions --> ui-tests/invalid-methods.rs:39:9 | 39 | pub const fn foo() {} | ^^^^^ warning: unused macro definition: `x` --> ui-tests/invalid-methods.rs:26:14 | 26 | macro_rules! x { () => () } | ^ | = note: `#[warn(unused_macros)]` on by default wasm-bindgen-macro-0.2.87/ui-tests/invalid-setter.rs000064400000000000000000000004551046102023000204550ustar 00000000000000 use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { type A; #[wasm_bindgen(setter, method)] fn a(this: &A, b: i32); #[wasm_bindgen(setter = x, method)] fn b(this: &A, b: i32); #[wasm_bindgen(setter, method, js_name = x)] fn c(this: &A, b: i32); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/invalid-setter.stderr000064400000000000000000000002011046102023000213210ustar 00000000000000error: setters must start with `set_`, found: a --> $DIR/invalid-setter.rs:9:8 | 9 | fn a(this: &A, b: i32); | ^ wasm-bindgen-macro-0.2.87/ui-tests/link-to.rs000064400000000000000000000011601046102023000170720ustar 00000000000000fn good1() -> String { wasm_bindgen::link_to!(inline_js = "console.log('Hello world!');") } fn good2() -> String { wasm_bindgen::link_to!(raw_module = "./foo.js") } fn bad1() -> String { wasm_bindgen::link_to!(module = "package/foo.js") } fn bad2() -> String { wasm_bindgen::link_to!(raw_module = "package/foo.js") } fn bad3() -> String { wasm_bindgen::link_to!(module = "/src/not-found.js") } fn bad4() -> String { wasm_bindgen::link_to!() } fn bad5() -> String { wasm_bindgen::link_to!( inline_js = "console.log('Hello world!');", js_namespace = foo ) } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/link-to.stderr000064400000000000000000000021461046102023000177560ustar 00000000000000error: `link_to!` does not support module paths. --> ui-tests/link-to.rs:10:37 | 10 | wasm_bindgen::link_to!(module = "package/foo.js") | ^^^^^^^^^^^^^^^^ error: `link_to!` does not support module paths. --> ui-tests/link-to.rs:14:41 | 14 | wasm_bindgen::link_to!(raw_module = "package/foo.js") | ^^^^^^^^^^^^^^^^ error: failed to read file `$WORKSPACE/target/tests/trybuild/wasm-bindgen-macro/src/not-found.js`: No such file or directory (os error 2) --> ui-tests/link-to.rs:18:37 | 18 | wasm_bindgen::link_to!(module = "/src/not-found.js") | ^^^^^^^^^^^^^^^^^^^ error: `link_to!` requires a module. --> ui-tests/link-to.rs:22:5 | 22 | wasm_bindgen::link_to!() | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `wasm_bindgen::link_to` (in Nightly builds, run with -Z macro-backtrace for more info) error: unused wasm_bindgen attribute --> ui-tests/link-to.rs:28:9 | 28 | js_namespace = foo | ^^^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main-async.rs000064400000000000000000000001541046102023000175560ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] async fn main() {} #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main-async.stderr000064400000000000000000000001601046102023000204320ustar 00000000000000error: the main function has to be called main --> ui-tests/main-async.rs:7:4 | 7 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main-debug.rs000064400000000000000000000004501046102023000175260ustar 00000000000000use std::fmt; use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] fn main() -> Result<(), Test> { unimplemented!() } struct Test; impl fmt::Debug for Test { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { unimplemented!() } } #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main-debug.stderr000064400000000000000000000001651046102023000204100ustar 00000000000000error: the main function has to be called main --> ui-tests/main-debug.rs:18:4 | 18 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main-infallible.rs000064400000000000000000000002501046102023000205370ustar 00000000000000use std::convert::Infallible; use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] fn main() -> Infallible { unimplemented!() } #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main-infallible.stderr000064400000000000000000000001721046102023000214210ustar 00000000000000error: the main function has to be called main --> ui-tests/main-infallible.rs:10:4 | 10 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main-jsvalue.rs000064400000000000000000000002231046102023000201070ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] fn main() -> Result<(), JsValue> { unimplemented!() } #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main-jsvalue.stderr000064400000000000000000000001621046102023000207700ustar 00000000000000error: the main function has to be called main --> ui-tests/main-jsvalue.rs:9:4 | 9 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main-unit.rs000064400000000000000000000001541046102023000174200ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] fn main() -> () {} #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main-unit.stderr000064400000000000000000000001571046102023000203020ustar 00000000000000error: the main function has to be called main --> ui-tests/main-unit.rs:7:4 | 7 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/main.rs000064400000000000000000000001461046102023000164440ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(main)] fn main() {} #[wasm_bindgen(main)] fn fail() {} wasm-bindgen-macro-0.2.87/ui-tests/main.stderr000064400000000000000000000001521046102023000173200ustar 00000000000000error: the main function has to be called main --> ui-tests/main.rs:7:4 | 7 | fn fail() {} | ^^^^ wasm-bindgen-macro-0.2.87/ui-tests/missing-catch.rs000064400000000000000000000002101046102023000202410ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen] pub fn foo() -> Result; } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/missing-catch.stderr000064400000000000000000000011241046102023000211250ustar 00000000000000error[E0277]: the trait bound `Result: FromWasmAbi` is not satisfied --> ui-tests/missing-catch.rs:6:9 | 6 | pub fn foo() -> Result; | ^^^ the trait `FromWasmAbi` is not implemented for `Result` | = help: the following other types implement trait `FromWasmAbi`: *const T *mut T Box<[T]> Box<[f32]> Box<[f64]> Box<[i16]> Box<[i32]> Box<[i64]> and 35 others wasm-bindgen-macro-0.2.87/ui-tests/non-public-function.rs000064400000000000000000000001111046102023000214010ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] fn foo() {} fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/non-public-function.stderr000064400000000000000000000001721046102023000222670ustar 00000000000000error: can only #[wasm_bindgen] public functions --> $DIR/non-public-function.rs:4:1 | 4 | fn foo() {} | ^^^^^^^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/pub-not-copy.rs000064400000000000000000000001451046102023000200530ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct A { pub field: String, } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/pub-not-copy.stderr000064400000000000000000000010071046102023000207300ustar 00000000000000error[E0277]: the trait bound `String: std::marker::Copy` is not satisfied --> $DIR/pub-not-copy.rs:5:16 | 5 | pub field: String, | ^^^^^^ the trait `std::marker::Copy` is not implemented for `String` | note: required by a bound in `assert_copy` --> $DIR/pub-not-copy.rs:3:1 | 3 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ required by this bound in `assert_copy` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) wasm-bindgen-macro-0.2.87/ui-tests/start-function.rs000064400000000000000000000012761046102023000205050ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen(start)] fn foo() {} #[wasm_bindgen(start)] fn foo2(x: u32) {} #[wasm_bindgen(start)] fn foo3() {} #[wasm_bindgen(start)] fn foo4() -> Result<(), JsValue> { Ok(()) } #[wasm_bindgen(start)] fn foo5() -> Result { Err(()) } #[wasm_bindgen(start)] fn foo6() -> Result { Ok(JsValue::from(1u32)) } #[wasm_bindgen(start)] async fn foo_async1() {} #[wasm_bindgen(start)] async fn foo_async2() -> Result<(), JsValue> { Ok(()) } #[wasm_bindgen(start)] async fn foo_async3() -> Result { Err(()) } #[wasm_bindgen(start)] async fn foo_async4() -> Result { Ok(JsValue::from(1u32)) } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/start-function.stderr000064400000000000000000000046261046102023000213660ustar 00000000000000error: the start function cannot have arguments --> ui-tests/start-function.rs:7:9 | 7 | fn foo2(x: u32) {} | ^^^^^^ error: the start function cannot have generics --> ui-tests/start-function.rs:10:8 | 10 | fn foo3() {} | ^^^ error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied --> ui-tests/start-function.rs:15:1 | 15 | #[wasm_bindgen(start)] | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied --> ui-tests/start-function.rs:18:1 | 18 | #[wasm_bindgen(start)] | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied --> ui-tests/start-function.rs:27:1 | 27 | #[wasm_bindgen(start)] | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied --> ui-tests/start-function.rs:30:1 | 30 | #[wasm_bindgen(start)] | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) wasm-bindgen-macro-0.2.87/ui-tests/struct-fields.rs000064400000000000000000000003051046102023000203050ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { pub type Foo; } #[wasm_bindgen] struct Bar { pub a: Foo, #[wasm_bindgen(getter_with_clone)] pub b: Foo, } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/struct-fields.stderr000064400000000000000000000017701046102023000211730ustar 00000000000000error[E0277]: the trait bound `Foo: std::marker::Copy` is not satisfied --> ui-tests/struct-fields.rs:10:12 | 10 | pub a: Foo, | ^^^ the trait `std::marker::Copy` is not implemented for `Foo` | note: required by a bound in `__wbg_get_bar_a::assert_copy` --> ui-tests/struct-fields.rs:8:1 | 8 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ required by this bound in `assert_copy` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Foo: Clone` is not satisfied --> ui-tests/struct-fields.rs:11:20 | 11 | #[wasm_bindgen(getter_with_clone)] | ^---------------- | | | ____________________required by a bound introduced by this call | | 12 | | pub b: Foo, | |_________^ the trait `Clone` is not implemented for `Foo` | help: consider annotating `Foo` with `#[derive(Clone)]` | 3 | #[derive(Clone)] | wasm-bindgen-macro-0.2.87/ui-tests/structural-and-final.rs000064400000000000000000000002421046102023000215540ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { type Foo; #[wasm_bindgen(method, structural, final)] fn bar(this: &Foo); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/structural-and-final.stderr000064400000000000000000000003031046102023000224310ustar 00000000000000error: cannot specify both `structural` and `final` --> $DIR/structural-and-final.rs:7:40 | 7 | #[wasm_bindgen(method, structural, final)] | ^^^^^ wasm-bindgen-macro-0.2.87/ui-tests/traits-not-implemented.rs000064400000000000000000000002011046102023000221150ustar 00000000000000use wasm_bindgen::prelude::*; struct A; #[wasm_bindgen] extern "C" { #[wasm_bindgen] pub fn foo(a: A); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/traits-not-implemented.stderr000064400000000000000000000014351046102023000230060ustar 00000000000000error[E0277]: the trait bound `A: IntoWasmAbi` is not satisfied --> ui-tests/traits-not-implemented.rs:5:1 | 5 | #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `IntoWasmAbi` is not implemented for `A` | = help: the following other types implement trait `IntoWasmAbi`: &'a (dyn Fn() -> R + 'b) &'a (dyn Fn(A) -> R + 'b) &'a (dyn Fn(A, B) -> R + 'b) &'a (dyn Fn(A, B, C) -> R + 'b) &'a (dyn Fn(A, B, C, D) -> R + 'b) &'a (dyn Fn(A, B, C, D, E) -> R + 'b) &'a (dyn Fn(A, B, C, D, E, F) -> R + 'b) &'a (dyn Fn(A, B, C, D, E, F, G) -> R + 'b) and 84 others = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) wasm-bindgen-macro-0.2.87/ui-tests/unknown-type-in-import.rs000064400000000000000000000001671046102023000221150ustar 00000000000000use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen] pub fn foo(a: A); } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/unknown-type-in-import.stderr000064400000000000000000000004231046102023000227670ustar 00000000000000error[E0412]: cannot find type `A` in this scope --> ui-tests/unknown-type-in-import.rs:6:19 | 6 | pub fn foo(a: A); | ^ not found in this scope | help: you might be missing a type parameter | 6 | pub fn foo(a: A); | +++ wasm-bindgen-macro-0.2.87/ui-tests/unused-attributes.rs000064400000000000000000000010341046102023000212040ustar 00000000000000#![deny(unused_variables)] use wasm_bindgen::prelude::*; struct A {} #[wasm_bindgen] impl A { #[wasm_bindgen(method)] pub fn foo() {} } #[wasm_bindgen] pub struct MyStruct { hello: String, } #[wasm_bindgen(getter, typescript_custom_section)] pub const FOO: &'static str = "FOO"; #[wasm_bindgen(readonly)] pub fn bar() {} #[wasm_bindgen(getter_with_clone, final)] impl MyStruct { #[wasm_bindgen(getter, typescript_type = "Thing[]")] pub fn hello(&self) -> String { self.hello.clone() } } fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/unused-attributes.stderr000064400000000000000000000030541046102023000220670ustar 00000000000000error: unused variable: `method` --> ui-tests/unused-attributes.rs:9:20 | 9 | #[wasm_bindgen(method)] | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_method` | note: the lint level is defined here --> ui-tests/unused-attributes.rs:1:9 | 1 | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ error: unused variable: `getter` --> ui-tests/unused-attributes.rs:18:16 | 18 | #[wasm_bindgen(getter, typescript_custom_section)] | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_getter` error: unused variable: `readonly` --> ui-tests/unused-attributes.rs:21:16 | 21 | #[wasm_bindgen(readonly)] | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_readonly` error: unused variable: `typescript_type` --> ui-tests/unused-attributes.rs:26:28 | 26 | #[wasm_bindgen(getter, typescript_type = "Thing[]")] | ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_typescript_type` error: unused variable: `getter_with_clone` --> ui-tests/unused-attributes.rs:24:16 | 24 | #[wasm_bindgen(getter_with_clone, final)] | ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_getter_with_clone` error: unused variable: `final` --> ui-tests/unused-attributes.rs:24:35 | 24 | #[wasm_bindgen(getter_with_clone, final)] | ^^^^^ help: if this is intentional, prefix it with an underscore: `_final` wasm-bindgen-macro-0.2.87/ui-tests/update-all-references.sh000075500000000000000000000017141046102023000216620ustar 00000000000000#!/bin/bash # # Copyright 2015 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. # A script to update the references for all tests. The idea is that # you do a run, which will generate files in the build directory # containing the (normalized) actual output of the compiler. You then # run this script, which will copy those files over. If you find # yourself manually editing a foo.stderr file, you're doing it wrong. # # See all `update-references.sh`, if you just want to update a single test. MY_DIR=$(dirname $0) cd $MY_DIR find . -name '*.rs' | xargs ./update-references.sh wasm-bindgen-macro-0.2.87/ui-tests/update-references.sh000075500000000000000000000027501046102023000211150ustar 00000000000000#!/bin/bash # # Copyright 2015 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. # A script to update the references for particular tests. The idea is # that you do a run, which will generate files in the build directory # containing the (normalized) actual output of the compiler. This # script will then copy that output and replace the "expected output" # files. You can then commit the changes. # # If you find yourself manually editing a foo.stderr file, you're # doing it wrong. MYDIR=$(dirname $0) BUILD_DIR="../../../target/tests/ui" while [[ "$1" != "" ]]; do STDERR_NAME="${1/%.rs/.stderr}" STDOUT_NAME="${1/%.rs/.stdout}" shift if [ -f $BUILD_DIR/$STDOUT_NAME ] && \ ! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then echo updating $MYDIR/$STDOUT_NAME cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME fi if [ -f $BUILD_DIR/$STDERR_NAME ] && \ ! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then echo updating $MYDIR/$STDERR_NAME cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME fi done wasm-bindgen-macro-0.2.87/ui-tests/wasm-bindgen.rs000064400000000000000000000017011046102023000200710ustar 00000000000000extern crate wasm_bindgen as extern_test; use wasm_bindgen::prelude::*; mod test { pub use wasm_bindgen as test; pub use wasm_bindgen; } #[wasm_bindgen(wasm_bindgen = wasm_bindgen)] pub fn good1() {} #[wasm_bindgen(wasm_bindgen = ::wasm_bindgen)] pub fn good2() {} #[wasm_bindgen(wasm_bindgen = test::wasm_bindgen)] pub fn good3() {} #[wasm_bindgen(wasm_bindgen = test::test)] pub fn good4() {} #[wasm_bindgen(wasm_bindgen = extern_test)] pub fn good5() {} #[wasm_bindgen(wasm_bindgen_futures = wasm_bindgen_futures)] pub fn good6() {} #[wasm_bindgen(wasm_bindgen = wasm_bindgen)] pub async fn good7() {} #[wasm_bindgen(wasm_bindgen_futures = wasm_bindgen_futures)] pub async fn good8() {} #[wasm_bindgen(wasm_bindgen = wasm_bindgen, wasm_bindgen_futures = wasm_bindgen_futures)] pub async fn good9() {} #[wasm_bindgen(wasm_bindgen = test)] pub fn bad1() {} #[wasm_bindgen(wasm_bindgen_futures = test)] pub async fn bad2() {} fn main() {} wasm-bindgen-macro-0.2.87/ui-tests/wasm-bindgen.stderr000064400000000000000000000015071046102023000207540ustar 00000000000000error[E0433]: failed to resolve: could not find `convert` in `test` --> ui-tests/wasm-bindgen.rs:37:1 | 37 | #[wasm_bindgen(wasm_bindgen = test)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `convert` in `test` | = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `future_to_promise` in module `test` --> ui-tests/wasm-bindgen.rs:40:1 | 40 | #[wasm_bindgen(wasm_bindgen_futures = test)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `test` | = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this function | 3 | use wasm_bindgen_futures::future_to_promise; |