mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
There was a mismatch between a `self.macro_context_level += 1` and the corresponding `self.macro_context_level -= 1`, which resulted in an `usize` underflow (panic in debug mode, wrong behaviour in release mode). This fixes it and adds a relevant assertion and test. In order to properly test library mode extraction, a special option enforcing that on source code as well is added.
15 lines
395 B
Rust
15 lines
395 B
Rust
use proc_macro::TokenStream;
|
|
use quote::quote;
|
|
|
|
#[proc_macro_attribute]
|
|
pub fn add_one(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
let ast = syn::parse_macro_input!(item as syn::ItemFn);
|
|
let mut new_ast = ast.clone();
|
|
new_ast.sig.ident = syn::Ident::new(&format!("{}_new", ast.sig.ident), ast.sig.ident.span());
|
|
quote! {
|
|
#ast
|
|
#new_ast
|
|
}.into()
|
|
}
|
|
|