From 792a8e132ecbed4bbe27cead6876cc5e32769d73 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Apr 2018 13:16:59 -0700 Subject: [PATCH] Fix unused variables in generated code Also deny all warnings in tests to prevent this creeping back in. Closes #141 --- crates/backend/src/codegen.rs | 2 +- tests/all/classes.rs | 6 +++--- tests/all/closures.rs | 4 ---- tests/all/imports.rs | 1 + tests/all/main.rs | 4 +++- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs index d71ff6bdc..99c7aec42 100644 --- a/crates/backend/src/codegen.rs +++ b/crates/backend/src/codegen.rs @@ -129,7 +129,7 @@ impl ToTokens for ast::Struct { impl ::wasm_bindgen::convert::FromWasmAbi for #name { type Abi = u32; - unsafe fn from_abi(js: u32, extra: &mut ::wasm_bindgen::convert::Stack) + unsafe fn from_abi(js: u32, _extra: &mut ::wasm_bindgen::convert::Stack) -> Self { let ptr = js as *mut ::wasm_bindgen::__rt::WasmRefCell<#name>; diff --git a/tests/all/classes.rs b/tests/all/classes.rs index b388a5dfa..c96593f65 100644 --- a/tests/all/classes.rs +++ b/tests/all/classes.rs @@ -291,13 +291,13 @@ fn issue_27() { #[wasm_bindgen] impl Context { - pub fn parse(&self, expr: &str) -> Expr { + pub fn parse(&self, _expr: &str) -> Expr { panic!() } - pub fn eval(&self, expr: &Expr) -> f64 { + pub fn eval(&self, _expr: &Expr) -> f64 { panic!() } - pub fn set(&mut self, var: &str, val: f64) { + pub fn set(&mut self, _var: &str, _val: f64) { panic!() } } diff --git a/tests/all/closures.rs b/tests/all/closures.rs index 0cac95c94..d965091c1 100644 --- a/tests/all/closures.rs +++ b/tests/all/closures.rs @@ -294,7 +294,6 @@ fn long_fnmut_recursive() { extern crate wasm_bindgen; - use std::cell::Cell; use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "./test")] @@ -336,7 +335,6 @@ fn fnmut() { extern crate wasm_bindgen; - use std::cell::Cell; use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "./test")] @@ -385,7 +383,6 @@ fn fnmut_bad() { extern crate wasm_bindgen; - use std::cell::Cell; use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "./test")] @@ -441,7 +438,6 @@ fn string_arguments() { extern crate wasm_bindgen; - use std::cell::Cell; use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "./test")] diff --git a/tests/all/imports.rs b/tests/all/imports.rs index b464e0898..3cd4f7fca 100644 --- a/tests/all/imports.rs +++ b/tests/all/imports.rs @@ -87,6 +87,7 @@ fn unused() { project() .file("src/lib.rs", r#" #![feature(proc_macro, wasm_custom_section, wasm_import_module)] + #![allow(dead_code)] extern crate wasm_bindgen; diff --git a/tests/all/main.rs b/tests/all/main.rs index 27fcdaa97..8c7aac10a 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -169,7 +169,9 @@ impl Project { .arg("--target") .arg("wasm32-unknown-unknown") .current_dir(&root) - .env("CARGO_TARGET_DIR", &target_dir); + .env("CARGO_TARGET_DIR", &target_dir) + // Catch any warnings in generated code because we don't want any + .env("RUSTFLAGS", "-Dwarnings"); run(&mut cmd, "cargo"); let idx = IDX.with(|x| *x);