Skip to content

Commit c51f2f8

Browse files
committed
Merge branch 'main' into redsun82/just2
2 parents c9cda74 + 5722084 commit c51f2f8

File tree

6 files changed

+310
-148
lines changed

6 files changed

+310
-148
lines changed

MODULE.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True
3737
# the versions there are canonical, the versions here are used for CI in github/codeql, as well as for the vendoring of dependencies.
3838
RUST_EDITION = "2024"
3939

40+
# run buildutils-internal/scripts/fill-rust-sha256s.py when updating (internal repo)
4041
RUST_VERSION = "1.86.0"
4142

4243
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
@@ -47,6 +48,29 @@ rust.toolchain(
4748
"x86_64-apple-darwin",
4849
"aarch64-apple-darwin",
4950
],
51+
# generated by buildutils-internal/scripts/fill-rust-sha256s.py (internal repo)
52+
sha256s = {
53+
"rustc-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "4438b809ce4a083af31ed17aeeedcc8fc60ccffc0625bef1926620751b6989d7",
54+
"rustc-1.86.0-x86_64-apple-darwin.tar.xz": "42b76253626febb7912541a30d3379f463dec89581aad4cb72c6c04fb5a71dc5",
55+
"rustc-1.86.0-aarch64-apple-darwin.tar.xz": "23b8f52102249a47ab5bc859d54c9a3cb588a3259ba3f00f557d50edeca4fde9",
56+
"rustc-1.86.0-x86_64-pc-windows-msvc.tar.xz": "fdde839fea274529a31e51eb85c6df1782cc8479c9d1bc24e2914d66a0de41ab",
57+
"clippy-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "02aaff2c1407d2da8dba19aa4970dd873e311902b120a66cbcdbe51eb8836edf",
58+
"clippy-1.86.0-x86_64-apple-darwin.tar.xz": "bb85efda7bbffaf124867f5ca36d50932b1e8f533c62ee923438afb32ff8fe9a",
59+
"clippy-1.86.0-aarch64-apple-darwin.tar.xz": "239fa3a604b124f0312f2af08537874a1227dba63385484b468cca62e7c4f2f2",
60+
"clippy-1.86.0-x86_64-pc-windows-msvc.tar.xz": "d00498f47d49219f032e2c5eeebdfc3d32317c0dc3d3fd7125327445bc482cb4",
61+
"cargo-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "c5c1590f7e9246ad9f4f97cfe26ffa92707b52a769726596a9ef81565ebd908b",
62+
"cargo-1.86.0-x86_64-apple-darwin.tar.xz": "af163eb02d1a178044d1b4f2375960efd47130f795f6e33d09e345454bb26f4e",
63+
"cargo-1.86.0-aarch64-apple-darwin.tar.xz": "3cb13873d48c3e1e4cc684d42c245226a11fba52af6b047c3346ed654e7a05c0",
64+
"cargo-1.86.0-x86_64-pc-windows-msvc.tar.xz": "e57a9d89619b5604899bac443e68927bdd371e40f2e03e18950b6ceb3eb67966",
65+
"llvm-tools-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "282145ab7a63c98b625856f44b905b4dc726b497246b824632a5790debe95a78",
66+
"llvm-tools-1.86.0-x86_64-apple-darwin.tar.xz": "b55706e92f7da989207c50c13c7add483a9fedd233bc431b106eca2a8f151ec9",
67+
"llvm-tools-1.86.0-aarch64-apple-darwin.tar.xz": "04d3618c686845853585f036e3211eb9e18f2d290f4610a7a78bdc1fcce1ebd9",
68+
"llvm-tools-1.86.0-x86_64-pc-windows-msvc.tar.xz": "721a17cc8dc219177e4277a3592253934ef08daa1e1b12eda669a67d15fad8dd",
69+
"rust-std-1.86.0-x86_64-unknown-linux-gnu.tar.xz": "67be7184ea388d8ce0feaf7fdea46f1775cfc2970930264343b3089898501d37",
70+
"rust-std-1.86.0-x86_64-apple-darwin.tar.xz": "3b1140d54870a080080e84700143f4a342fbd02a410a319b05d9c02e7dcf44cc",
71+
"rust-std-1.86.0-aarch64-apple-darwin.tar.xz": "0fb121fb3b8fa9027d79ff598500a7e5cd086ddbc3557482ed3fdda00832c61b",
72+
"rust-std-1.86.0-x86_64-pc-windows-msvc.tar.xz": "3d5354b7b9cb950b58bff3fce18a652aa374bb30c8f70caebd3bd0b43cb41a33",
73+
},
5074
versions = [RUST_VERSION],
5175
)
5276
use_repo(rust, "rust_toolchains")

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,14 +1045,15 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
10451045
}
10461046

