Skip to content

Commit

Permalink
add #[allow(clippy::*)] in the top-level items
Browse files Browse the repository at this point in the history
  • Loading branch information
T5uku5hi committed Jan 25, 2019
1 parent f8dabfc commit e19306c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl TryToTokens for ast::Program {
#[cfg(target_arch = "wasm32")]
#[link_section = "__wasm_bindgen_unstable"]
#[doc(hidden)]
#[allow(clippy::*)]
pub static #generated_static_name: [u8; #generated_static_length] =
*#generated_static_value;
})
Expand All @@ -129,6 +130,7 @@ impl ToTokens for ast::Struct {
let free_fn = Ident::new(&shared::free_function(&name_str), Span::call_site());
(quote! {
impl ::wasm_bindgen::describe::WasmDescribe for #name {
#[allow(clippy::*)]
fn describe() {
use wasm_bindgen::__wbindgen_if_not_std;
__wbindgen_if_not_std! {
Expand All @@ -147,6 +149,7 @@ impl ToTokens for ast::Struct {
impl ::wasm_bindgen::convert::IntoWasmAbi for #name {
type Abi = u32;

#[allow(clippy::*)]
fn into_abi(self, _extra: &mut ::wasm_bindgen::convert::Stack)
-> u32
{
Expand All @@ -159,6 +162,7 @@ impl ToTokens for ast::Struct {
impl ::wasm_bindgen::convert::FromWasmAbi for #name {
type Abi = u32;

#[allow(clippy::*)]
unsafe fn from_abi(js: u32, _extra: &mut ::wasm_bindgen::convert::Stack)
-> Self
{
Expand All @@ -177,6 +181,7 @@ impl ToTokens for ast::Struct {
::wasm_bindgen::JsValue
{
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[allow(clippy::*)]
fn from(value: #name) -> Self {
let ptr = ::wasm_bindgen::convert::IntoWasmAbi::into_abi(
value,
Expand All @@ -198,6 +203,7 @@ impl ToTokens for ast::Struct {
}

#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
#[allow(clippy::*)]
fn from(_value: #name) -> Self {
panic!("cannot convert to JsValue outside of the wasm target")
}
Expand All @@ -206,6 +212,7 @@ impl ToTokens for ast::Struct {
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[no_mangle]
#[doc(hidden)]
#[allow(clippy::*)]
pub unsafe extern "C" fn #free_fn(ptr: u32) {
<#name as ::wasm_bindgen::convert::FromWasmAbi>::from_abi(
ptr,
Expand All @@ -217,6 +224,7 @@ impl ToTokens for ast::Struct {
type Abi = u32;
type Anchor = ::wasm_bindgen::__rt::Ref<'static, #name>;

#[allow(clippy::*)]
unsafe fn ref_from_abi(
js: Self::Abi,
_extra: &mut ::wasm_bindgen::convert::Stack,
Expand All @@ -231,6 +239,7 @@ impl ToTokens for ast::Struct {
type Abi = u32;
type Anchor = ::wasm_bindgen::__rt::RefMut<'static, #name>;

#[allow(clippy::*)]
unsafe fn ref_mut_from_abi(
js: Self::Abi,
_extra: &mut ::wasm_bindgen::convert::Stack,
Expand Down Expand Up @@ -260,6 +269,7 @@ impl ToTokens for ast::StructField {
#[no_mangle]
#[doc(hidden)]
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[allow(clippy::*)]
pub unsafe extern "C" fn #getter(js: u32)
-> <#ty as ::wasm_bindgen::convert::IntoWasmAbi>::Abi
{
Expand Down Expand Up @@ -296,6 +306,7 @@ impl ToTokens for ast::StructField {
#[no_mangle]
#[doc(hidden)]
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[allow(clippy::*)]
pub unsafe extern "C" fn #setter(
js: u32,
val: <#ty as ::wasm_bindgen::convert::FromWasmAbi>::Abi,
Expand Down Expand Up @@ -463,6 +474,7 @@ impl TryToTokens for ast::Export {
#[export_name = #export_name]
#[allow(non_snake_case)]
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[allow(clippy::*)]
pub extern "C" fn #generated_name(#(#args),*) #ret_ty {
#start_check
// Scope all local variables to be destroyed after we call the
Expand Down Expand Up @@ -543,11 +555,13 @@ impl ToTokens for ast::ImportType {
#(#attrs)*
#[doc = #doc_comment]
#[repr(transparent)]
#[allow(clippy::*)]
#vis struct #rust_name {
obj: ::wasm_bindgen::JsValue,
}

#[allow(bad_style)]
#[allow(clippy::*)]
const #const_name: () = {
use wasm_bindgen::convert::{IntoWasmAbi, FromWasmAbi, Stack};
use wasm_bindgen::convert::{OptionIntoWasmAbi, OptionFromWasmAbi};
Expand Down Expand Up @@ -685,6 +699,7 @@ impl ToTokens for ast::ImportType {
type Target = #deref_target;

#[inline]
#[allow(clippy::*)]
fn deref(&self) -> &#deref_target {
self.as_ref()
}
Expand All @@ -695,6 +710,7 @@ impl ToTokens for ast::ImportType {
(quote! {
impl From<#rust_name> for #superclass {
#[inline]
#[allow(clippy::*)]
fn from(obj: #rust_name) -> #superclass {
use wasm_bindgen::JsCast;
#superclass::unchecked_from_js(obj.into())
Expand All @@ -703,6 +719,7 @@ impl ToTokens for ast::ImportType {

impl AsRef<#superclass> for #rust_name {
#[inline]
#[allow(clippy::*)]
fn as_ref(&self) -> &#superclass {
use wasm_bindgen::JsCast;
#superclass::unchecked_from_js_ref(self.as_ref())
Expand Down Expand Up @@ -749,13 +766,15 @@ impl ToTokens for ast::ImportEnum {
(quote! {
#[allow(bad_style)]
#(#attrs)*
#[allow(clippy::*)]
#vis enum #name {
#(#variants = #variant_indexes_ref,)*
#[doc(hidden)]
__Nonexhaustive,
}

impl #name {
#[allow(clippy::*)]
#vis fn from_js_value(obj: &::wasm_bindgen::JsValue) -> Option<#name> {
obj.as_string().and_then(|obj_str| match obj_str.as_str() {
#(#variant_strings => Some(#variant_paths_ref),)*
Expand All @@ -765,6 +784,7 @@ impl ToTokens for ast::ImportEnum {
}

impl ::wasm_bindgen::describe::WasmDescribe for #name {
#[allow(clippy::*)]
fn describe() {
::wasm_bindgen::JsValue::describe()
}
Expand All @@ -775,6 +795,7 @@ impl ToTokens for ast::ImportEnum {
::wasm_bindgen::convert::IntoWasmAbi>::Abi;

#[inline]
#[allow(clippy::*)]
fn into_abi(self, extra: &mut ::wasm_bindgen::convert::Stack) -> Self::Abi {
::wasm_bindgen::JsValue::from(self).into_abi(extra)
}
Expand All @@ -784,6 +805,7 @@ impl ToTokens for ast::ImportEnum {
type Abi = <::wasm_bindgen::JsValue as
::wasm_bindgen::convert::FromWasmAbi>::Abi;

#[allow(clippy::*)]
unsafe fn from_abi(
js: Self::Abi,
extra: &mut ::wasm_bindgen::convert::Stack,
Expand All @@ -793,6 +815,7 @@ impl ToTokens for ast::ImportEnum {
}

impl From<#name> for ::wasm_bindgen::JsValue {
#[allow(clippy::*)]
fn from(obj: #name) -> ::wasm_bindgen::JsValue {
match obj {
#(#variant_paths_ref => ::wasm_bindgen::JsValue::from_str(#variant_strings),)*
Expand Down Expand Up @@ -935,6 +958,7 @@ impl TryToTokens for ast::ImportFunction {
#[allow(bad_style)]
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[doc = #doc_comment]
#[allow(clippy::*)]
#vis fn #rust_name(#me #(#arguments),*) #ret {
#[link(wasm_import_module = "__wbindgen_placeholder__")]
extern "C" {
Expand All @@ -956,6 +980,7 @@ impl TryToTokens for ast::ImportFunction {
#[allow(bad_style, unused_variables)]
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
#[doc = #doc_comment]
#[allow(clippy::*)]
#vis fn #rust_name(#me #(#arguments),*) #ret {
panic!("cannot call wasm-bindgen imported functions on \
non-wasm targets");
Expand Down Expand Up @@ -1026,6 +1051,7 @@ impl ToTokens for ast::Enum {
type Abi = u32;

#[inline]
#[allow(clippy::*)]
fn into_abi(self, _extra: &mut ::wasm_bindgen::convert::Stack) -> u32 {
self as u32
}
Expand All @@ -1034,6 +1060,7 @@ impl ToTokens for ast::Enum {
impl ::wasm_bindgen::convert::FromWasmAbi for #enum_name {
type Abi = u32;

#[allow(clippy::*)]
unsafe fn from_abi(
js: u32,
_extra: &mut ::wasm_bindgen::convert::Stack,
Expand All @@ -1045,6 +1072,7 @@ impl ToTokens for ast::Enum {
}

impl ::wasm_bindgen::describe::WasmDescribe for #enum_name {
#[allow(clippy::*)]
fn describe() {
use wasm_bindgen::describe::*;
inform(ENUM);
Expand All @@ -1063,6 +1091,7 @@ impl ToTokens for ast::ImportStatic {
let vis = &self.vis;
(quote! {
#[allow(bad_style)]
#[allow(clippy::*)]
#vis static #name: ::wasm_bindgen::JsStatic<#ty> = {
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
fn init() -> #ty {
Expand Down Expand Up @@ -1167,11 +1196,13 @@ impl ToTokens for ast::Dictionary {
(quote! {
#[derive(Clone, Debug)]
#[repr(transparent)]
#[allow(clippy::*)]
pub struct #name {
obj: ::js_sys::Object,
}

impl #name {
#[allow(clippy::*)]
pub fn new(#(#required_names: #required_types),*) -> #name {
let mut _ret = #name { obj: ::js_sys::Object::new() };
#(_ret.#required_names2(#required_names3);)*
Expand All @@ -1182,6 +1213,7 @@ impl ToTokens for ast::Dictionary {
}

#[allow(bad_style)]
#[allow(clippy::*)]
const #const_name: () = {
use js_sys::Object;
use wasm_bindgen::describe::WasmDescribe;
Expand All @@ -1192,17 +1224,20 @@ impl ToTokens for ast::Dictionary {
// interop w/ JsValue
impl From<#name> for JsValue {
#[inline]
#[allow(clippy::*)]
fn from(val: #name) -> JsValue {
val.obj.into()
}
}
impl AsRef<JsValue> for #name {
#[inline]
#[allow(clippy::*)]
fn as_ref(&self) -> &JsValue { self.obj.as_ref() }
}

// Boundary conversion impls
impl WasmDescribe for #name {
#[allow(clippy::*)]
fn describe() {
Object::describe();
}
Expand All @@ -1211,6 +1246,7 @@ impl ToTokens for ast::Dictionary {
impl IntoWasmAbi for #name {
type Abi = <Object as IntoWasmAbi>::Abi;
#[inline]
#[allow(clippy::*)]
fn into_abi(self, extra: &mut Stack) -> Self::Abi {
self.obj.into_abi(extra)
}
Expand All @@ -1219,6 +1255,7 @@ impl ToTokens for ast::Dictionary {
impl<'a> IntoWasmAbi for &'a #name {
type Abi = <&'a Object as IntoWasmAbi>::Abi;
#[inline]
#[allow(clippy::*)]
fn into_abi(self, extra: &mut Stack) -> Self::Abi {
(&self.obj).into_abi(extra)
}
Expand All @@ -1227,21 +1264,25 @@ impl ToTokens for ast::Dictionary {
impl FromWasmAbi for #name {
type Abi = <Object as FromWasmAbi>::Abi;
#[inline]
#[allow(clippy::*)]
unsafe fn from_abi(abi: Self::Abi, extra: &mut Stack) -> Self {
#name { obj: Object::from_abi(abi, extra) }
}
}

impl OptionIntoWasmAbi for #name {
#[inline]
#[allow(clippy::*)]
fn none() -> Self::Abi { Object::none() }
}
impl<'a> OptionIntoWasmAbi for &'a #name {
#[inline]
#[allow(clippy::*)]
fn none() -> Self::Abi { <&'a Object>::none() }
}
impl OptionFromWasmAbi for #name {
#[inline]
#[allow(clippy::*)]
fn is_none(abi: &Self::Abi) -> bool { Object::is_none(abi) }
}

Expand All @@ -1250,6 +1291,7 @@ impl ToTokens for ast::Dictionary {
type Anchor = ManuallyDrop<#name>;

#[inline]
#[allow(clippy::*)]
unsafe fn ref_from_abi(js: Self::Abi, extra: &mut Stack) -> Self::Anchor {
let tmp = <Object as RefFromWasmAbi>::ref_from_abi(js, extra);
ManuallyDrop::new(#name {
Expand All @@ -1260,16 +1302,19 @@ impl ToTokens for ast::Dictionary {

impl JsCast for #name {
#[inline]
#[allow(clippy::*)]
fn instanceof(val: &JsValue) -> bool {
Object::instanceof(val)
}

#[inline]
#[allow(clippy::*)]
fn unchecked_from_js(val: JsValue) -> Self {
#name { obj: Object::unchecked_from_js(val) }
}

#[inline]
#[allow(clippy::*)]
fn unchecked_from_js_ref(val: &JsValue) -> &Self {
unsafe { &*(val as *const JsValue as *const #name) }
}
Expand All @@ -1286,6 +1331,7 @@ impl ToTokens for ast::DictionaryField {
let js_name = &self.js_name;
let ty = &self.ty;
(quote! {
#[allow(clippy::*)]
pub fn #rust_name(&mut self, val: #ty) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
Expand Down Expand Up @@ -1333,6 +1379,7 @@ impl<'a, T: ToTokens> ToTokens for Descriptor<'a, T> {
#[allow(non_snake_case)]
#[doc(hidden)]
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
#[allow(clippy::*)]
pub extern "C" fn #name() {
use wasm_bindgen::describe::*;
// See definition of `link_mem_intrinsics` for what this is doing
Expand Down

0 comments on commit e19306c

Please sign in to comment.