Skip to content

Commit 7da7416

Browse files
Paolo TranquilliCopilot
andcommitted
Rust: Test proc macros across concurrently loaded workspaces
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8d0772f66a6b42c7b59d25b5e8f4073d
1 parent 33d2cd3 commit 7da7416

9 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
[package]
3+
name = "a"
4+
version = "0.1.0"
5+
edition = "2024"
6+
7+
[dependencies]
8+
macros = { path = "../macros" }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
macros::generate!(a);
2+
3+
pub fn call() -> u32 {
4+
from_a()
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
[package]
3+
name = "b"
4+
version = "0.1.0"
5+
edition = "2024"
6+
7+
[dependencies]
8+
macros = { path = "../macros" }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
macros::generate!(b);
2+
3+
pub fn call() -> u32 {
4+
from_b()
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| a/src/lib.rs:4:5:4:12 | from_a(...) | a::from_a |
2+
| b/src/lib.rs:4:5:4:12 | from_b(...) | b::from_b |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rust
2+
3+
from Call c, Function target
4+
where c.fromSource() and target = c.getStaticTarget() and target.getName().getText().matches("from_%")
5+
select c, target.getCanonicalPath()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
[package]
3+
name = "macros"
4+
version = "0.1.0"
5+
edition = "2024"
6+
7+
[lib]
8+
proc-macro = true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extern crate proc_macro;
2+
3+
#[proc_macro]
4+
pub fn generate(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
5+
format!("pub fn from_{input}() -> u32 {{ 42 }}").parse().unwrap()
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
@pytest.mark.parametrize("threads", [1, 4])
5+
def test_proc_macro_workspaces(codeql, rust, threads):
6+
codeql.database.create(threads=threads)

0 commit comments

Comments
 (0)