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

Trigger warnings for unused wasm-bindgen attributes #3073

Merged
merged 6 commits into from Sep 8, 2022

Commits on Sep 7, 2022

  1. Trigger warnings for unused wasm-bindgen attributes

    This attempts to do something similar to rustwasm#3070, but without potentially dangerous fallout from strict-mode failing on all the existing code out there.
    
    Instead of forcing a compiler error like strict-mode does, this PR will internally generate unused variables with spans pointing to unused attributes, so that users get a relatively meaningful warning.
    
    Here's how the result looks like on example from rustwasm#2874:
    
    ```
    warning: unused variable: `typescript_type`
      --> tests\headless\snippets.rs:67:28
       |
    67 |     #[wasm_bindgen(getter, typescript_type = "Thing[]")]
       |                            ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_typescript_type`
       |
       = note: `#[warn(unused_variables)]` on by default
    ```
    
    This is not 100% perfect - until Rust has a built-in `compile_warning!`, nothing is - but is a better status quo than the current one and can help users find problematic attributes without actually breaking their builds.
    
    Fixes rustwasm#3038.
    RReverser committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    84d6c85 View commit details
    Browse the repository at this point in the history
  2. Guide users who used the suggested (invalid) fix (#1)

    Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
    lukaslihotzki and RReverser committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    91334cc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d43124d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a6d1d9e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b8d612c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    73e82c1 View commit details
    Browse the repository at this point in the history