Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rust: Type inference for non-overloadable operators #19549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Rust: Add type inference tests for operators
  • Loading branch information
paldepind committed May 21, 2025
commit 0dcf15bf7733ce7c37e45b0a0349f307f1168985
16 changes: 16 additions & 0 deletions 16 rust/ql/test/library-tests/type-inference/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,21 @@ mod builtins {
}
}

mod operators {
pub fn f() {
let x = true && false; // $ MISSING: type=x:bool
let y = true || false; // $ MISSING: type=y:bool

let mut a;
if 34 == 33 {
let z = (a = 1); // $ MISSING: type=z:() MISSING: type=a:i32
} else {
a = 2; // $ MISSING: type=a:i32
}
a; // $ MISSING: type=a:i32
}
}

fn main() {
field_access::f();
method_impl::f();
Expand All @@ -1242,4 +1257,5 @@ fn main() {
borrowed_typed::f();
try_expressions::f();
builtins::f();
operators::f();
}
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,15 @@ inferType
| main.rs:1222:17:1222:20 | true | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1223:13:1223:13 | f | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1223:17:1223:21 | false | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1229:5:1229:20 | ...::f(...) | | main.rs:67:5:67:21 | Foo |
| main.rs:1230:5:1230:60 | ...::g(...) | | main.rs:67:5:67:21 | Foo |
| main.rs:1230:20:1230:38 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
| main.rs:1230:41:1230:59 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
| main.rs:1229:17:1229:20 | true | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1229:25:1229:29 | false | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1230:17:1230:20 | true | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1230:25:1230:29 | false | | file:///BUILTINS/types.rs:3:1:5:16 | bool |
| main.rs:1233:12:1233:13 | 34 | | file:///BUILTINS/types.rs:12:1:12:15 | i32 |
| main.rs:1233:18:1233:19 | 33 | | file:///BUILTINS/types.rs:12:1:12:15 | i32 |
| main.rs:1234:26:1234:26 | 1 | | file:///BUILTINS/types.rs:12:1:12:15 | i32 |
| main.rs:1236:17:1236:17 | 2 | | file:///BUILTINS/types.rs:12:1:12:15 | i32 |
| main.rs:1244:5:1244:20 | ...::f(...) | | main.rs:67:5:67:21 | Foo |
| main.rs:1245:5:1245:60 | ...::g(...) | | main.rs:67:5:67:21 | Foo |
| main.rs:1245:20:1245:38 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
| main.rs:1245:41:1245:59 | ...::Foo {...} | | main.rs:67:5:67:21 | Foo |
Morty Proxy This is a proxified and sanitized view of the page, visit original site.