Skip to content

Commit

Permalink
fix: remove repeated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
eerii committed Mar 21, 2024
1 parent 77683e3 commit f58d4fd
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -39,8 +39,13 @@
iteratorNativeType
)

AUTOGENERATED_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
AUTOGENERATED_WARNING_COMMENT = "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
IGNORED_WARNING_LIST = ['non_camel_case_types', 'non_upper_case_globals', 'unused_imports',
'unused_variables', 'unused_assignments', 'unused_mut',
'clippy::approx_constant', 'clippy::let_unit_value', 'clippy::needless_return',
'clippy::too_many_arguments', 'clippy::unnecessary_cast']
IGNORED_WARNINGS = f"#![allow({','.join(IGNORED_WARNING_LIST)})]\n\n"

FINALIZE_HOOK_NAME = '_finalize'
TRACE_HOOK_NAME = '_trace'
CONSTRUCT_HOOK_NAME = '_constructor'
Expand Down Expand Up @@ -2160,25 +2165,10 @@ class CGImports(CGWrapper):
"""
Generates the appropriate import/use statements.
"""
def __init__(self, child, descriptors, callbacks, dictionaries, enums, typedefs, imports, config,
ignored_warnings=None):
def __init__(self, child, descriptors, callbacks, dictionaries, enums, typedefs, imports, config):
"""
Adds a set of imports.
"""
if ignored_warnings is None:
ignored_warnings = [
'non_camel_case_types',
'non_upper_case_globals',
'unused_imports',
'unused_variables',
'unused_assignments',
'unused_mut',
'clippy::approx_constant',
'clippy::let_unit_value',
'clippy::needless_return',
'clippy::too_many_arguments',
'clippy::unnecessary_cast',
]

def componentTypes(type):
if type.isType() and type.nullable():
Expand Down Expand Up @@ -2289,8 +2279,6 @@ def removeWrapperAndNullableTypes(types):
extras += [getModuleFromObject(t) + '::' + getIdentifier(t).name]

statements = []
if len(ignored_warnings) > 0:
statements.append('#![allow(%s)]' % ','.join(ignored_warnings))
statements.extend('use %s;' % i for i in sorted(set(imports + extras)))

CGWrapper.__init__(self, child,
Expand Down Expand Up @@ -2658,8 +2646,8 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config):
# Sort unionStructs by key, retrieve value
unionStructs = (i[1] for i in sorted(list(unionStructs.items()), key=operator.itemgetter(0)))

return CGImports(CGList(unionStructs, "\n\n"), descriptors=[], callbacks=[], dictionaries=[], enums=[], typedefs=[],
imports=imports, config=config, ignored_warnings=[])
return CGImports(CGList(unionStructs, "\n\n"), descriptors=[], callbacks=[], dictionaries=[], enums=[],
typedefs=[], imports=imports, config=config)


class Argument():
Expand Down Expand Up @@ -6959,7 +6947,7 @@ def __init__(self, config, prefix, webIDLFile):
imports=['crate::dom::bindings::import::base::*'], config=config)

# Add the auto-generated comment.
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT + IGNORED_WARNINGS)

# Store the final result.
self.root = curr
Expand Down Expand Up @@ -7826,7 +7814,7 @@ def RegisterBindings(config):

return CGImports(code, descriptors=[], callbacks=[], dictionaries=[], enums=[], typedefs=[], imports=[
'crate::dom::bindings::codegen::Bindings',
], config=config, ignored_warnings=[])
], config=config)

@staticmethod
def InterfaceTypes(config):
Expand Down

0 comments on commit f58d4fd

Please sign in to comment.