Skip to content

Commit 715f45d

Browse files
committed
temp
1 parent 7bed818 commit 715f45d

File tree

8 files changed

+1264
-655
lines changed

8 files changed

+1264
-655
lines changed

rust/ql/lib/codeql/rust/elements/internal/OperationImpl.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ predicate isOverloaded(string op, int arity, string path, string method, int bor
8383
op = "<<=" and path = "core::ops::bit::ShlAssign" and method = "shl_assign" and borrows = 1
8484
or
8585
op = ">>=" and path = "core::ops::bit::ShrAssign" and method = "shr_assign" and borrows = 1
86+
or
87+
// Index operator
88+
op = "[]" and path = "core::ops::index::Index" and method = "index" and borrows = 1
8689
)
8790
}
8891

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
641641

642642
TraitItemNode resolveTraitTy() { result = resolvePath(this.getTraitPath()) }
643643

644+
predicate isBlanket() { this.resolveSelfTy() instanceof TypeParam }
645+
644646
override AssocItemNode getAnAssocItem() { result = this.getADescendant() }
645647

646648
override string getName() { result = "(impl)" }
@@ -726,7 +728,7 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
726728
}
727729
}
728730

729-
final private class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
731+
final class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
730732
pragma[nomagic]
731733
Path getABoundPath() {
732734
result = super.getTypeBoundList().getABound().getTypeRepr().(PathTypeRepr).getPath()

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ newtype TType =
4747
TImplTraitType(ImplTraitTypeRepr impl) or
4848
TDynTraitType(Trait t) { t = any(DynTraitTypeRepr dt).getTrait() } or
4949
TSliceType() or
50+
TNeverType() or
51+
TPtrType() or
5052
TTupleTypeParameter(int arity, int i) { exists(TTuple(arity)) and i in [0 .. arity - 1] } or
5153
TTypeParamTypeParameter(TypeParam t) or
5254
TAssociatedTypeTypeParameter(TypeAlias t) { any(TraitItemNode trait).getAnAssocItem() = t } or
@@ -57,7 +59,8 @@ newtype TType =
5759
} or
5860
TRefTypeParameter() or
5961
TSelfTypeParameter(Trait t) or
60-
TSliceTypeParameter()
62+
TSliceTypeParameter() or
63+
TPtrTypeParameter()
6164

6265
private predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
6366
implTrait.isInReturnPos() and
@@ -374,6 +377,33 @@ class SliceType extends Type, TSliceType {
374377
override Location getLocation() { result instanceof EmptyLocation }
375378
}
376379

380+
class NeverType extends Type, TNeverType {
381+
override StructField getStructField(string name) { none() }
382+
383+
override TupleField getTupleField(int i) { none() }
384+
385+
override TypeParameter getPositionalTypeParameter(int i) { none() }
386+
387+
override string toString() { result = "!" }
388+
389+
override Location getLocation() { result instanceof EmptyLocation }
390+
}
391+
392+
class PtrType extends Type, TPtrType {
393+
override StructField getStructField(string name) { none() }
394+
395+
override TupleField getTupleField(int i) { none() }
396+
397+
override TypeParameter getPositionalTypeParameter(int i) {
398+
i = 0 and
399+
result = TPtrTypeParameter()
400+
}
401+
402+
override string toString() { result = "*" }
403+
404+
override Location getLocation() { result instanceof EmptyLocation }
405+
}
406+
377407
/** A type parameter. */
378408
abstract class TypeParameter extends Type {
379409
override StructField getStructField(string name) { none() }
@@ -529,6 +559,12 @@ class SliceTypeParameter extends TypeParameter, TSliceTypeParameter {
529559
override Location getLocation() { result instanceof EmptyLocation }
530560
}
531561

562+
class PtrTypeParameter extends TypeParameter, TPtrTypeParameter {
563+
override string toString() { result = "*T" }
564+
565+
override Location getLocation() { result instanceof EmptyLocation }
566+
}
567+
532568
/**
533569
* The implicit `Self` type parameter of a trait, that refers to the
534570
* implementing type of the trait.

0 commit comments

Comments
 (0)