diff options
author | Jack Moffitt <jack@metajack.im> | 2015-06-17 15:59:04 -0600 |
---|---|---|
committer | Jack Moffitt <jack@metajack.im> | 2015-06-17 16:18:22 -0600 |
commit | 07d95627ca08d092a78edff85faa820c924853d7 (patch) | |
tree | 9fcd232e3a8b1b542b2a2bc47c999404cae0217c /components/script/dom/bindings/codegen/CodegenRust.py | |
parent | e1b28d893e54601bf497d0d5b83d77658ca16bac (diff) | |
download | servo-07d95627ca08d092a78edff85faa820c924853d7.tar.gz servo-07d95627ca08d092a78edff85faa820c924853d7.zip |
Generate code into OUT_DIR.
This is necessary to ensure Cargo knows when to rebuild. Normally
.gitignore would be enough to exclude these from Cargo's freshness
calculation, but https://github.com/rust-lang/cargo/issues/1729 prevents
this currently. This is the new, correct way to do these thigns, just
like the style crate does.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 78d8b2f7f6f..aa1b1ae14d3 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1429,25 +1429,26 @@ class CGImports(CGWrapper): """ Generates the appropriate import/use statements. """ - def __init__(self, child, descriptors, callbacks, imports): + def __init__(self, child, descriptors, callbacks, imports, ignored_warnings=None): """ Adds a set of imports. """ - ignored_warnings = [ - # Allow unreachable_code because we use 'break' in a way that - # sometimes produces two 'break's in a row. See for example - # CallbackMember.getArgConversions. - 'unreachable_code', - 'non_camel_case_types', - 'non_upper_case_globals', - 'unused_parens', - 'unused_imports', - 'unused_variables', - 'unused_unsafe', - 'unused_mut', - 'unused_assignments', - 'dead_code', - ] + if ignored_warnings is None: + ignored_warnings = [ + # Allow unreachable_code because we use 'break' in a way that + # sometimes produces two 'break's in a row. See for example + # CallbackMember.getArgConversions. + 'unreachable_code', + 'non_camel_case_types', + 'non_upper_case_globals', + 'unused_parens', + 'unused_imports', + 'unused_variables', + 'unused_unsafe', + 'unused_mut', + 'unused_assignments', + 'dead_code', + ] def componentTypes(type): if type.nullable(): @@ -1496,7 +1497,9 @@ class CGImports(CGWrapper): imports += ['dom::types::%s' % getIdentifier(t).name for t in types if isImportable(t)] - statements = ['#![allow(%s)]' % ','.join(ignored_warnings)] + statements = [] + if len(ignored_warnings) > 0: + statements.append('#![allow(%s)]' % ','.join(ignored_warnings)) statements.extend('use %s;' % i for i in sorted(set(imports))) CGWrapper.__init__(self, child, @@ -1815,7 +1818,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, config): CGUnionConversionStruct(t, provider) ]) - return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], [], imports) + return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], [], imports, ignored_warnings=[]) class Argument(): @@ -5415,7 +5418,7 @@ class GlobalGenRoots(): 'js::jsapi::JSContext', 'js::jsapi::JSObject', 'libc', - ]) + ], ignored_warnings=[]) @staticmethod def InterfaceTypes(config): @@ -5438,8 +5441,7 @@ class GlobalGenRoots(): def InheritTypes(config): descriptors = config.getDescriptors(register=True, isCallback=False) - allprotos = [CGGeneric("#![allow(unused_imports)]\n"), - CGGeneric("use dom::types::*;\n"), + allprotos = [CGGeneric("use dom::types::*;\n"), CGGeneric("use dom::bindings::js::{JS, JSRef, LayoutJS, Rootable, Temporary};\n"), CGGeneric("use dom::bindings::trace::JSTraceable;\n"), CGGeneric("use dom::bindings::utils::Reflectable;\n"), |