mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-28 01:41:05 +00:00
Preserve original tokens of Signature
This commit is contained in:
parent
33d3029780
commit
d95b119931
@ -116,6 +116,7 @@ impl PartialEq for Signature {
|
||||
args,
|
||||
ret,
|
||||
throws,
|
||||
tokens: _,
|
||||
} = self;
|
||||
let Signature {
|
||||
fn_token: _,
|
||||
@ -123,6 +124,7 @@ impl PartialEq for Signature {
|
||||
args: args2,
|
||||
ret: ret2,
|
||||
throws: throws2,
|
||||
tokens: _,
|
||||
} = other;
|
||||
receiver == receiver2 && args == args2 && ret == ret2 && throws == throws2
|
||||
}
|
||||
@ -136,6 +138,7 @@ impl Hash for Signature {
|
||||
args,
|
||||
ret,
|
||||
throws,
|
||||
tokens: _,
|
||||
} = self;
|
||||
receiver.hash(state);
|
||||
args.hash(state);
|
||||
|
@ -12,7 +12,7 @@ pub mod set;
|
||||
mod tokens;
|
||||
pub mod types;
|
||||
|
||||
use proc_macro2::{Ident, Span};
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use syn::{LitStr, Token};
|
||||
|
||||
pub use self::atom::Atom;
|
||||
@ -57,6 +57,7 @@ pub struct Signature {
|
||||
pub args: Vec<Var>,
|
||||
pub ret: Option<Type>,
|
||||
pub throws: bool,
|
||||
pub tokens: TokenStream,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash)]
|
||||
|
@ -205,7 +205,11 @@ fn parse_extern_fn(foreign_fn: &ForeignItemFn, lang: Lang) -> Result<ExternFn> {
|
||||
let doc = attrs::parse_doc(&foreign_fn.attrs)?;
|
||||
let fn_token = foreign_fn.sig.fn_token;
|
||||
let ident = foreign_fn.sig.ident.clone();
|
||||
let mut foreign_fn2 = foreign_fn.clone();
|
||||
foreign_fn2.attrs.clear();
|
||||
let tokens = quote!(#foreign_fn2);
|
||||
let semi_token = foreign_fn.semi_token;
|
||||
|
||||
Ok(ExternFn {
|
||||
lang,
|
||||
doc,
|
||||
@ -216,6 +220,7 @@ fn parse_extern_fn(foreign_fn: &ForeignItemFn, lang: Lang) -> Result<ExternFn> {
|
||||
args,
|
||||
ret,
|
||||
throws,
|
||||
tokens,
|
||||
},
|
||||
semi_token,
|
||||
})
|
||||
|
@ -77,8 +77,6 @@ impl ToTokens for Derive {
|
||||
|
||||
impl ToTokens for ExternFn {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
self.fn_token.to_tokens(tokens);
|
||||
self.ident.to_tokens(tokens);
|
||||
self.semi_token.to_tokens(tokens);
|
||||
self.sig.tokens.to_tokens(tokens);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user