10471047
pragma[nomagic]
1048-
private StructType inferLiteralType(LiteralExpr le) {
1048+
private StructType getStrStruct() { result = TStruct(any(Builtins::Str s)) }
1049+
1050+
pragma[nomagic]
1051+
private Type inferLiteralType(LiteralExpr le, TypePath path) {
1052+
path.isEmpty() and
10491053
exists(Builtins::BuiltinType t | result = TStruct(t) |
10501054
le instanceof CharLiteralExpr and
10511055
t instanceof Builtins::Char
10521056
or
1053-
le instanceof StringLiteralExpr and
1054-
t instanceof Builtins::Str
1055-
or
10561057
le =
10571058
any(NumberLiteralExpr ne |
10581059
t.getName() = ne.getSuffix()
@@ -1070,6 +1071,14 @@ private StructType inferLiteralType(LiteralExpr le) {
10701071
le instanceof BooleanLiteralExpr and
10711072
t instanceof Builtins::Bool
10721073
)
1074+
or
1075+
le instanceof StringLiteralExpr and
1076+
(
1077+
path.isEmpty() and result = TRefType()
1078+
or
1079+
path = TypePath::singleton(TRefTypeParameter()) and
1080+
result = getStrStruct()
1081+
)
10731082
}
10741083

10751084
pragma[nomagic]
@@ -1635,8 +1644,7 @@ private module Cached {
16351644
or
16361645
result = inferTryExprType(n, path)
16371646
or
1638-
result = inferLiteralType(n) and
1639-
path.isEmpty()
1647+
result = inferLiteralType(n, path)
16401648
or
16411649
result = inferAsyncBlockExprRootType(n) and
16421650
path.isEmpty()

rust/ql/test/library-tests/type-inference/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ mod builtins {
14131413
let z = x + y; // $ type=z:i32 method=add
14141414
let z = x.abs(); // $ method=abs $ type=z:i32
14151415
let c = 'c'; // $ type=c:char
1416-
let hello = "Hello"; // $ type=hello:str
1416+
let hello = "Hello"; // $ type=hello:&T.str
14171417
let f = 123.0f64; // $ type=f:f64
14181418
let t = true; // $ type=t:bool
14191419
let f = false; // $ type=f:bool
@@ -2086,10 +2086,10 @@ mod loops {
20862086
let vals4: [u64; 3] = [1; 3]; // $ type=vals4:[T;...].u64
20872087
for u in vals4 {} // $ type=u:u64
20882088

2089-
let mut strings1 = ["foo", "bar", "baz"]; // $ type=strings1:[T;...].str
2090-
for s in &strings1 {} // $ type=s:&T.str
2091-
for s in &mut strings1 {} // $ type=s:&T.str
2092-
for s in strings1 {} // $ type=s:str
2089+
let mut strings1 = ["foo", "bar", "baz"]; // $ type=strings1:[T;...].&T.str
2090+
for s in &strings1 {} // $ type=s:&T.&T.str
2091+
for s in &mut strings1 {} // $ type=s:&T.&T.str
2092+
for s in strings1 {} // $ type=s:&T.str
20932093

20942094
let strings2 = // $ type=strings2:[T;...].String
20952095
[

0 commit comments

Comments
 (0)