Skip to content

Commit 7d5664f

Browse files
committed
Address review comment
1 parent f850025 commit 7d5664f

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,20 +2826,10 @@ private AssociatedTypeTypeParameter getFutureOutputTypeParameter() {
28262826
result.getTypeAlias() = any(FutureTrait ft).getOutputType()
28272827
}
28282828

2829-
private predicate isReturnExprCfgAncestor(AstNode n) {
2830-
n instanceof ReturnExpr
2831-
or
2832-
exists(AstNode mid |
2833-
isReturnExprCfgAncestor(mid) and
2834-
n = mid.getParentNode() and
2835-
n.getEnclosingCfgScope() = mid.getEnclosingCfgScope()
2836-
)
2837-
}
2838-
28392829
pragma[nomagic]
28402830
predicate isUnitBlockExpr(BlockExpr be) {
28412831
not be.getStmtList().hasTailExpr() and
2842-
not isReturnExprCfgAncestor(be) and
2832+
not be = any(Callable c).getBody() and
28432833
not be.hasLabel()
28442834
}
28452835

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2865,7 +2865,7 @@ mod block_types {
28652865

28662866
#[rustfmt::skip]
28672867
fn f4(cond: bool) -> i32 {
2868-
let a = { // $ MISSING: certainType=a:()
2868+
let a = { // $ certainType=a:()
28692869
if cond {
28702870
return 12;
28712871
};

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6476,15 +6476,19 @@ inferType
64766476
| main.rs:2863:16:2863:16 | 0 | | {EXTERNAL LOCATION} | i32 |
64776477
| main.rs:2867:11:2867:14 | cond | | {EXTERNAL LOCATION} | bool |
64786478
| main.rs:2867:30:2875:5 | { ... } | | {EXTERNAL LOCATION} | i32 |
6479+
| main.rs:2868:13:2868:13 | a | | file://:0:0:0:0 | () |
6480+
| main.rs:2868:17:2872:9 | { ... } | | file://:0:0:0:0 | () |
64796481
| main.rs:2869:13:2871:13 | if cond {...} | | file://:0:0:0:0 | () |
64806482
| main.rs:2869:16:2869:19 | cond | | {EXTERNAL LOCATION} | bool |
6483+
| main.rs:2869:21:2871:13 | { ... } | | file://:0:0:0:0 | () |
64816484
| main.rs:2870:24:2870:25 | 12 | | {EXTERNAL LOCATION} | i32 |
64826485
| main.rs:2873:18:2873:26 | "a: {:?}\\n" | | file://:0:0:0:0 | & |
64836486
| main.rs:2873:18:2873:26 | "a: {:?}\\n" | &T | {EXTERNAL LOCATION} | str |
64846487
| main.rs:2873:18:2873:29 | ...::_print(...) | | file://:0:0:0:0 | () |
64856488
| main.rs:2873:18:2873:29 | FormatArgsExpr | | {EXTERNAL LOCATION} | Arguments |
64866489
| main.rs:2873:18:2873:29 | MacroExpr | | {EXTERNAL LOCATION} | Arguments |
64876490
| main.rs:2873:18:2873:29 | { ... } | | file://:0:0:0:0 | () |
6491+
| main.rs:2873:29:2873:29 | a | | file://:0:0:0:0 | () |
64886492
| main.rs:2874:9:2874:9 | 0 | | {EXTERNAL LOCATION} | i32 |
64896493
| main.rs:2883:11:2918:1 | { ... } | | file://:0:0:0:0 | () |
64906494
| main.rs:2884:5:2884:21 | ...::f(...) | | file://:0:0:0:0 | () |

0 commit comments

Comments
 (0)