From 2227223a96b0016ec960a8d5ba354d8c889ecc68 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Sun, 15 Oct 2023 15:45:18 +1100 Subject: [PATCH] aya-log: fix hygiene Before this change we leaked some bindings to the calling scope, so for instance logging a variable named "len" led to a compile error. --- aya-log-ebpf-macros/src/expand.rs | 21 ++++++++++++--------- test/integration-ebpf/src/log.rs | 5 +++++ test/integration-test/src/tests/log.rs | 9 +++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/aya-log-ebpf-macros/src/expand.rs b/aya-log-ebpf-macros/src/expand.rs index efc1a943..fb4630b3 100644 --- a/aya-log-ebpf-macros/src/expand.rs +++ b/aya-log-ebpf-macros/src/expand.rs @@ -1,6 +1,6 @@ use aya_log_common::DisplayHint; use aya_log_parser::{parse, Fragment}; -use proc_macro2::TokenStream; +use proc_macro2::{Ident, Span, TokenStream}; use quote::quote; use syn::{ parse::{Parse, ParseStream}, @@ -141,13 +141,16 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result {}, Some(::aya_log_ebpf::LogBuf { buf }) => { let _: Option<()> = (|| { - let size = ::aya_log_ebpf::write_record_header( + let #size = ::aya_log_ebpf::write_record_header( buf, #target, #lvl, @@ -156,14 +159,14 @@ pub(crate) fn log(args: LogArgs, level: Option) -> Result