Skip to content

Commit 7d1a38f

Browse files
authored
Merge pull request #19600 from github/redsun82/rust-new-macro-expansion-integration-test
Rust: add more macro expansion tests
2 parents 7ccae93 + ece075c commit 7d1a38f

File tree

18 files changed

+105
-105
lines changed

18 files changed

+105
-105
lines changed

rust/ql/integration-tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
target/
2+
Cargo.lock

rust/ql/integration-tests/macro-expansion/Cargo.lock

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
[workspace]
2-
members = ["macros"]
2+
members = [ "attributes", "calls", "proc_macros"]
33
resolver = "2"
4-
5-
[package]
6-
name = "macro_expansion"
7-
version = "0.1.0"
8-
edition = "2024"
9-
10-
[dependencies]
11-
macros = { path = "macros" }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "attributes"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
proc_macros = { path = "../proc_macros" }

rust/ql/integration-tests/macro-expansion/src/lib.rs renamed to rust/ql/integration-tests/macro-expansion/attributes/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use macros::repeat;
1+
use proc_macros::repeat;
22

33
#[repeat(3)]
44
fn foo() {
5-
println!("Hello, world!");
5+
_ = concat!("Hello ", "world!");
66

77
#[repeat(2)]
88
fn inner() {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "calls"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn included() {
2+
_ = concat!("Hello", " ", "world!"); // this doesn't expand (in included.rs) since 0.0.274
3+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
struct S;
2+
3+
macro_rules! def_x {
4+
() => {
5+
fn x() {}
6+
};
7+
}
8+
9+
impl S {
10+
def_x!(); // this doesn't expand since 0.0.274
11+
}
12+
13+
macro_rules! my_macro {
14+
($head:expr, $($tail:tt)*) => { format!($head, $($tail)*) };
15+
}
16+
17+
18+
fn test() {
19+
_ = concat!("x", "y");
20+
21+
_ = my_macro!(
22+
concat!("<", "{}", ">"), // this doesn't expand since 0.0.274
23+
"hi",
24+
);
25+
}
26+
27+
include!("included.rs");
28+
29+
#[doc = include_str!("some.txt")] // this doesn't expand since 0.0.274
30+
fn documented() {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hey!

rust/ql/integration-tests/macro-expansion/diagnostics.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"pretty": "__REDACTED__"
3939
}
4040
},
41-
"numberOfFiles": 2,
41+
"numberOfFiles": 4,
4242
"numberOfManifests": 1
4343
},
4444
"severity": "note",

0 commit comments

Comments
 (0)