Skip to content

Commit 5a69845

Browse files
committed
Rust: Elaborate QL doc
1 parent a07e357 commit 5a69845

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,32 @@ private ItemNode getAChildSuccessor(ItemNode item, string name, SuccessorKind ki
9999
* For example, if we have
100100
*
101101
* ```rust
102-
* mod m1 {
103-
* mod m2 { }
102+
* pub mod m1 {
103+
* pub mod m2 { }
104+
* }
105+
* ```
106+
*
107+
* then there is an edge `mod m1 --m2,both--> mod m2`.
108+
*
109+
* Associated items are example of externally visible items (inside the
110+
* declaring item they must be `Self` prefixed), while type parameters are
111+
* examples of internally visible items. For example, for
112+
*
113+
* ```rust
114+
* mod m {
115+
* pub trait<T> Trait {
116+
* fn foo(&self) -> T;
117+
* }
104118
* }
105119
* ```
106120
*
107-
* then there is an edge `m1 --m2,both--> m1::m2`.
121+
* we have the following edges
122+
*
123+
* ```
124+
* mod m --Trait,both--> trait Trait
125+
* trait Trait --foo,external --> fn foo
126+
* trait Trait --T,internal --> T
127+
* ```
108128
*
109129
* Source files are also considered nodes in the item graph, and for
110130
* each source file `f` there is an edge `f --name,both--> item` when `f`
@@ -119,13 +139,13 @@ private ItemNode getAChildSuccessor(ItemNode item, string name, SuccessorKind ki
119139
* }
120140
* ```
121141
*
122-
* we first generate an edge `m1::m2 --name,kind--> f::item`, where `item` is
142+
* we first generate an edge `mod m2 --name,kind--> f::item`, where `item` is
123143
* any item (named `name`) inside the imported source file `f`, and `kind` is
124144
* either `external` or `both`. Using this edge, `m2::foo` can resolve to
125-
* `f::foo`, which results in the edge `m1::use m2 --foo,internal--> f::foo`
145+
* `f::foo`, which results in the edge `use m2 --foo,internal--> f::foo`
126146
* (would have been `external` if it was `pub use m2::foo`). Lastly, all edges
127147
* out of `use` nodes are lifted to predecessors in the graph, so we get
128-
* an edge `m1 --foo,internal--> f::foo`.
148+
* an edge `mod m1 --foo,internal--> f::foo`.
129149
*
130150
*
131151
* References:

0 commit comments

Comments
 (0)