Skip to content

Commit 29a6347

Browse files
authored
Merge pull request #1409 from emilio/update-some-crates. r=emilio
Update which, quote and proc_macro.
2 parents 33912cf + 7b1406d commit 29a6347

File tree

89 files changed

+628
-830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+628
-830
lines changed

Cargo.lock

Lines changed: 50 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
repository = "https://github.com/rust-lang/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
1616
homepage = "https://rust-lang.github.io/rust-bindgen/"
17-
version = "0.43.2"
17+
version = "0.44.0"
1818
build = "build.rs"
1919

2020
include = [
@@ -51,12 +51,12 @@ clap = "2"
5151
clang-sys = { version = "0.26", features = ["runtime", "clang_6_0"] }
5252
lazy_static = "1"
5353
peeking_take_while = "0.1.2"
54-
quote = { version = "0.5", default-features = false }
54+
quote = { version = "0.6", default-features = false }
5555
regex = "1.0"
56-
which = "1.0.2"
56+
which = "2.0"
5757
# New validation in 0.3.6 breaks bindgen-integration:
5858
# https://github.com/alexcrichton/proc-macro2/commit/489c642.
59-
proc-macro2 = { version = "0.3.2, < 0.3.6", default-features = false }
59+
proc-macro2 = { version = "0.4", default-features = false }
6060

6161
[dependencies.env_logger]
6262
optional = true

bindgen-integration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build = "build.rs"
88

99
[build-dependencies]
1010
bindgen = { path = ".." }
11-
gcc = "0.3"
11+
cc = "1.0"
1212

1313
[features]
1414
testing_only_libclang_5 = ["bindgen/testing_only_libclang_5"]

bindgen-integration/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
extern crate bindgen;
2-
extern crate gcc;
2+
extern crate cc;
33

44
use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks};
55
use bindgen::Builder;
@@ -72,7 +72,7 @@ impl Drop for MacroCallback {
7272
}
7373

