Skip to content

Commit 68021c7

Browse files
authored
Merge pull request rust-lang#396 from KyleMayes/clippy-and-clang
Bump clang-sys version
2 parents 8443960 + af68180 commit 68021c7

File tree

7 files changed

+141
-153
lines changed

7 files changed

+141
-153
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ doc = false
1515
name = "bindgen"
1616

1717
[dependencies]
18-
clang-sys = "~0.8"
18+
clang-sys = "~0.11.0"
1919
# only for main, see https://github.com/rust-lang/cargo/issues/1982
2020
docopt = "~0.6.80"
2121
# only for main, see https://github.com/rust-lang/cargo/issues/1982
@@ -25,11 +25,11 @@ log = "~0.3.6"
2525
# only for main, see https://github.com/rust-lang/cargo/issues/1982
2626
rustc-serialize = "~0.3.19"
2727
syntex_syntax = "~0.38.0"
28-
cexpr = "0.1.1"
28+
cexpr = "0.2.0"
2929

3030
[dependencies.clippy]
3131
optional = true
32-
version = "0.0.72"
32+
version = "0.0.95"
3333

3434
[dev-dependencies]
3535
diff = "~0.1.9"

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![][crates-version-shield]](https://crates.io/crates/bindgen)
44
[![][crates-downloads-shield]](https://crates.io/crates/bindgen)
5-
[![][crates-license-shield]](https://github.com/crabtw/rust-bindgen/blob/master/LICENSE.txt)
6-
[![][travis-status-shield]](https://travis-ci.org/crabtw/rust-bindgen)
5+
[![][crates-license-shield]](https://github.com/Yamakaky/rust-bindgen/blob/master/LICENSE)
6+
[![][travis-status-shield]](https://travis-ci.org/Yamakaky/rust-bindgen)
77

88
A native binding generator for the Rust language.
99

@@ -74,11 +74,11 @@ Options:
7474

7575
### Using a build script to generate bindings at compile time
7676

77-
Due to a known issuewith `include!` https://github.com/rust-lang/rfcs/issues/752 when generating
78-
bindings in a build script and importing them with `include!` you'll want to wrap the bindings
77+
Due to a known issue with `include!` (https://github.com/rust-lang/rfcs/issues/752) when generating
78+
bindings in a build script and importing them with `include!`, you'll want to wrap the bindings
7979
in a module before writing them to a file to avoid triggering the issue with top-level
80-
attributes in `include!`. Some more discussion about this issue can be found here
81-
https://github.com/Yamakaky/rust-bindgen/issues/359 .
80+
attributes in `include!`. Some more discussion about this issue can be found
81+
[here](https://github.com/Yamakaky/rust-bindgen/issues/359).
8282

8383
`Cargo.toml`
8484
```rust
@@ -109,7 +109,7 @@ fn main(){
109109
// Wrap the bindings in a `pub mod` before writing bindgen's output
110110
file.write(format!("pub mod {} {{\n", "my_lib").as_bytes()).unwrap();
111111
file.write(generated_bindings.as_bytes()).unwrap();
112-
file.write(b"}").unwrap();
112+
file.write(b"}").unwrap();
113113
}
114114
```
115115

@@ -125,7 +125,6 @@ fn main() {
125125
[crates-version-shield]: https://img.shields.io/crates/v/bindgen.svg?style=flat-square
126126
[crates-downloads-shield]: https://img.shields.io/crates/d/bindgen.svg?style=flat-square
127127
[crates-license-shield]: https://img.shields.io/crates/l/bindgen.svg?style=flat-square
128-
[travis-status-shield]: https://img.shields.io/travis/crabtw/rust-bindgen/master.svg?label=travis&style=flat-square
128+
[travis-status-shield]: https://img.shields.io/travis/Yamakaky/rust-bindgen/master.svg?label=travis&style=flat-square
129129

130130
[clay's bindgen]: https://github.com/jckarter/clay/blob/master/tools/bindgen.clay
131-
[issue 89]: https://github.com/yamakaky/rust-bindgen/issues/89

scripts/travis-before-install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Workaround for a Travis CI issue on OS X: https://github.com/travis-ci/travis-ci/issues/6522
2+
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
3+
rvm get head || true
4+
fi
5+
16
set -e
27

38
function llvm_version_triple() {

src/clang.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,12 @@ impl Into<CexprToken> for Token {
334334
fn into(self) -> CexprToken {
335335
CexprToken {
336336
kind:match self.kind {
337-
CXTokenKind::Comment => CexprTokenKind::Comment,
338-
CXTokenKind::Identifier => CexprTokenKind::Identifier,
339-
CXTokenKind::Keyword => CexprTokenKind::Keyword,
340-
CXTokenKind::Literal => CexprTokenKind::Literal,
341-
CXTokenKind::Punctuation => CexprTokenKind::Punctuation,
337+
CXToken_Comment => CexprTokenKind::Comment,
338+
CXToken_Identifier => CexprTokenKind::Identifier,
339+
CXToken_Keyword => CexprTokenKind::Keyword,
340+
CXToken_Literal => CexprTokenKind::Literal,
341+
CXToken_Punctuation => CexprTokenKind::Punctuation,
342+
_ => panic!("invalid token kind: {:?}", self.kind),
342343
},
343344
raw:self.spelling.into_bytes().into_boxed_slice()
344345
}
@@ -383,7 +384,7 @@ impl TranslationUnit {
383384
clang_reparseTranslationUnit(self.x,
384385
c_unsaved.len() as c_uint,
385386
c_unsaved.as_mut_ptr(),
386-
opts) == CXErrorCode::Success
387+
opts) == CXError_Success
387388
}
388389
}
389390

@@ -414,7 +415,7 @@ impl TranslationUnit {
414415

415416
pub fn tokens(&self, cursor: &Cursor) -> Option<Vec<Token>> {
416417
let mut range = cursor.extent();
417-
if cursor.kind()==CXCursorKind::MacroDefinition {
418+
if cursor.kind()==CXCursor_MacroDefinition {
418419
range.end_int_data-=1; // bug observed in clang 3.5 ~ 3.8
419420
}
420421
let mut tokens = vec![];
@@ -504,5 +505,5 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
504505
&format!("({:?} {} {:?}", c.kind(), c.spelling(), ct)[..]);
505506
c.visit(|s, _: &Cursor| ast_dump(s, depth + 1));
506507
print_indent(depth, ")");
507-
CXChildVisitResult::Continue
508+
CXChildVisit_Continue
508509
}

src/gen.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub fn gen_mod(options: &BindgenOptions,
285285
let mut fs = vec![];
286286
let mut vs = vec![];
287287
let mut gs = vec![];
288-
for g in uniq_globs.into_iter() {
288+
for g in uniq_globs {
289289
match g {
290290
GOther => {}
291291
GFunc(_) => fs.push(g),
@@ -331,7 +331,7 @@ pub fn gen_mod(options: &BindgenOptions,
331331
defs.push(mk_extern(&mut ctx, &options.links, vars, abi::Abi::C));
332332
}
333333

334-
for (abi, funcs) in funcs.into_iter() {
334+
for (abi, funcs) in funcs {
335335
defs.push(mk_extern(&mut ctx, &options.links, funcs, abi));
336336
}
337337

@@ -601,9 +601,6 @@ fn gen_padding_fields(ctx: &mut GenCtx,
601601
} else {
602602
// u64s only; subtract implicit 8-byte pad for alignment
603603
let size = padding_size - (padding_size % u64_size);
604-
(0..(size / max_field_size))
605-
.map(|_| (&u64_ty, MAX_ARRAY_CLONE_LEN))
606-
.collect::<Vec<(&P<ast::Ty>, usize)>>();
607604

608605
let u64_num = (size % max_field_size) / u64_size;
609606
if u64_num > 0 {
@@ -756,12 +753,10 @@ fn cstruct_to_rs(ctx: &mut GenCtx,
756753
offset += m.layout().size as usize;
757754
}
758755

759-
if offset < layout.size {
760-
// We only need to pad if the pad amount is more than the existing alignment
761-
if layout.size - offset > largest_member_alignment {
762-
let mut padding_fields = gen_padding_fields(ctx, paddings, layout.size - offset);
763-
fields.append(&mut padding_fields);
764-
}
756+
// We only need to pad if the pad amount is more than the existing alignment
757+
if offset < layout.size && layout.size - offset > largest_member_alignment {
758+
let mut padding_fields = gen_padding_fields(ctx, paddings, layout.size - offset);
759+
fields.append(&mut padding_fields);
765760
}
766761

767762
let def = ast::ItemKind::Struct(ast::VariantData::Struct(fields, ast::DUMMY_NODE_ID),
@@ -1188,7 +1183,7 @@ fn gen_comp_methods(ctx: &mut GenCtx,
11881183

11891184
let mut offset = data_offset;
11901185
let mut methods = vec![];
1191-
for m in members.into_iter() {
1186+
for m in members {
11921187
let advance_by = match *m {
11931188
CompMember::Field(ref f) => {
11941189
methods.extend(mk_field_method(ctx, f, offset).into_iter());

0 commit comments

Comments
 (0)