Skip to content

Commit 212ceed

Browse files
committed
Rust: Do not infer any types for !-typed expressions
1 parent edfe5f3 commit 212ceed

3 files changed

Lines changed: 1 addition & 6 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,9 +3094,6 @@ private module Input3 implements InputSig3 {
30943094
(
30953095
n.(AssocFunctionResolution::AssocFunctionCall).resolutionDependsOnReturnType(path)
30963096
or
3097-
path.isEmpty() and
3098-
isPanicMacroCall(n)
3099-
or
31003097
n.(ArrayListExpr).getNumberOfExprs() = 0 and
31013098
path = TypePath::singleton(getArrayTypeParameter())
31023099
)

rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ private module MkTypeMention<getAdditionalPathTypeAtSig/2 getAdditionalPathTypeA
678678
}
679679

680680
class NeverTypeReprMention extends TypeMentionImpl, NeverTypeRepr {
681-
override Type getTypeAt(TypePath path) { result = TUnknownType() and path.isEmpty() }
681+
override Type getTypeAt(TypePath path) { none() }
682682
}
683683

684684
class PtrTypeReprMention extends TypeMentionImpl instanceof PtrTypeRepr {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8994,7 +8994,6 @@ inferType
89948994
| main.rs:983:17:983:38 | ...::PairNone(...) | | main.rs:972:5:978:5 | PairOption |
89958995
| main.rs:983:17:983:38 | ...::PairNone(...) | Fst | main.rs:980:10:980:12 | Fst |
89968996
| main.rs:983:17:983:38 | ...::PairNone(...) | Snd | main.rs:980:15:980:17 | Snd |
8997-
| main.rs:983:43:983:82 | MacroExpr | | main.rs:980:15:980:17 | Snd |
89988997
| main.rs:983:50:983:81 | "PairNone has no second elemen... | | {EXTERNAL LOCATION} | & |
89998998
| main.rs:983:50:983:81 | "PairNone has no second elemen... | TRef | {EXTERNAL LOCATION} | str |
90008999
| main.rs:983:50:983:81 | MacroExpr | | {EXTERNAL LOCATION} | () |
@@ -9003,7 +9002,6 @@ inferType
90039002
| main.rs:984:17:984:38 | ...::PairFst(...) | Fst | main.rs:980:10:980:12 | Fst |
90049003
| main.rs:984:17:984:38 | ...::PairFst(...) | Snd | main.rs:980:15:980:17 | Snd |
90059004
| main.rs:984:37:984:37 | _ | | main.rs:980:10:980:12 | Fst |
9006-
| main.rs:984:43:984:81 | MacroExpr | | main.rs:980:15:980:17 | Snd |
90079005
| main.rs:984:50:984:80 | "PairFst has no second element... | | {EXTERNAL LOCATION} | & |
90089006
| main.rs:984:50:984:80 | "PairFst has no second element... | TRef | {EXTERNAL LOCATION} | str |
90099007
| main.rs:984:50:984:80 | MacroExpr | | {EXTERNAL LOCATION} | () |

0 commit comments

Comments
 (0)