Rust: Type inference for macro expressions

This commit is contained in:
Tom Hvitved
2025-06-13 11:04:39 +02:00
parent fd59a27bd2
commit 2f698d1590
3 changed files with 7 additions and 1 deletions

View File

@@ -265,6 +265,8 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
n1 = be.getLhs() and
n2 = be.getRhs()
)
or
n1 = n2.(MacroExpr).getMacroCall().getMacroCallExpansion()
)
or
n1 = n2.(RefExpr).getExpr() and

View File

@@ -1812,7 +1812,7 @@ mod indexers {
mod macros {
pub fn f() {
let x = format!("Hello, {}", "World!"); // $ MISSING: type=x:String
let x = format!("Hello, {}", "World!"); // $ MISSING: type=x:String -- needs https://github.com/github/codeql/pull/19658
}
}

View File

@@ -1021,8 +1021,12 @@ inferType
| main.rs:912:19:912:22 | self | Snd | main.rs:910:15:910:17 | Snd |
| main.rs:913:43:913:82 | MacroExpr | | main.rs:910:15:910:17 | Snd |
| main.rs:913:50:913:81 | "PairNone has no second elemen... | | {EXTERNAL LOCATION} | str |
| main.rs:913:50:913:81 | MacroExpr | | main.rs:910:15:910:17 | Snd |
| main.rs:913:50:913:81 | { ... } | | main.rs:910:15:910:17 | Snd |
| main.rs:914:43:914:81 | MacroExpr | | main.rs:910:15:910:17 | Snd |
| main.rs:914:50:914:80 | "PairFst has no second element... | | {EXTERNAL LOCATION} | str |
| main.rs:914:50:914:80 | MacroExpr | | main.rs:910:15:910:17 | Snd |
| main.rs:914:50:914:80 | { ... } | | main.rs:910:15:910:17 | Snd |
| main.rs:915:37:915:39 | snd | | main.rs:910:15:910:17 | Snd |
| main.rs:915:45:915:47 | snd | | main.rs:910:15:910:17 | Snd |
| main.rs:916:41:916:43 | snd | | main.rs:910:15:910:17 | Snd |