lib.rs: Be explicit about the proc_macro::TokenStream input/output vs....

lib.rs: Be explicit about the proc_macro::TokenStream input/output vs. proc_macro2::TokenStream for internal work
parent 96531aa6
// We give `ClassName` variables an identifier that uses upper-case.
#![allow(non_snake_case)]
use proc_macro::TokenStream;
use proc_macro2::{Ident};
use proc_macro2::{Ident, TokenStream};
use std::fmt::Display;
mod boilerplate;
......
......@@ -21,7 +21,6 @@ extern crate glib_sys;
extern crate gobject_sys;
use errors::*;
use proc_macro::TokenStream;
use std::error::Error;
mod ast;
......@@ -138,7 +137,7 @@ mod parser;
/// ```
///
#[proc_macro]
pub fn gobject_gen(input: TokenStream) -> TokenStream {
pub fn gobject_gen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let ast_program = match parser::parse_program(input) {
Ok(p) => p,
Err(e) => {
......@@ -150,7 +149,7 @@ pub fn gobject_gen(input: TokenStream) -> TokenStream {
}
};
let result: Result<TokenStream> =
let result: Result<proc_macro2::TokenStream> =
hir::Program::from_ast_program(&ast_program).and_then(|program| Ok(gen::codegen(&program)));
match result {
......@@ -166,14 +165,14 @@ pub fn gobject_gen(input: TokenStream) -> TokenStream {
println!("/********************************************************************************/\n{}", output);
tokens.into()
}
Err(e) => error_to_compile_error(&e.0),
Err(e) => error_to_compile_error(&e.0).into(),
}
}
Err(e) => error_to_compile_error(&e),
Err(e) => error_to_compile_error(&e).into(),
}
}
fn error_to_compile_error<E: Error>(e: &E) -> TokenStream {
fn error_to_compile_error<E: Error>(e: &E) -> proc_macro2::TokenStream {
let desc = e.description();
let tokens = quote! {
compile_error!(#desc);
......@@ -183,7 +182,7 @@ fn error_to_compile_error<E: Error>(e: &E) -> TokenStream {
}
#[proc_macro]
pub fn testme(input: TokenStream) -> TokenStream {
pub fn testme(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
checking::tests::run();
glib_utils::tests::run();
hir::tests::run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment