Skip to content

Commit 1320efe

Browse files
author
bors-servo
authored
Auto merge of #565 - framlog:master, r=fitzgen
automatically allow non rust naming conventions + related issue: #562 I just added those attributes at the root mod. And I'm not sure whether it should be better if we could set this setting in `build.rs`.
2 parents ecd9770 + e0ca632 commit 1320efe

21 files changed

+34
-3
lines changed

src/codegen/helpers.rs

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ pub mod attributes {
1010
use aster;
1111
use syntax::ast;
1212

13+
pub fn allow(which_ones: &[&str]) -> ast::Attribute {
14+
aster::AstBuilder::new().attr().list("allow").words(which_ones).build()
15+
}
16+
1317
pub fn repr(which: &str) -> ast::Attribute {
1418
aster::AstBuilder::new().attr().list("repr").words(&[which]).build()
1519
}

src/codegen/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,18 @@ impl CodeGenerator for Module {
399399
});
400400

401401
let name = item.canonical_name(ctx);
402-
let item = aster::AstBuilder::new()
402+
let item_builder = aster::AstBuilder::new()
403403
.item()
404-
.pub_()
405-
.build_item_kind(name, module);
404+
.pub_();
405+
let item = if name == "root" {
406+
let attrs = &["non_snake_case",
407+
"non_camel_case_types",
408+
"non_upper_case_globals"];
409+
item_builder.with_attr(attributes::allow(attrs))
410+
.build_item_kind(name, module)
411+
} else {
412+
item_builder.build_item_kind(name, module)
413+
};
406414

407415
result.push(item);
408416
}

tests/expectations/tests/duplicated-namespaces-definitions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/duplicated-namespaces.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/duplicated_constants_in_ns.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/inline_namespace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/inline_namespace_conservative.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/inline_namespace_whitelist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/issue-372.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/issue-410.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/issue-447.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/issue_311.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/module-whitelisted.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/namespace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/nested_within_namespace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/reparented_replacement.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/struct_typedef_ns.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/template_alias_namespace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/union-in-ns.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[repr(C)]
910
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);

tests/expectations/tests/whitelist-namespaces-basic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

tests/expectations/tests/whitelist-namespaces.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55

66

7+
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
78
pub mod root {
89
#[allow(unused_imports)]
910
use self::super::root;

0 commit comments

Comments
 (0)