Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Come up with regression test for #66286 #66422

Closed
estebank opened this issue Nov 14, 2019 · 3 comments · Fixed by #79712
Closed

Come up with regression test for #66286 #66422

estebank opened this issue Nov 14, 2019 · 3 comments · Fixed by #79712
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

Follow up to #66286 and #66390, as per #66390 (comment).

Minimize a test that exercises the same codepath as

extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub extern fn third(a: Vec(u32)) -> u32 {
    return a[3]
}
@estebank estebank added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Nov 14, 2019
@hellow554
Copy link
Contributor

As already stated in #66286 (comment) the wasm_bindgen proc macro can be reduced to:

extern crate proc_macro;

use proc_macro::TokenStream;
use quote::ToTokens;

#[proc_macro_attribute]
pub fn wasm_bindgen(attr: TokenStream, input: TokenStream) -> TokenStream {
    let mut tokens = proc_macro2::TokenStream::new();
    let item = syn::parse::<syn::Item>(input).expect("parse");

    if let syn::Item::Fn(f) = item {
        f.to_tokens(&mut tokens);
    }

    tokens.into()
}

@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Feb 2, 2020
@camelid
Copy link
Member

camelid commented Oct 26, 2020

How do you write a UI test that depends on 3rd-party libraries?

@estebank
Copy link
Contributor Author

@camelid https://github.com/rust-lang/rust/blob/5c6f7b32aab683276d4feb1810244ccf72bda736/src/test/ui/proc_macro.rs is an example of a test that relies on a proc_macro, and we can use @hellow554's snippet for the necessary proc_macro being tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants