File tree Expand file tree Collapse file tree
rust/ql/lib/codeql/rust/elements/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 * INTERNAL: Do not use.
55 */
66
7+ private import rust
78private import codeql.rust.elements.internal.generated.Impl
9+ private import codeql.rust.internal.PathResolution as PathResolution
10+ private import codeql.rust.internal.typeinference.Type
11+ private import codeql.rust.internal.typeinference.TypeMention
812
913/**
1014 * INTERNAL: This module contains the customizable definition of `Impl` and should not
@@ -39,5 +43,39 @@ module Impl {
3943 */
4044 pragma [ nomagic]
4145 predicate isInherent ( ) { not this .hasTraitTy ( ) }
46+
47+ /**
48+ * Gets the type being implemented.
49+ *
50+ * For example, in
51+ *
52+ * ```rust
53+ * impl MyType { ... }
54+ *
55+ * impl MyTrait for MyType { ... }
56+ * ```
57+ *
58+ * the type being implemented is in both cases`MyType`.
59+ */
60+ TypeItem getSelf ( ) {
61+ result = this .getSelfTy ( ) .( TypeMention ) .getType ( ) .( DataType ) .getTypeItem ( )
62+ }
63+
64+ /**
65+ * Gets the trait being implemented, if any.
66+ *
67+ * For example, in
68+ *
69+ * ```rust
70+ * impl MyType { ... }
71+ *
72+ * impl MyTrait for MyType { ... }
73+ * ```
74+ *
75+ * the trait being implemented is in the second case `MyTrait`.
76+ */
77+ Trait getTrait ( ) {
78+ result = PathResolution:: resolvePath ( this .getTraitTy ( ) .( PathTypeRepr ) .getPath ( ) )
79+ }
4280 }
4381}
You can’t perform that action at this time.
0 commit comments