Skip to content

Commit 4346178

Browse files
committed
Rust: Add type inference regression tests for cfg!
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2b6b35e8-4f05-4cf7-b229-2ddc3ebdd83c
1 parent 052953c commit 4346178

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub fn expressions() {
2+
let unix = cfg!(unix); // $ MISSING: certainType=unix:bool
3+
let windows = cfg!(target_os = "windows"); // $ MISSING: certainType=windows:bool
4+
let either = cfg!(any(unix, target_os = "windows")); // $ MISSING: certainType=either:bool
5+
let always = cfg!(all()); // $ MISSING: certainType=always:bool
6+
let never = cfg!(any()); // $ MISSING: certainType=never:bool
7+
}
8+
9+
pub fn patterns() {
10+
let value = Default::default(); // $ MISSING: target=default type=value:bool
11+
match value {
12+
cfg!(unix) => (),
13+
cfg!(target_os = "windows") => (),
14+
cfg!(any(unix, target_os = "windows")) => (),
15+
_ => (),
16+
}
17+
}

‎rust/ql/test/library-tests/type-inference/type-inference.expected‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@ inferCertainType
508508
| blanket_impl.rs:299:44:299:44 | c | | blanket_impl.rs:286:5:286:29 | MySqlConnection |
509509
| blanket_impl.rs:299:47:299:67 | "SELECT * FROM users" | | {EXTERNAL LOCATION} | & |
510510
| blanket_impl.rs:299:47:299:67 | "SELECT * FROM users" | TRef | {EXTERNAL LOCATION} | str |
511+
| cfg.rs:1:22:7:1 | { ... } | | {EXTERNAL LOCATION} | () |
512+
| cfg.rs:12:23:12:24 | TupleExpr | | {EXTERNAL LOCATION} | () |
513+
| cfg.rs:13:40:13:41 | TupleExpr | | {EXTERNAL LOCATION} | () |
514+
| cfg.rs:14:51:14:52 | TupleExpr | | {EXTERNAL LOCATION} | () |
515+
| cfg.rs:15:14:15:15 | TupleExpr | | {EXTERNAL LOCATION} | () |
511516
| closure.rs:4:19:39:5 | { ... } | | {EXTERNAL LOCATION} | () |
512517
| closure.rs:6:13:6:22 | my_closure | | {EXTERNAL LOCATION} | dyn Fn |
513518
| closure.rs:6:13:6:22 | my_closure | dyn(Args) | {EXTERNAL LOCATION} | (T_2) |
@@ -6003,6 +6008,13 @@ inferType
60036008
| blanket_impl.rs:299:44:299:44 | c | | blanket_impl.rs:286:5:286:29 | MySqlConnection |
60046009
| blanket_impl.rs:299:47:299:67 | "SELECT * FROM users" | | {EXTERNAL LOCATION} | & |
60056010
| blanket_impl.rs:299:47:299:67 | "SELECT * FROM users" | TRef | {EXTERNAL LOCATION} | str |
6011+
| cfg.rs:1:22:7:1 | { ... } | | {EXTERNAL LOCATION} | () |
6012+
| cfg.rs:9:19:17:1 | { ... } | | {EXTERNAL LOCATION} | () |
6013+
| cfg.rs:11:5:16:5 | match value { ... } | | {EXTERNAL LOCATION} | () |
6014+
| cfg.rs:12:23:12:24 | TupleExpr | | {EXTERNAL LOCATION} | () |
6015+
| cfg.rs:13:40:13:41 | TupleExpr | | {EXTERNAL LOCATION} | () |
6016+
| cfg.rs:14:51:14:52 | TupleExpr | | {EXTERNAL LOCATION} | () |
6017+
| cfg.rs:15:14:15:15 | TupleExpr | | {EXTERNAL LOCATION} | () |
60066018
| closure.rs:4:19:39:5 | { ... } | | {EXTERNAL LOCATION} | () |
60076019
| closure.rs:6:13:6:22 | my_closure | | {EXTERNAL LOCATION} | dyn Fn |
60086020
| closure.rs:6:13:6:22 | my_closure | dyn(Args) | {EXTERNAL LOCATION} | (T_2) |

0 commit comments

Comments
 (0)