Skip to content

Commit

Permalink
Don't pass inline macro name to macro args token stream (#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Nov 29, 2024
1 parent 715f414 commit 3342e75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scarb/src/compiler/plugin/proc_macro/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,8 @@ impl InlineMacroExprPlugin for ProcMacroInlinePlugin {
_metadata: &MacroPluginMetadata<'_>,
) -> InlinePluginResult {
let stable_ptr = syntax.clone().stable_ptr().untyped();
let token_stream = TokenStream::from_syntax_node(db, syntax);
let arguments = syntax.arguments(db);
let token_stream = TokenStream::from_syntax_node(db, &arguments);
let result = self.instance().generate_code(
self.expansion.name.clone(),
TokenStream::empty(),
Expand Down
8 changes: 6 additions & 2 deletions scarb/tests/build_cairo_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ fn can_implement_inline_macro() {
use cairo_lang_macro::{ProcMacroResult, TokenStream, inline_macro};
#[inline_macro]
pub fn some(_token_stream: TokenStream) -> ProcMacroResult {
pub fn some(token_stream: TokenStream) -> ProcMacroResult {
assert_eq!(token_stream.to_string(), "()");
ProcMacroResult::new(TokenStream::new("34".to_string()))
}
"##})
Expand All @@ -879,7 +880,10 @@ fn can_implement_inline_macro() {
.version("1.0.0")
.dep("some", &t)
.lib_cairo(indoc! {r#"
fn main() -> felt252 { some!() }
fn main() -> felt252 {
let x = some!();
x
}
"#})
.build(&project);

Expand Down

0 comments on commit 3342e75

Please sign in to comment.