diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-13 21:19:10 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-13 21:19:10 +0100 |
commit | aaa7280a08b65aebe42b5405aec2bf72ae780885 (patch) | |
tree | 88644aee06f8dc7b42e6aea475c85fb3e9b1fbe8 /libbindgen/src/codegen | |
parent | 8c54a566457a1c4aacabf72977380c25c7fa10a1 (diff) |
Update aster and syntex.
Diffstat (limited to 'libbindgen/src/codegen')
-rw-r--r-- | libbindgen/src/codegen/helpers.rs | 5 | ||||
-rw-r--r-- | libbindgen/src/codegen/mod.rs | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/libbindgen/src/codegen/helpers.rs b/libbindgen/src/codegen/helpers.rs index c09f0071..b4cc75f5 100644 --- a/libbindgen/src/codegen/helpers.rs +++ b/libbindgen/src/codegen/helpers.rs @@ -153,7 +153,7 @@ pub mod ast_ty { } pub fn float_expr(f: f64) -> P<ast::Expr> { - use aster::str::ToInternedString; + use aster::symbol::ToSymbol; let mut string = f.to_string(); // So it gets properly recognised as a floating point constant. @@ -161,8 +161,7 @@ pub mod ast_ty { string.push('.'); } - let interned_str = string.as_str().to_interned_string(); - let kind = ast::LitKind::FloatUnsuffixed(interned_str); + let kind = ast::LitKind::FloatUnsuffixed(string.as_str().to_symbol()); aster::AstBuilder::new().expr().lit().build_lit(kind) } diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs index f8352cc8..b223783e 100644 --- a/libbindgen/src/codegen/mod.rs +++ b/libbindgen/src/codegen/mod.rs @@ -1863,16 +1863,19 @@ impl ToRustTy for Type { if let ast::TyKind::Path(_, ref mut path) = inner_ty.node { let template_args = template_args.iter() .map(|arg| arg.to_rust_ty(ctx)) - .collect(); + .collect::<Vec<_>>(); - path.segments.last_mut().unwrap().parameters = - ast::PathParameters::AngleBracketed( + path.segments.last_mut().unwrap().parameters = if template_args.is_empty() { + None + } else { + Some(P(ast::PathParameters::AngleBracketed( ast::AngleBracketedParameterData { lifetimes: vec![], types: P::from_vec(template_args), bindings: P::from_vec(vec![]), } - ); + ))) + } } P(inner_ty) |