7474
fn main() {
75-
gcc::Build::new()
75+
cc::Build::new()
7676
.cpp(true)
7777
.file("cpp/Test.cc")
7878
.compile("libtest.a");

src/codegen/helpers.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,54 @@
22
33
use ir::context::BindgenContext;
44
use ir::layout::Layout;
5-
use quote;
6-
use proc_macro2::{Term, Span};
5+
use proc_macro2::{self, Ident, Span};
6+
use quote::TokenStreamExt;
77

88
pub mod attributes {
9-
use quote;
10-
use proc_macro2::{Term, Span};
9+
use proc_macro2::{self, Ident, Span};
1110

12-
pub fn repr(which: &str) -> quote::Tokens {
13-
let which = Term::new(which, Span::call_site());
11+
pub fn repr(which: &str) -> proc_macro2::TokenStream {
12+
let which = Ident::new(which, Span::call_site());
1413
quote! {
1514
#[repr( #which )]
1615
}
1716
}
1817

19-
pub fn repr_list(which_ones: &[&str]) -> quote::Tokens {
20-
let which_ones = which_ones.iter().cloned().map(|one| Term::new(one, Span::call_site()));
18+
pub fn repr_list(which_ones: &[&str]) -> proc_macro2::TokenStream {
19+
let which_ones = which_ones.iter().cloned().map(|one| Ident::new(one, Span::call_site()));
2120
quote! {
2221
#[repr( #( #which_ones ),* )]
2322
}
2423
}
2524

26-
pub fn derives(which_ones: &[&str]) -> quote::Tokens {
27-
let which_ones = which_ones.iter().cloned().map(|one| Term::new(one, Span::call_site()));
25+
pub fn derives(which_ones: &[&str]) -> proc_macro2::TokenStream {
26+
let which_ones = which_ones.iter().cloned().map(|one| Ident::new(one, Span::call_site()));
2827
quote! {
2928
#[derive( #( #which_ones ),* )]
3029
}
3130
}
3231

33-
pub fn inline() -> quote::Tokens {
32+
pub fn inline() -> proc_macro2::TokenStream {
3433
quote! {
3534
#[inline]
3635
}
3736
}
3837

39-
pub fn must_use() -> quote::Tokens {
38+
pub fn must_use() -> proc_macro2::TokenStream {
4039
quote! {
4140
#[must_use]
4241
}
4342
}
4443

45-
pub fn doc(comment: String) -> quote::Tokens {
46-
// Doc comments are already preprocessed into nice `///` formats by the
47-
// time they get here. Just make sure that we have newlines around it so
48-
// that nothing else gets wrapped into the comment.
49-
let mut tokens = quote! {};
50-
tokens.append(Term::new("\n", Span::call_site()));
51-
tokens.append(Term::new(&comment, Span::call_site()));
52-
tokens.append(Term::new("\n", Span::call_site()));
53-
tokens
44+
pub fn doc(comment: String) -> proc_macro2::TokenStream {
45+
use std::str::FromStr;
46+
47+
// NOTE(emilio): By this point comments are already preprocessed and in
48+
// `///` form. Quote turns them into `#[doc]` comments, but oh well.
49+
proc_macro2::TokenStream::from_str(&comment).unwrap()
5450
}
5551

56-
pub fn link_name(name: &str) -> quote::Tokens {
52+
pub fn link_name(name: &str) -> proc_macro2::TokenStream {
5753
// LLVM mangles the name by default but it's already mangled.
5854
// Prefixing the name with \u{1} should tell LLVM to not mangle it.
5955
let name = format!("\u{1}{}", name);
@@ -65,7 +61,7 @@ pub mod attributes {
6561

6662
/// Generates a proper type for a field or type with a given `Layout`, that is,
6763
/// a type with the correct size and alignment restrictions.
68-
pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
64+
pub fn blob(ctx: &BindgenContext, layout: Layout) -> proc_macro2::TokenStream {
6965
let opaque = layout.opaque();
7066

7167
// FIXME(emilio, #412): We fall back to byte alignment, but there are
@@ -80,7 +76,7 @@ pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
8076
}
8177
};
8278

83-
let ty_name = Term::new(ty_name, Span::call_site());
79+
let ty_name = Ident::new(ty_name, Span::call_site());
8480

8581
let data_len = opaque.array_size(ctx).unwrap_or(layout.size);
8682

@@ -96,14 +92,14 @@ pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
9692
}
9793

9894
/// Integer type of the same size as the given `Layout`.
99-
pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option<quote::Tokens> {
95+
pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option<proc_macro2::TokenStream> {
10096
let name = Layout::known_type_for_size(ctx, layout.size)?;
101-
let name = Term::new(name, Span::call_site());
97+
let name = Ident::new(name, Span::call_site());
10298
Some(quote! { #name })
10399
}
104100

105101
/// Generates a bitfield allocation unit type for a type with the given `Layout`.
106-
pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
102+
pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> proc_macro2::TokenStream {
107103
let mut tokens = quote! {};
108104

109105
if ctx.options().enable_cxx_namespaces {
@@ -130,10 +126,9 @@ pub mod ast_ty {
130126
use ir::function::FunctionSig;
131127
use ir::layout::Layout;
132128
use ir::ty::FloatKind;
133-
use quote;
134129
use proc_macro2;
135130

136-
pub fn raw_type(ctx: &BindgenContext, name: &str) -> quote::Tokens {
131+
pub fn raw_type(ctx: &BindgenContext, name: &str) -> proc_macro2::TokenStream {
137132
let ident = ctx.rust_ident_raw(name);
138133
match ctx.options().ctypes_prefix {
139134
Some(ref prefix) => {
@@ -152,7 +147,7 @@ pub mod ast_ty {
152147
ctx: &BindgenContext,
153148
fk: FloatKind,
154149
layout: Option<Layout>,
155-
) -> quote::Tokens {
150+
) -> proc_macro2::TokenStream {
156151
// TODO: we probably should take the type layout into account more
157152
// often?
158153
//
@@ -192,25 +187,25 @@ pub mod ast_ty {
192187
}
193188
}
194189

195-
pub fn int_expr(val: i64) -> quote::Tokens {
190+
pub fn int_expr(val: i64) -> proc_macro2::TokenStream {
196191
// Don't use quote! { #val } because that adds the type suffix.
197192
let val = proc_macro2::Literal::i64_unsuffixed(val);
198193
quote!(#val)
199194
}
200195

201-
pub fn uint_expr(val: u64) -> quote::Tokens {
196+
pub fn uint_expr(val: u64) -> proc_macro2::TokenStream {
202197
// Don't use quote! { #val } because that adds the type suffix.
203198
let val = proc_macro2::Literal::u64_unsuffixed(val);
204199
quote!(#val)
205200
}
206201

207-
pub fn byte_array_expr(bytes: &[u8]) -> quote::Tokens {
202+
pub fn byte_array_expr(bytes: &[u8]) -> proc_macro2::TokenStream {
208203
let mut bytes: Vec<_> = bytes.iter().cloned().collect();
209204
bytes.push(0);
210205
quote! { [ #(#bytes),* ] }
211206
}
212207

213-
pub fn cstr_expr(mut string: String) -> quote::Tokens {
208+
pub fn cstr_expr(mut string: String) -> proc_macro2::TokenStream {
214209
string.push('\0');
215210
let b = proc_macro2::Literal::byte_string(&string.as_bytes());
216211
quote! {
@@ -221,7 +216,7 @@ pub mod ast_ty {
221216
pub fn float_expr(
222217
ctx: &BindgenContext,
223218
f: f64,
224-
) -> Result<quote::Tokens, ()> {
219+
) -> Result<proc_macro2::TokenStream, ()> {
225220
if f.is_finite() {
226221
let val = proc_macro2::Literal::f64_unsuffixed(f);
227222

@@ -255,7 +250,7 @@ pub mod ast_ty {
255250
pub fn arguments_from_signature(
256251
signature: &FunctionSig,
257252
ctx: &BindgenContext,
258-
) -> Vec<quote::Tokens> {
253+
) -> Vec<proc_macro2::TokenStream> {
259254
let mut unnamed_arguments = 0;
260255
signature
261256
.argument_types()

0 commit comments

Comments
 (0)