Skip to content

Commit b57a67c

Browse files
paldepindCopilot
andcommitted
Rust: Test dependency modules disabled by richer configurations
Cover macro expansion in a dependency module that is inactive under the preferred configuration, including richer, tied, and reversed manifest cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d675ac38-ec3b-47ee-8b48-268c63fc7777
1 parent c3fdbd8 commit b57a67c

8 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎rust/ql/integration-tests/dependency-features/dependencies/alpha/src/lib.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
#[cfg(feature = "a")]
1+
#[cfg(all(feature = "a", feature = "b"))]
22
pub fn a() {}
33

4+
#[cfg(all(feature = "a", not(feature = "b")))]
5+
mod only_a;
6+
7+
#[cfg(all(feature = "a", not(feature = "b")))]
8+
pub use only_a::a;
9+
410
#[cfg(feature = "b")]
511
pub fn b() {}
612

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
macro_rules! define_a {
2+
() => {
3+
pub fn a() {}
4+
};
5+
}
6+
7+
define_a!();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import rust
2+
3+
from Function f
4+
where f.getFile().getBaseName() = "only_a.rs"
5+
select f, f.getName()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| dependencies/alpha/src/only_a.rs:7:1:7:9 | fn a | dependencies/alpha/src/only_a.rs:7:1:7:9 | a |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| dependencies/alpha/src/only_a.rs:7:1:7:9 | fn a | dependencies/alpha/src/only_a.rs:7:1:7:9 | a |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| dependencies/alpha/src/only_a.rs:7:1:7:9 | fn a | dependencies/alpha/src/only_a.rs:7:1:7:9 | a |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| dependencies/alpha/src/only_a.rs:7:1:7:9 | fn a | dependencies/alpha/src/only_a.rs:7:1:7:9 | a |

‎rust/ql/integration-tests/dependency-features/test_dependency_features.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def test_dependency_features(codeql, rust, cwd, configurations, reverse):
5252
to different calls depending on the enabled features. The `functions.ql`
5353
query checks which calls and targets are extracted for the `src/lib.rs`
5454
files.
55+
56+
Alpha's `only_a` module is disabled by feature `b`. Its item macro must still
57+
be expanded using a configuration in which the module is enabled, even when
58+
a richer configuration wins for alpha's other files.
5559
"""
5660
if reverse:
5761
configurations = configurations[::-1]

0 commit comments

Comments
 (0)