mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge branch 'main' into aibaars/rust-expand-assoc-items
This commit is contained in:
@@ -35,7 +35,7 @@ module Impl {
|
||||
*/
|
||||
abstract class Call extends ExprImpl::Expr {
|
||||
/** Holds if the receiver of this call is implicitly borrowed. */
|
||||
predicate receiverImplicitlyBorrowed() { this.implicitBorrowAt(TSelfArgumentPosition()) }
|
||||
predicate receiverImplicitlyBorrowed() { this.implicitBorrowAt(TSelfArgumentPosition(), _) }
|
||||
|
||||
/** Gets the trait targeted by this call, if any. */
|
||||
abstract Trait getTrait();
|
||||
@@ -47,7 +47,7 @@ module Impl {
|
||||
abstract Expr getArgument(ArgumentPosition pos);
|
||||
|
||||
/** Holds if the argument at `pos` might be implicitly borrowed. */
|
||||
abstract predicate implicitBorrowAt(ArgumentPosition pos);
|
||||
abstract predicate implicitBorrowAt(ArgumentPosition pos, boolean certain);
|
||||
|
||||
/** Gets the number of arguments _excluding_ any `self` argument. */
|
||||
int getNumberOfArguments() { result = count(this.getArgument(TPositionalArgumentPosition(_))) }
|
||||
@@ -85,7 +85,7 @@ module Impl {
|
||||
|
||||
override Trait getTrait() { none() }
|
||||
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos) { none() }
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos, boolean certain) { none() }
|
||||
|
||||
override Expr getArgument(ArgumentPosition pos) {
|
||||
result = super.getArgList().getArg(pos.asPosition())
|
||||
@@ -109,7 +109,7 @@ module Impl {
|
||||
qualifier.toString() != "Self"
|
||||
}
|
||||
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos) { none() }
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos, boolean certain) { none() }
|
||||
|
||||
override Expr getArgument(ArgumentPosition pos) {
|
||||
pos.isSelf() and result = super.getArgList().getArg(0)
|
||||
@@ -123,7 +123,9 @@ module Impl {
|
||||
|
||||
override Trait getTrait() { none() }
|
||||
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos) { pos.isSelf() }
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos, boolean certain) {
|
||||
pos.isSelf() and certain = false
|
||||
}
|
||||
|
||||
override Expr getArgument(ArgumentPosition pos) {
|
||||
pos.isSelf() and result = this.(MethodCallExpr).getReceiver()
|
||||
@@ -143,10 +145,13 @@ module Impl {
|
||||
|
||||
override Trait getTrait() { result = trait }
|
||||
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos) {
|
||||
pos.isSelf() and borrows >= 1
|
||||
or
|
||||
pos.asPosition() = 0 and borrows = 2
|
||||
override predicate implicitBorrowAt(ArgumentPosition pos, boolean certain) {
|
||||
(
|
||||
pos.isSelf() and borrows >= 1
|
||||
or
|
||||
pos.asPosition() = 0 and borrows = 2
|
||||
) and
|
||||
certain = true
|
||||
}
|
||||
|
||||
override Expr getArgument(ArgumentPosition pos) {
|
||||
|
||||
@@ -22,7 +22,7 @@ private predicate isOverloaded(string op, int arity, string path, string method,
|
||||
op = "!" and path = "core::ops::bit::Not" and method = "not" and borrows = 0
|
||||
or
|
||||
// Dereference
|
||||
op = "*" and path = "core::ops::deref::Deref" and method = "deref" and borrows = 0
|
||||
op = "*" and path = "core::ops::deref::Deref" and method = "deref" and borrows = 1
|
||||
)
|
||||
or
|
||||
arity = 2 and
|
||||
|
||||
@@ -205,7 +205,11 @@ abstract class ItemNode extends Locatable {
|
||||
else result = this.getImmediateParentModule().getImmediateParentModule()
|
||||
or
|
||||
name = "self" and
|
||||
if this instanceof Module or this instanceof Enum or this instanceof Struct
|
||||
if
|
||||
this instanceof Module or
|
||||
this instanceof Enum or
|
||||
this instanceof Struct or
|
||||
this instanceof Crate
|
||||
then result = this
|
||||
else result = this.getImmediateParentModule()
|
||||
or
|
||||
|
||||
@@ -273,10 +273,6 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
|
||||
prefix1.isEmpty() and
|
||||
prefix2 = TypePath::singleton(TRefTypeParameter())
|
||||
or
|
||||
n1 = n2.(DerefExpr).getExpr() and
|
||||
prefix1 = TypePath::singleton(TRefTypeParameter()) and
|
||||
prefix2.isEmpty()
|
||||
or
|
||||
exists(BlockExpr be |
|
||||
n1 = be and
|
||||
n2 = be.getStmtList().getTailExpr() and
|
||||
@@ -640,20 +636,20 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
|
||||
}
|
||||
|
||||
private newtype TAccessPosition =
|
||||
TArgumentAccessPosition(ArgumentPosition pos, Boolean borrowed) or
|
||||
TArgumentAccessPosition(ArgumentPosition pos, Boolean borrowed, Boolean certain) or
|
||||
TReturnAccessPosition()
|
||||
|
||||
class AccessPosition extends TAccessPosition {
|
||||
ArgumentPosition getArgumentPosition() { this = TArgumentAccessPosition(result, _) }
|
||||
ArgumentPosition getArgumentPosition() { this = TArgumentAccessPosition(result, _, _) }
|
||||
|
||||
predicate isBorrowed() { this = TArgumentAccessPosition(_, true) }
|
||||
predicate isBorrowed(boolean certain) { this = TArgumentAccessPosition(_, true, certain) }
|
||||
|
||||
predicate isReturn() { this = TReturnAccessPosition() }
|
||||
|
||||
string toString() {
|
||||
exists(ArgumentPosition pos, boolean borrowed |
|
||||
this = TArgumentAccessPosition(pos, borrowed) and
|
||||
result = pos + ":" + borrowed
|
||||
exists(ArgumentPosition pos, boolean borrowed, boolean certain |
|
||||
this = TArgumentAccessPosition(pos, borrowed, certain) and
|
||||
result = pos + ":" + borrowed + ":" + certain
|
||||
)
|
||||
or
|
||||
this.isReturn() and
|
||||
@@ -674,10 +670,15 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
|
||||
}
|
||||
|
||||
AstNode getNodeAt(AccessPosition apos) {
|
||||
exists(ArgumentPosition pos, boolean borrowed |
|
||||
apos = TArgumentAccessPosition(pos, borrowed) and
|
||||
result = this.getArgument(pos) and
|
||||
if this.implicitBorrowAt(pos) then borrowed = true else borrowed = false
|
||||
exists(ArgumentPosition pos, boolean borrowed, boolean certain |
|
||||
apos = TArgumentAccessPosition(pos, borrowed, certain) and
|
||||
result = this.getArgument(pos)
|
||||
|
|
||||
if this.implicitBorrowAt(pos, _)
|
||||
then borrowed = true and this.implicitBorrowAt(pos, certain)
|
||||
else (
|
||||
borrowed = false and certain = true
|
||||
)
|
||||
)
|
||||
or
|
||||
result = this and apos.isReturn()
|
||||
@@ -705,51 +706,54 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
|
||||
predicate adjustAccessType(
|
||||
AccessPosition apos, Declaration target, TypePath path, Type t, TypePath pathAdj, Type tAdj
|
||||
) {
|
||||
if apos.isBorrowed()
|
||||
then
|
||||
exists(Type selfParamType |
|
||||
selfParamType =
|
||||
target
|
||||
.getParameterType(TArgumentDeclarationPosition(apos.getArgumentPosition()),
|
||||
TypePath::nil())
|
||||
|
|
||||
if selfParamType = TRefType()
|
||||
apos.isBorrowed(true) and
|
||||
pathAdj = TypePath::cons(TRefTypeParameter(), path) and
|
||||
tAdj = t
|
||||
or
|
||||
apos.isBorrowed(false) and
|
||||
exists(Type selfParamType |
|
||||
selfParamType =
|
||||
target
|
||||
.getParameterType(TArgumentDeclarationPosition(apos.getArgumentPosition()),
|
||||
TypePath::nil())
|
||||
|
|
||||
if selfParamType = TRefType()
|
||||
then
|
||||
if t != TRefType() and path.isEmpty()
|
||||
then
|
||||
if t != TRefType() and path.isEmpty()
|
||||
then
|
||||
// adjust for implicit borrow
|
||||
pathAdj.isEmpty() and
|
||||
tAdj = TRefType()
|
||||
or
|
||||
// adjust for implicit borrow
|
||||
pathAdj = TypePath::singleton(TRefTypeParameter()) and
|
||||
tAdj = t
|
||||
else
|
||||
if path.isCons(TRefTypeParameter(), _)
|
||||
then
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
else (
|
||||
// adjust for implicit borrow
|
||||
not (t = TRefType() and path.isEmpty()) and
|
||||
pathAdj = TypePath::cons(TRefTypeParameter(), path) and
|
||||
tAdj = t
|
||||
)
|
||||
else (
|
||||
// adjust for implicit deref
|
||||
path.isCons(TRefTypeParameter(), pathAdj) and
|
||||
tAdj = t
|
||||
// adjust for implicit borrow
|
||||
pathAdj.isEmpty() and
|
||||
tAdj = TRefType()
|
||||
or
|
||||
not path.isCons(TRefTypeParameter(), _) and
|
||||
not (t = TRefType() and path.isEmpty()) and
|
||||
pathAdj = path and
|
||||
// adjust for implicit borrow
|
||||
pathAdj = TypePath::singleton(TRefTypeParameter()) and
|
||||
tAdj = t
|
||||
)
|
||||
else
|
||||
if path.isCons(TRefTypeParameter(), _)
|
||||
then
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
else (
|
||||
// adjust for implicit borrow
|
||||
not (t = TRefType() and path.isEmpty()) and
|
||||
pathAdj = TypePath::cons(TRefTypeParameter(), path) and
|
||||
tAdj = t
|
||||
)
|
||||
else (
|
||||
// adjust for implicit deref
|
||||
path.isCons(TRefTypeParameter(), pathAdj) and
|
||||
tAdj = t
|
||||
or
|
||||
not path.isCons(TRefTypeParameter(), _) and
|
||||
not (t = TRefType() and path.isEmpty()) and
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
)
|
||||
else (
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
)
|
||||
or
|
||||
not apos.isBorrowed(_) and
|
||||
pathAdj = path and
|
||||
tAdj = t
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,35 +770,47 @@ private Type inferCallExprBaseType(AstNode n, TypePath path) {
|
||||
TypePath path0
|
||||
|
|
||||
n = a.getNodeAt(apos) and
|
||||
result = CallExprBaseMatching::inferAccessType(a, apos, path0) and
|
||||
if apos.isBorrowed()
|
||||
then
|
||||
exists(Type argType | argType = inferType(n) |
|
||||
if argType = TRefType()
|
||||
then
|
||||
path = path0 and
|
||||
path0.isCons(TRefTypeParameter(), _)
|
||||
or
|
||||
// adjust for implicit deref
|
||||
result = CallExprBaseMatching::inferAccessType(a, apos, path0)
|
||||
|
|
||||
(
|
||||
apos.isBorrowed(true)
|
||||
or
|
||||
// The desugaring of the unary `*e` is `*Deref::deref(&e)`. To handle the
|
||||
// deref expression after the call we must strip a `&` from the type at
|
||||
// the return position.
|
||||
apos.isReturn() and a instanceof DerefExpr
|
||||
) and
|
||||
path0.isCons(TRefTypeParameter(), path)
|
||||
or
|
||||
apos.isBorrowed(false) and
|
||||
exists(Type argType | argType = inferType(n) |
|
||||
if argType = TRefType()
|
||||
then
|
||||
path = path0 and
|
||||
path0.isCons(TRefTypeParameter(), _)
|
||||
or
|
||||
// adjust for implicit deref
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType()) and
|
||||
path = TypePath::cons(TRefTypeParameter(), path0)
|
||||
else (
|
||||
not (
|
||||
argType.(StructType).asItemNode() instanceof StringStruct and
|
||||
result.(StructType).asItemNode() instanceof Builtins::Str
|
||||
) and
|
||||
(
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType()) and
|
||||
path = TypePath::cons(TRefTypeParameter(), path0)
|
||||
else (
|
||||
not (
|
||||
argType.(StructType).asItemNode() instanceof StringStruct and
|
||||
result.(StructType).asItemNode() instanceof Builtins::Str
|
||||
) and
|
||||
(
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType()) and
|
||||
path = path0
|
||||
or
|
||||
// adjust for implicit borrow
|
||||
path0.isCons(TRefTypeParameter(), path)
|
||||
)
|
||||
path = path0
|
||||
or
|
||||
// adjust for implicit borrow
|
||||
path0.isCons(TRefTypeParameter(), path)
|
||||
)
|
||||
)
|
||||
else path = path0
|
||||
)
|
||||
or
|
||||
not apos.isBorrowed(_) and
|
||||
path = path0
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1141,8 +1157,15 @@ final class MethodCall extends Call {
|
||||
(
|
||||
path0.isCons(TRefTypeParameter(), path)
|
||||
or
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType()) and
|
||||
(
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType())
|
||||
or
|
||||
// Ideally we should find all methods on reference types, but as
|
||||
// that currently causes a blowup we limit this to the `deref`
|
||||
// method in order to make dereferencing work.
|
||||
this.getMethodName() = "deref"
|
||||
) and
|
||||
path = path0
|
||||
)
|
||||
|
|
||||
@@ -1389,7 +1412,7 @@ private module Cached {
|
||||
predicate receiverHasImplicitDeref(AstNode receiver) {
|
||||
exists(CallExprBaseMatchingInput::Access a, CallExprBaseMatchingInput::AccessPosition apos |
|
||||
apos.getArgumentPosition().isSelf() and
|
||||
apos.isBorrowed() and
|
||||
apos.isBorrowed(_) and
|
||||
receiver = a.getNodeAt(apos) and
|
||||
inferType(receiver) = TRefType() and
|
||||
CallExprBaseMatching::inferAccessType(a, apos, TypePath::nil()) != TRefType()
|
||||
@@ -1401,7 +1424,7 @@ private module Cached {
|
||||
predicate receiverHasImplicitBorrow(AstNode receiver) {
|
||||
exists(CallExprBaseMatchingInput::Access a, CallExprBaseMatchingInput::AccessPosition apos |
|
||||
apos.getArgumentPosition().isSelf() and
|
||||
apos.isBorrowed() and
|
||||
apos.isBorrowed(_) and
|
||||
receiver = a.getNodeAt(apos) and
|
||||
CallExprBaseMatching::inferAccessType(a, apos, TypePath::nil()) = TRefType() and
|
||||
inferType(receiver) != TRefType()
|
||||
|
||||
7
rust/ql/test/.gitignore
vendored
7
rust/ql/test/.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
Cargo.toml
|
||||
lib.rs
|
||||
target/
|
||||
|
||||
# these are all generated, see `rust/extractor/src/qltest.rs` for details
|
||||
Cargo.toml
|
||||
rust-toolchain.toml
|
||||
lib.rs
|
||||
.proc_macro/
|
||||
.lib/
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ fn test_operator_overloading() {
|
||||
|
||||
let a = MyInt { value: source(28) };
|
||||
let c = *a;
|
||||
sink(c); // $ MISSING: hasValueFlow=28
|
||||
sink(c); // $ hasTaintFlow=28 MISSING: hasValueFlow=28
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
| main.rs:165:13:165:34 | ...::new(...) | main.rs:158:5:161:5 | fn new |
|
||||
| main.rs:165:24:165:33 | source(...) | main.rs:1:1:3:1 | fn source |
|
||||
| main.rs:167:5:167:11 | sink(...) | main.rs:5:1:7:1 | fn sink |
|
||||
| main.rs:181:10:181:14 | * ... | main.rs:188:5:190:5 | fn deref |
|
||||
| main.rs:189:11:189:15 | * ... | main.rs:188:5:190:5 | fn deref |
|
||||
| main.rs:195:28:195:36 | source(...) | main.rs:1:1:3:1 | fn source |
|
||||
| main.rs:197:13:197:17 | ... + ... | main.rs:173:5:176:5 | fn add |
|
||||
| main.rs:198:5:198:17 | sink(...) | main.rs:5:1:7:1 | fn sink |
|
||||
|
||||
@@ -114,6 +114,8 @@ localStep
|
||||
| main.rs:89:9:89:9 | i | main.rs:89:9:89:9 | [SSA] i |
|
||||
| main.rs:89:9:89:9 | i | main.rs:89:9:89:9 | i |
|
||||
| main.rs:89:13:89:31 | ...::new(...) | main.rs:89:9:89:9 | i |
|
||||
| main.rs:90:11:90:11 | [post] receiver for i | main.rs:90:11:90:11 | [post] i |
|
||||
| main.rs:90:11:90:11 | i | main.rs:90:11:90:11 | receiver for i |
|
||||
| main.rs:97:9:97:9 | [SSA] a | main.rs:98:10:98:10 | a |
|
||||
| main.rs:97:9:97:9 | a | main.rs:97:9:97:9 | [SSA] a |
|
||||
| main.rs:97:9:97:9 | a | main.rs:97:9:97:9 | a |
|
||||
@@ -732,6 +734,8 @@ localStep
|
||||
| main.rs:482:11:482:19 | vs.iter() | main.rs:482:11:482:19 | receiver for vs.iter() |
|
||||
| main.rs:482:11:482:26 | ... .next() | main.rs:482:11:482:26 | receiver for ... .next() |
|
||||
| main.rs:482:11:482:26 | [post] receiver for ... .next() | main.rs:482:11:482:26 | [post] ... .next() |
|
||||
| main.rs:482:11:482:35 | ... .unwrap() | main.rs:482:11:482:35 | receiver for ... .unwrap() |
|
||||
| main.rs:482:11:482:35 | [post] receiver for ... .unwrap() | main.rs:482:11:482:35 | [post] ... .unwrap() |
|
||||
| main.rs:483:11:483:12 | [post] receiver for vs | main.rs:483:11:483:12 | [post] vs |
|
||||
| main.rs:483:11:483:12 | [post] vs | main.rs:485:14:485:15 | vs |
|
||||
| main.rs:483:11:483:12 | vs | main.rs:483:11:483:12 | receiver for vs |
|
||||
@@ -740,6 +744,8 @@ localStep
|
||||
| main.rs:483:11:483:19 | vs.iter() | main.rs:483:11:483:19 | receiver for vs.iter() |
|
||||
| main.rs:483:11:483:26 | ... .nth(...) | main.rs:483:11:483:26 | receiver for ... .nth(...) |
|
||||
| main.rs:483:11:483:26 | [post] receiver for ... .nth(...) | main.rs:483:11:483:26 | [post] ... .nth(...) |
|
||||
| main.rs:483:11:483:35 | ... .unwrap() | main.rs:483:11:483:35 | receiver for ... .unwrap() |
|
||||
| main.rs:483:11:483:35 | [post] receiver for ... .unwrap() | main.rs:483:11:483:35 | [post] ... .unwrap() |
|
||||
| main.rs:485:9:485:9 | [SSA] v | main.rs:486:14:486:14 | v |
|
||||
| main.rs:485:9:485:9 | v | main.rs:485:9:485:9 | [SSA] v |
|
||||
| main.rs:485:9:485:9 | v | main.rs:485:9:485:9 | v |
|
||||
@@ -774,6 +780,8 @@ localStep
|
||||
| main.rs:497:20:497:20 | [SSA] x | main.rs:497:29:497:29 | x |
|
||||
| main.rs:497:20:497:20 | x | main.rs:497:20:497:20 | [SSA] x |
|
||||
| main.rs:497:20:497:20 | x | main.rs:497:20:497:20 | x |
|
||||
| main.rs:497:29:497:29 | [post] receiver for x | main.rs:497:29:497:29 | [post] x |
|
||||
| main.rs:497:29:497:29 | x | main.rs:497:29:497:29 | receiver for x |
|
||||
| main.rs:498:5:498:6 | [post] receiver for vs | main.rs:498:5:498:6 | [post] vs |
|
||||
| main.rs:498:5:498:6 | [post] vs | main.rs:500:14:500:15 | vs |
|
||||
| main.rs:498:5:498:6 | vs | main.rs:498:5:498:6 | receiver for vs |
|
||||
@@ -784,6 +792,8 @@ localStep
|
||||
| main.rs:498:25:498:25 | [SSA] x | main.rs:498:34:498:34 | x |
|
||||
| main.rs:498:25:498:25 | x | main.rs:498:25:498:25 | [SSA] x |
|
||||
| main.rs:498:25:498:25 | x | main.rs:498:25:498:25 | x |
|
||||
| main.rs:498:34:498:34 | [post] receiver for x | main.rs:498:34:498:34 | [post] x |
|
||||
| main.rs:498:34:498:34 | x | main.rs:498:34:498:34 | receiver for x |
|
||||
| main.rs:500:9:500:9 | [SSA] v | main.rs:501:14:501:14 | v |
|
||||
| main.rs:500:9:500:9 | v | main.rs:500:9:500:9 | [SSA] v |
|
||||
| main.rs:500:9:500:9 | v | main.rs:500:9:500:9 | v |
|
||||
@@ -809,6 +819,8 @@ localStep
|
||||
| main.rs:507:11:507:23 | vs_mut.iter() | main.rs:507:11:507:23 | receiver for vs_mut.iter() |
|
||||
| main.rs:507:11:507:30 | ... .next() | main.rs:507:11:507:30 | receiver for ... .next() |
|
||||
| main.rs:507:11:507:30 | [post] receiver for ... .next() | main.rs:507:11:507:30 | [post] ... .next() |
|
||||
| main.rs:507:11:507:39 | ... .unwrap() | main.rs:507:11:507:39 | receiver for ... .unwrap() |
|
||||
| main.rs:507:11:507:39 | [post] receiver for ... .unwrap() | main.rs:507:11:507:39 | [post] ... .unwrap() |
|
||||
| main.rs:508:11:508:16 | [SSA] vs_mut | main.rs:510:19:510:24 | vs_mut |
|
||||
| main.rs:508:11:508:16 | [post] receiver for vs_mut | main.rs:508:11:508:16 | [post] vs_mut |
|
||||
| main.rs:508:11:508:16 | [post] vs_mut | main.rs:510:19:510:24 | vs_mut |
|
||||
@@ -818,6 +830,8 @@ localStep
|
||||
| main.rs:508:11:508:23 | vs_mut.iter() | main.rs:508:11:508:23 | receiver for vs_mut.iter() |
|
||||
| main.rs:508:11:508:30 | ... .nth(...) | main.rs:508:11:508:30 | receiver for ... .nth(...) |
|
||||
| main.rs:508:11:508:30 | [post] receiver for ... .nth(...) | main.rs:508:11:508:30 | [post] ... .nth(...) |
|
||||
| main.rs:508:11:508:39 | ... .unwrap() | main.rs:508:11:508:39 | receiver for ... .unwrap() |
|
||||
| main.rs:508:11:508:39 | [post] receiver for ... .unwrap() | main.rs:508:11:508:39 | [post] ... .unwrap() |
|
||||
| main.rs:510:5:512:5 | for ... in ... { ... } | main.rs:478:16:513:1 | { ... } |
|
||||
| main.rs:510:14:510:14 | [SSA] v | main.rs:511:14:511:14 | v |
|
||||
| main.rs:510:14:510:14 | v | main.rs:510:14:510:14 | [SSA] v |
|
||||
@@ -842,6 +856,8 @@ localStep
|
||||
| main.rs:519:17:519:18 | &c | main.rs:519:9:519:13 | c_ref |
|
||||
| main.rs:523:14:523:18 | [post] c_ref | main.rs:524:11:524:15 | c_ref |
|
||||
| main.rs:523:14:523:18 | c_ref | main.rs:524:11:524:15 | c_ref |
|
||||
| main.rs:524:11:524:15 | [post] receiver for c_ref | main.rs:524:11:524:15 | [post] c_ref |
|
||||
| main.rs:524:11:524:15 | c_ref | main.rs:524:11:524:15 | receiver for c_ref |
|
||||
| main.rs:528:9:528:9 | [SSA] a | main.rs:530:10:530:10 | a |
|
||||
| main.rs:528:9:528:9 | a | main.rs:528:9:528:9 | [SSA] a |
|
||||
| main.rs:528:9:528:9 | a | main.rs:528:9:528:9 | a |
|
||||
@@ -867,6 +883,7 @@ localStep
|
||||
| main.rs:577:36:577:41 | [post] MacroExpr | main.rs:577:36:577:41 | [post] ...::new(...) |
|
||||
readStep
|
||||
| main.rs:36:9:36:15 | Some(...) | {EXTERNAL LOCATION} | Some | main.rs:36:14:36:14 | _ |
|
||||
| main.rs:90:11:90:11 | [post] receiver for i | file://:0:0:0:0 | &ref | main.rs:90:11:90:11 | [post] i |
|
||||
| main.rs:90:11:90:11 | i | file://:0:0:0:0 | &ref | main.rs:90:10:90:11 | * ... |
|
||||
| main.rs:98:10:98:10 | a | file://:0:0:0:0 | tuple.0 | main.rs:98:10:98:12 | a.0 |
|
||||
| main.rs:99:10:99:10 | a | file://:0:0:0:0 | tuple.1 | main.rs:99:10:99:12 | a.1 |
|
||||
@@ -981,6 +998,7 @@ readStep
|
||||
| main.rs:510:19:510:35 | vs_mut.iter_mut() | file://:0:0:0:0 | element | main.rs:510:9:510:14 | &mut ... |
|
||||
| main.rs:524:11:524:15 | c_ref | file://:0:0:0:0 | &ref | main.rs:524:10:524:15 | * ... |
|
||||
storeStep
|
||||
| main.rs:90:11:90:11 | i | file://:0:0:0:0 | &ref | main.rs:90:11:90:11 | receiver for i |
|
||||
| main.rs:97:14:97:22 | source(...) | file://:0:0:0:0 | tuple.0 | main.rs:97:13:97:26 | TupleExpr |
|
||||
| main.rs:97:25:97:25 | 2 | file://:0:0:0:0 | tuple.1 | main.rs:97:13:97:26 | TupleExpr |
|
||||
| main.rs:103:14:103:14 | 2 | file://:0:0:0:0 | tuple.0 | main.rs:103:13:103:30 | TupleExpr |
|
||||
|
||||
@@ -3,7 +3,7 @@ multiplePathResolutions
|
||||
| main.rs:118:9:118:9 | f | main.rs:110:5:112:5 | fn f |
|
||||
| main.rs:626:3:626:12 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:626:3:626:12 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:631:7:631:16 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:631:7:631:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:634:7:634:16 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:634:7:634:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:632:7:632:16 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:632:7:632:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:635:7:635:16 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:635:7:635:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
|
||||
@@ -627,7 +627,8 @@ extern crate self as zelf;
|
||||
fn z() {} // I122
|
||||
|
||||
struct AStruct {} //I123
|
||||
impl AStruct { // $ item=I123
|
||||
impl AStruct // $ item=I123
|
||||
{
|
||||
#[proc_macro::add_suffix("on_type")] // $ item=add_suffix
|
||||
pub fn z() {} // I124
|
||||
|
||||
@@ -635,6 +636,10 @@ impl AStruct { // $ item=I123
|
||||
pub fn z(&self) {} // I125
|
||||
}
|
||||
|
||||
use std::{self as ztd}; // $ item=std
|
||||
|
||||
fn use_ztd(x: ztd::string::String) {} // $ item=String
|
||||
|
||||
fn main() {
|
||||
my::nested::nested1::nested2::f(); // $ item=I4
|
||||
my::f(); // $ item=I38
|
||||
@@ -667,6 +672,6 @@ fn main() {
|
||||
zelf::h(); // $ item=I25
|
||||
z_changed(); // $ MISSING: item=I122
|
||||
AStruct::z_on_type(); // $ MISSING: item=I124
|
||||
AStruct{} // $ item=I123
|
||||
AStruct {} // $ item=I123
|
||||
.z_on_instance(); // MISSING: item=I125
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ resolvePath
|
||||
| main.rs:30:17:30:21 | super | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:30:17:30:24 | ...::f | main.rs:19:9:21:9 | fn f |
|
||||
| main.rs:33:17:33:17 | f | main.rs:19:9:21:9 | fn f |
|
||||
| main.rs:40:9:40:13 | super | main.rs:1:1:672:2 | SourceFile |
|
||||
| main.rs:40:9:40:13 | super | main.rs:1:1:677:2 | SourceFile |
|
||||
| main.rs:40:9:40:17 | ...::m1 | main.rs:13:1:37:1 | mod m1 |
|
||||
| main.rs:40:9:40:21 | ...::m2 | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:40:9:40:24 | ...::g | main.rs:23:9:27:9 | fn g |
|
||||
@@ -73,7 +73,7 @@ resolvePath
|
||||
| main.rs:61:17:61:19 | Foo | main.rs:59:9:59:21 | struct Foo |
|
||||
| main.rs:64:13:64:15 | Foo | main.rs:53:5:53:17 | struct Foo |
|
||||
| main.rs:66:5:66:5 | f | main.rs:55:5:62:5 | fn f |
|
||||
| main.rs:68:5:68:8 | self | main.rs:1:1:672:2 | SourceFile |
|
||||
| main.rs:68:5:68:8 | self | main.rs:1:1:677:2 | SourceFile |
|
||||
| main.rs:68:5:68:11 | ...::i | main.rs:71:1:83:1 | fn i |
|
||||
| main.rs:74:13:74:15 | Foo | main.rs:48:1:48:13 | struct Foo |
|
||||
| main.rs:78:16:78:18 | i32 | {EXTERNAL LOCATION} | struct i32 |
|
||||
@@ -88,7 +88,7 @@ resolvePath
|
||||
| main.rs:87:57:87:66 | ...::g | my2/nested2.rs:7:9:9:9 | fn g |
|
||||
| main.rs:87:80:87:86 | nested4 | my2/nested2.rs:2:5:10:5 | mod nested4 |
|
||||
| main.rs:100:5:100:22 | f_defined_in_macro | main.rs:99:18:99:42 | fn f_defined_in_macro |
|
||||
| main.rs:117:13:117:17 | super | main.rs:1:1:672:2 | SourceFile |
|
||||
| main.rs:117:13:117:17 | super | main.rs:1:1:677:2 | SourceFile |
|
||||
| main.rs:117:13:117:21 | ...::m5 | main.rs:103:1:107:1 | mod m5 |
|
||||
| main.rs:118:9:118:9 | f | main.rs:104:5:106:5 | fn f |
|
||||
| main.rs:118:9:118:9 | f | main.rs:110:5:112:5 | fn f |
|
||||
@@ -270,75 +270,80 @@ resolvePath
|
||||
| main.rs:626:3:626:12 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:626:3:626:24 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
|
||||
| main.rs:630:6:630:12 | AStruct | main.rs:629:1:629:17 | struct AStruct |
|
||||
| main.rs:631:7:631:16 | proc_macro | {EXTERNAL LOCATION} | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:631:7:631:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:631:7:631:28 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
|
||||
| main.rs:634:7:634:16 | proc_macro | {EXTERNAL LOCATION} | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:634:7:634:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:634:7:634:28 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
|
||||
| main.rs:639:5:639:6 | my | main.rs:1:1:1:7 | mod my |
|
||||
| main.rs:639:5:639:14 | ...::nested | my.rs:1:1:1:15 | mod nested |
|
||||
| main.rs:639:5:639:23 | ...::nested1 | my/nested.rs:1:1:17:1 | mod nested1 |
|
||||
| main.rs:639:5:639:32 | ...::nested2 | my/nested.rs:2:5:11:5 | mod nested2 |
|
||||
| main.rs:639:5:639:35 | ...::f | my/nested.rs:3:9:5:9 | fn f |
|
||||
| main.rs:640:5:640:6 | my | main.rs:1:1:1:7 | mod my |
|
||||
| main.rs:640:5:640:9 | ...::f | my.rs:5:1:7:1 | fn f |
|
||||
| main.rs:641:5:641:11 | nested2 | my2/mod.rs:1:1:1:16 | mod nested2 |
|
||||
| main.rs:641:5:641:20 | ...::nested3 | my2/nested2.rs:1:1:11:1 | mod nested3 |
|
||||
| main.rs:641:5:641:29 | ...::nested4 | my2/nested2.rs:2:5:10:5 | mod nested4 |
|
||||
| main.rs:641:5:641:32 | ...::f | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:642:5:642:5 | f | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:643:5:643:5 | g | my2/nested2.rs:7:9:9:9 | fn g |
|
||||
| main.rs:644:5:644:9 | crate | main.rs:0:0:0:0 | Crate(main@0.0.1) |
|
||||
| main.rs:644:5:644:12 | ...::h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:645:5:645:6 | m1 | main.rs:13:1:37:1 | mod m1 |
|
||||
| main.rs:645:5:645:10 | ...::m2 | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:645:5:645:13 | ...::g | main.rs:23:9:27:9 | fn g |
|
||||
| main.rs:646:5:646:6 | m1 | main.rs:13:1:37:1 | mod m1 |
|
||||
| main.rs:646:5:646:10 | ...::m2 | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:646:5:646:14 | ...::m3 | main.rs:29:9:35:9 | mod m3 |
|
||||
| main.rs:646:5:646:17 | ...::h | main.rs:30:27:34:13 | fn h |
|
||||
| main.rs:647:5:647:6 | m4 | main.rs:39:1:46:1 | mod m4 |
|
||||
| main.rs:647:5:647:9 | ...::i | main.rs:42:5:45:5 | fn i |
|
||||
| main.rs:648:5:648:5 | h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:649:5:649:11 | f_alias | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:650:5:650:11 | g_alias | my2/nested2.rs:7:9:9:9 | fn g |
|
||||
| main.rs:651:5:651:5 | j | main.rs:97:1:101:1 | fn j |
|
||||
| main.rs:652:5:652:6 | m6 | main.rs:109:1:120:1 | mod m6 |
|
||||
| main.rs:652:5:652:9 | ...::g | main.rs:114:5:119:5 | fn g |
|
||||
| main.rs:653:5:653:6 | m7 | main.rs:122:1:141:1 | mod m7 |
|
||||
| main.rs:653:5:653:9 | ...::f | main.rs:133:5:140:5 | fn f |
|
||||
| main.rs:654:5:654:6 | m8 | main.rs:143:1:197:1 | mod m8 |
|
||||
| main.rs:654:5:654:9 | ...::g | main.rs:181:5:196:5 | fn g |
|
||||
| main.rs:655:5:655:6 | m9 | main.rs:199:1:207:1 | mod m9 |
|
||||
| main.rs:655:5:655:9 | ...::f | main.rs:202:5:206:5 | fn f |
|
||||
| main.rs:656:5:656:7 | m11 | main.rs:230:1:267:1 | mod m11 |
|
||||
| main.rs:656:5:656:10 | ...::f | main.rs:235:5:238:5 | fn f |
|
||||
| main.rs:657:5:657:7 | m15 | main.rs:298:1:352:1 | mod m15 |
|
||||
| main.rs:657:5:657:10 | ...::f | main.rs:339:5:351:5 | fn f |
|
||||
| main.rs:658:5:658:7 | m16 | main.rs:354:1:446:1 | mod m16 |
|
||||
| main.rs:658:5:658:10 | ...::f | main.rs:421:5:445:5 | fn f |
|
||||
| main.rs:659:5:659:7 | m17 | main.rs:448:1:478:1 | mod m17 |
|
||||
| main.rs:659:5:659:10 | ...::f | main.rs:472:5:477:5 | fn f |
|
||||
| main.rs:660:5:660:11 | nested6 | my2/nested2.rs:14:5:18:5 | mod nested6 |
|
||||
| main.rs:660:5:660:14 | ...::f | my2/nested2.rs:15:9:17:9 | fn f |
|
||||
| main.rs:661:5:661:11 | nested8 | my2/nested2.rs:22:5:26:5 | mod nested8 |
|
||||
| main.rs:661:5:661:14 | ...::f | my2/nested2.rs:23:9:25:9 | fn f |
|
||||
| main.rs:662:5:662:7 | my3 | my2/mod.rs:12:1:12:12 | mod my3 |
|
||||
| main.rs:662:5:662:10 | ...::f | my2/my3/mod.rs:1:1:5:1 | fn f |
|
||||
| main.rs:663:5:663:12 | nested_f | my/my4/my5/mod.rs:1:1:3:1 | fn f |
|
||||
| main.rs:664:5:664:7 | m18 | main.rs:480:1:498:1 | mod m18 |
|
||||
| main.rs:664:5:664:12 | ...::m19 | main.rs:485:5:497:5 | mod m19 |
|
||||
| main.rs:664:5:664:17 | ...::m20 | main.rs:490:9:496:9 | mod m20 |
|
||||
| main.rs:664:5:664:20 | ...::g | main.rs:491:13:495:13 | fn g |
|
||||
| main.rs:665:5:665:7 | m23 | main.rs:527:1:552:1 | mod m23 |
|
||||
| main.rs:665:5:665:10 | ...::f | main.rs:547:5:551:5 | fn f |
|
||||
| main.rs:666:5:666:7 | m24 | main.rs:554:1:622:1 | mod m24 |
|
||||
| main.rs:666:5:666:10 | ...::f | main.rs:608:5:621:5 | fn f |
|
||||
| main.rs:667:5:667:8 | zelf | main.rs:0:0:0:0 | Crate(main@0.0.1) |
|
||||
| main.rs:667:5:667:11 | ...::h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:669:5:669:11 | AStruct | main.rs:629:1:629:17 | struct AStruct |
|
||||
| main.rs:670:5:670:11 | AStruct | main.rs:629:1:629:17 | struct AStruct |
|
||||
| main.rs:632:7:632:16 | proc_macro | {EXTERNAL LOCATION} | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:632:7:632:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:632:7:632:28 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
|
||||
| main.rs:635:7:635:16 | proc_macro | {EXTERNAL LOCATION} | Crate(proc_macro@0.0.0) |
|
||||
| main.rs:635:7:635:16 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
|
||||
| main.rs:635:7:635:28 | ...::add_suffix | proc_macro.rs:4:1:12:1 | fn add_suffix |
|
||||
| main.rs:639:5:639:7 | std | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
|
||||
| main.rs:639:11:639:14 | self | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
|
||||
| main.rs:641:15:641:17 | ztd | {EXTERNAL LOCATION} | Crate(std@0.0.0) |
|
||||
| main.rs:641:15:641:25 | ...::string | {EXTERNAL LOCATION} | mod string |
|
||||
| main.rs:641:15:641:33 | ...::String | {EXTERNAL LOCATION} | struct String |
|
||||
| main.rs:644:5:644:6 | my | main.rs:1:1:1:7 | mod my |
|
||||
| main.rs:644:5:644:14 | ...::nested | my.rs:1:1:1:15 | mod nested |
|
||||
| main.rs:644:5:644:23 | ...::nested1 | my/nested.rs:1:1:17:1 | mod nested1 |
|
||||
| main.rs:644:5:644:32 | ...::nested2 | my/nested.rs:2:5:11:5 | mod nested2 |
|
||||
| main.rs:644:5:644:35 | ...::f | my/nested.rs:3:9:5:9 | fn f |
|
||||
| main.rs:645:5:645:6 | my | main.rs:1:1:1:7 | mod my |
|
||||
| main.rs:645:5:645:9 | ...::f | my.rs:5:1:7:1 | fn f |
|
||||
| main.rs:646:5:646:11 | nested2 | my2/mod.rs:1:1:1:16 | mod nested2 |
|
||||
| main.rs:646:5:646:20 | ...::nested3 | my2/nested2.rs:1:1:11:1 | mod nested3 |
|
||||
| main.rs:646:5:646:29 | ...::nested4 | my2/nested2.rs:2:5:10:5 | mod nested4 |
|
||||
| main.rs:646:5:646:32 | ...::f | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:647:5:647:5 | f | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:648:5:648:5 | g | my2/nested2.rs:7:9:9:9 | fn g |
|
||||
| main.rs:649:5:649:9 | crate | main.rs:0:0:0:0 | Crate(main@0.0.1) |
|
||||
| main.rs:649:5:649:12 | ...::h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:650:5:650:6 | m1 | main.rs:13:1:37:1 | mod m1 |
|
||||
| main.rs:650:5:650:10 | ...::m2 | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:650:5:650:13 | ...::g | main.rs:23:9:27:9 | fn g |
|
||||
| main.rs:651:5:651:6 | m1 | main.rs:13:1:37:1 | mod m1 |
|
||||
| main.rs:651:5:651:10 | ...::m2 | main.rs:18:5:36:5 | mod m2 |
|
||||
| main.rs:651:5:651:14 | ...::m3 | main.rs:29:9:35:9 | mod m3 |
|
||||
| main.rs:651:5:651:17 | ...::h | main.rs:30:27:34:13 | fn h |
|
||||
| main.rs:652:5:652:6 | m4 | main.rs:39:1:46:1 | mod m4 |
|
||||
| main.rs:652:5:652:9 | ...::i | main.rs:42:5:45:5 | fn i |
|
||||
| main.rs:653:5:653:5 | h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:654:5:654:11 | f_alias | my2/nested2.rs:3:9:5:9 | fn f |
|
||||
| main.rs:655:5:655:11 | g_alias | my2/nested2.rs:7:9:9:9 | fn g |
|
||||
| main.rs:656:5:656:5 | j | main.rs:97:1:101:1 | fn j |
|
||||
| main.rs:657:5:657:6 | m6 | main.rs:109:1:120:1 | mod m6 |
|
||||
| main.rs:657:5:657:9 | ...::g | main.rs:114:5:119:5 | fn g |
|
||||
| main.rs:658:5:658:6 | m7 | main.rs:122:1:141:1 | mod m7 |
|
||||
| main.rs:658:5:658:9 | ...::f | main.rs:133:5:140:5 | fn f |
|
||||
| main.rs:659:5:659:6 | m8 | main.rs:143:1:197:1 | mod m8 |
|
||||
| main.rs:659:5:659:9 | ...::g | main.rs:181:5:196:5 | fn g |
|
||||
| main.rs:660:5:660:6 | m9 | main.rs:199:1:207:1 | mod m9 |
|
||||
| main.rs:660:5:660:9 | ...::f | main.rs:202:5:206:5 | fn f |
|
||||
| main.rs:661:5:661:7 | m11 | main.rs:230:1:267:1 | mod m11 |
|
||||
| main.rs:661:5:661:10 | ...::f | main.rs:235:5:238:5 | fn f |
|
||||
| main.rs:662:5:662:7 | m15 | main.rs:298:1:352:1 | mod m15 |
|
||||
| main.rs:662:5:662:10 | ...::f | main.rs:339:5:351:5 | fn f |
|
||||
| main.rs:663:5:663:7 | m16 | main.rs:354:1:446:1 | mod m16 |
|
||||
| main.rs:663:5:663:10 | ...::f | main.rs:421:5:445:5 | fn f |
|
||||
| main.rs:664:5:664:7 | m17 | main.rs:448:1:478:1 | mod m17 |
|
||||
| main.rs:664:5:664:10 | ...::f | main.rs:472:5:477:5 | fn f |
|
||||
| main.rs:665:5:665:11 | nested6 | my2/nested2.rs:14:5:18:5 | mod nested6 |
|
||||
| main.rs:665:5:665:14 | ...::f | my2/nested2.rs:15:9:17:9 | fn f |
|
||||
| main.rs:666:5:666:11 | nested8 | my2/nested2.rs:22:5:26:5 | mod nested8 |
|
||||
| main.rs:666:5:666:14 | ...::f | my2/nested2.rs:23:9:25:9 | fn f |
|
||||
| main.rs:667:5:667:7 | my3 | my2/mod.rs:12:1:12:12 | mod my3 |
|
||||
| main.rs:667:5:667:10 | ...::f | my2/my3/mod.rs:1:1:5:1 | fn f |
|
||||
| main.rs:668:5:668:12 | nested_f | my/my4/my5/mod.rs:1:1:3:1 | fn f |
|
||||
| main.rs:669:5:669:7 | m18 | main.rs:480:1:498:1 | mod m18 |
|
||||
| main.rs:669:5:669:12 | ...::m19 | main.rs:485:5:497:5 | mod m19 |
|
||||
| main.rs:669:5:669:17 | ...::m20 | main.rs:490:9:496:9 | mod m20 |
|
||||
| main.rs:669:5:669:20 | ...::g | main.rs:491:13:495:13 | fn g |
|
||||
| main.rs:670:5:670:7 | m23 | main.rs:527:1:552:1 | mod m23 |
|
||||
| main.rs:670:5:670:10 | ...::f | main.rs:547:5:551:5 | fn f |
|
||||
| main.rs:671:5:671:7 | m24 | main.rs:554:1:622:1 | mod m24 |
|
||||
| main.rs:671:5:671:10 | ...::f | main.rs:608:5:621:5 | fn f |
|
||||
| main.rs:672:5:672:8 | zelf | main.rs:0:0:0:0 | Crate(main@0.0.1) |
|
||||
| main.rs:672:5:672:11 | ...::h | main.rs:50:1:69:1 | fn h |
|
||||
| main.rs:674:5:674:11 | AStruct | main.rs:629:1:629:17 | struct AStruct |
|
||||
| main.rs:675:5:675:11 | AStruct | main.rs:629:1:629:17 | struct AStruct |
|
||||
| my2/mod.rs:5:5:5:11 | nested2 | my2/mod.rs:1:1:1:16 | mod nested2 |
|
||||
| my2/mod.rs:5:5:5:20 | ...::nested3 | my2/nested2.rs:1:1:11:1 | mod nested3 |
|
||||
| my2/mod.rs:5:5:5:29 | ...::nested4 | my2/nested2.rs:2:5:10:5 | mod nested4 |
|
||||
@@ -354,7 +359,7 @@ resolvePath
|
||||
| my2/my3/mod.rs:3:5:3:5 | g | my2/mod.rs:3:1:6:1 | fn g |
|
||||
| my2/my3/mod.rs:4:5:4:5 | h | main.rs:50:1:69:1 | fn h |
|
||||
| my2/my3/mod.rs:7:5:7:9 | super | my2/mod.rs:1:1:17:30 | SourceFile |
|
||||
| my2/my3/mod.rs:7:5:7:16 | ...::super | main.rs:1:1:672:2 | SourceFile |
|
||||
| my2/my3/mod.rs:7:5:7:16 | ...::super | main.rs:1:1:677:2 | SourceFile |
|
||||
| my2/my3/mod.rs:7:5:7:19 | ...::h | main.rs:50:1:69:1 | fn h |
|
||||
| my2/my3/mod.rs:8:5:8:9 | super | my2/mod.rs:1:1:17:30 | SourceFile |
|
||||
| my2/my3/mod.rs:8:5:8:12 | ...::g | my2/mod.rs:3:1:6:1 | fn g |
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
multipleMethodCallTargets
|
||||
| dereference.rs:61:15:61:24 | e1.deref() | file://:0:0:0:0 | fn deref |
|
||||
| dereference.rs:61:15:61:24 | e1.deref() | file://:0:0:0:0 | fn deref |
|
||||
102
rust/ql/test/library-tests/type-inference/dereference.rs
Normal file
102
rust/ql/test/library-tests/type-inference/dereference.rs
Normal file
@@ -0,0 +1,102 @@
|
||||
/// This file contains tests for dereferencing with through the `Deref` trait.
|
||||
use std::ops::Deref;
|
||||
|
||||
struct MyIntPointer {
|
||||
value: i64,
|
||||
}
|
||||
|
||||
impl Deref for MyIntPointer {
|
||||
type Target = i64;
|
||||
|
||||
// MyIntPointer::deref
|
||||
fn deref(&self) -> &i64 {
|
||||
&self.value // $ fieldof=MyIntPointer
|
||||
}
|
||||
}
|
||||
|
||||
struct MySmartPointer<T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
impl<T> Deref for MySmartPointer<T> {
|
||||
type Target = T;
|
||||
|
||||
// MySmartPointer::deref
|
||||
fn deref(&self) -> &T {
|
||||
&self.value // $ fieldof=MySmartPointer
|
||||
}
|
||||
}
|
||||
|
||||
fn explicit_monomorphic_dereference() {
|
||||
// Dereference with method call
|
||||
let a1 = MyIntPointer { value: 34i64 };
|
||||
let _b1 = a1.deref(); // $ method=MyIntPointer::deref type=_b1:&T.i64
|
||||
|
||||
// Dereference with overloaded dereference operator
|
||||
let a2 = MyIntPointer { value: 34i64 };
|
||||
let _b2 = *a2; // $ method=MyIntPointer::deref type=_b2:i64
|
||||
|
||||
// Call method on explicitly dereferenced value
|
||||
let a3 = MyIntPointer { value: 34i64 };
|
||||
let _b3 = (*a3).is_positive(); // $ method=MyIntPointer::deref method=is_positive type=_b3:bool
|
||||
}
|
||||
|
||||
fn explicit_polymorphic_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let c1 = MySmartPointer { value: 'a' };
|
||||
let _d1 = c1.deref(); // $ method=MySmartPointer::deref type=_d1:&T.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let c2 = MySmartPointer { value: 'a' };
|
||||
let _d2 = *c2; // $ method=MySmartPointer::deref type=_d2:char
|
||||
|
||||
// Call method on explicitly dereferenced value with type parameter
|
||||
let c3 = MySmartPointer { value: 34i64 };
|
||||
let _d3 = (*c3).is_positive(); // $ method=MySmartPointer::deref method=is_positive type=_d3:bool
|
||||
}
|
||||
|
||||
fn explicit_ref_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let e1 = &'a';
|
||||
let _f1 = e1.deref(); // $ method=deref MISSING: type=_f1:&T.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let e2 = &'a';
|
||||
let _f2 = *e2; // $ method=deref type=_f2:char
|
||||
|
||||
// Call method on explicitly dereferenced value with type parameter
|
||||
let e3 = &34i64;
|
||||
let _f3 = (*e3).is_positive(); // $ method=deref method=is_positive type=_f3:bool
|
||||
}
|
||||
|
||||
fn explicit_box_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let g1: Box<char> = Box::new('a');
|
||||
let _h1 = g1.deref(); // $ method=deref type=_h1:&T.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let g2: Box<char> = Box::new('a');
|
||||
let _h2 = *g2; // $ method=deref type=_h2:char
|
||||
|
||||
// Call method on explicitly dereferenced value with type parameter
|
||||
let g3: Box<i64> = Box::new(34i64);
|
||||
let _h3 = (*g3).is_positive(); // $ method=deref method=is_positive type=_h3:bool
|
||||
}
|
||||
|
||||
fn implicit_dereference() {
|
||||
// Call method on implicitly dereferenced value
|
||||
let x = MyIntPointer { value: 34i64 };
|
||||
let _y = x.is_positive(); // $ MISSING: method=is_positive type=_y:bool
|
||||
|
||||
// Call method on implicitly dereferenced value
|
||||
let x = MySmartPointer { value: 34i64 };
|
||||
let _y = x.is_positive(); // $ MISSING: method=is_positive type=_y:bool
|
||||
}
|
||||
|
||||
pub fn test() {
|
||||
explicit_monomorphic_dereference();
|
||||
explicit_polymorphic_dereference();
|
||||
explicit_ref_dereference();
|
||||
explicit_box_dereference();
|
||||
implicit_dereference();
|
||||
}
|
||||
@@ -1079,6 +1079,11 @@ mod method_call_type_conversion {
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
struct S2;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
struct MyInt {
|
||||
a: i64,
|
||||
}
|
||||
|
||||
impl<T> S<T> {
|
||||
fn m1(self) -> T {
|
||||
self.0 // $ fieldof=S
|
||||
@@ -1093,6 +1098,24 @@ mod method_call_type_conversion {
|
||||
}
|
||||
}
|
||||
|
||||
trait ATrait {
|
||||
fn method_on_borrow(&self) -> i64;
|
||||
fn method_not_on_borrow(self) -> i64;
|
||||
}
|
||||
|
||||
// Trait implementation on a borrow.
|
||||
impl ATrait for &MyInt {
|
||||
// MyInt::method_on_borrow
|
||||
fn method_on_borrow(&self) -> i64 {
|
||||
(*(*self)).a // $ method=deref fieldof=MyInt
|
||||
}
|
||||
|
||||
// MyInt::method_not_on_borrow
|
||||
fn method_not_on_borrow(self) -> i64 {
|
||||
(*self).a // $ method=deref fieldof=MyInt
|
||||
}
|
||||
}
|
||||
|
||||
pub fn f() {
|
||||
let x1 = S(S2);
|
||||
println!("{:?}", x1.m1()); // $ method=m1
|
||||
@@ -1117,7 +1140,7 @@ mod method_call_type_conversion {
|
||||
println!("{:?}", x5.m1()); // $ method=m1
|
||||
println!("{:?}", x5.0); // $ fieldof=S
|
||||
|
||||
let x6 = &S(S2); // $ SPURIOUS: type=x6:&T.&T.S
|
||||
let x6 = &S(S2);
|
||||
|
||||
// explicit dereference
|
||||
println!("{:?}", (*x6).m1()); // $ method=m1 method=deref
|
||||
@@ -1128,10 +1151,21 @@ mod method_call_type_conversion {
|
||||
let t = x7.m1(); // $ method=m1 type=t:& type=t:&T.S2
|
||||
println!("{:?}", x7);
|
||||
|
||||
let x9 : String = "Hello".to_string(); // $ type=x9:String
|
||||
let x9: String = "Hello".to_string(); // $ type=x9:String
|
||||
|
||||
// Implicit `String` -> `str` conversion happens via the `Deref` trait:
|
||||
// https://doc.rust-lang.org/std/string/struct.String.html#deref.
|
||||
let u = x9.parse::<u32>(); // $ method=parse type=u:T.u32
|
||||
|
||||
let my_thing = &MyInt { a: 37 };
|
||||
// implicit borrow of a `&`
|
||||
let a = my_thing.method_on_borrow(); // $ MISSING: method=MyInt::method_on_borrow
|
||||
println!("{:?}", a);
|
||||
|
||||
// no implicit borrow
|
||||
let my_thing = &MyInt { a: 38 };
|
||||
let a = my_thing.method_not_on_borrow(); // $ MISSING: method=MyInt::method_not_on_borrow
|
||||
println!("{:?}", a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1680,6 +1714,11 @@ mod overloadable_operators {
|
||||
// Here the type of `default_vec2` must be inferred from the `+` call.
|
||||
let default_vec2 = Default::default(); // $ type=default_vec2:Vec2
|
||||
let vec2_zero_plus = Vec2 { x: 0, y: 0 } + default_vec2; // $ method=Vec2::add
|
||||
|
||||
// Here the type of `default_vec2` must be inferred from the `==` call
|
||||
// and the type of the borrowed second argument is unknown at the call.
|
||||
let default_vec2 = Default::default(); // $ type=default_vec2:Vec2
|
||||
let vec2_zero_plus = Vec2 { x: 0, y: 0 } == default_vec2; // $ method=Vec2::eq
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1881,6 +1920,8 @@ mod method_determined_by_argument_type {
|
||||
}
|
||||
}
|
||||
|
||||
mod dereference;
|
||||
|
||||
fn main() {
|
||||
field_access::f();
|
||||
method_impl::f();
|
||||
@@ -1905,4 +1946,5 @@ fn main() {
|
||||
indexers::f();
|
||||
macros::f();
|
||||
method_determined_by_argument_type::f();
|
||||
dereference::test();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,3 @@
|
||||
qltest_use_nightly: true
|
||||
qltest_dependencies:
|
||||
- poem = { version = "3.1.7" }
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# This file specifies the Rust version used to develop and test the
|
||||
# extractors written in rust. It is set to the lowest version of Rust
|
||||
# we want to support.
|
||||
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
profile = "minimal"
|
||||
components = [ ]
|
||||
@@ -1,30 +1,30 @@
|
||||
multiplePathResolutions
|
||||
| main.rs:218:14:218:17 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:218:14:218:17 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:218:14:218:17 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:218:14:218:25 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| main.rs:218:14:218:25 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| main.rs:219:13:219:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:219:13:219:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:219:13:219:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:219:13:219:24 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| main.rs:219:13:219:24 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| main.rs:220:13:220:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:220:13:220:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:220:13:220:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:220:13:220:31 | ...::aligned_alloc | file://:0:0:0:0 | fn aligned_alloc |
|
||||
| main.rs:220:13:220:31 | ...::aligned_alloc | file://:0:0:0:0 | fn aligned_alloc |
|
||||
| main.rs:221:13:221:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:221:13:221:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:221:13:221:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:221:13:221:31 | ...::aligned_alloc | file://:0:0:0:0 | fn aligned_alloc |
|
||||
| main.rs:221:13:221:31 | ...::aligned_alloc | file://:0:0:0:0 | fn aligned_alloc |
|
||||
| main.rs:222:13:222:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:222:13:222:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:222:13:222:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:222:13:222:24 | ...::calloc | file://:0:0:0:0 | fn calloc |
|
||||
| main.rs:222:13:222:24 | ...::calloc | file://:0:0:0:0 | fn calloc |
|
||||
| main.rs:223:13:223:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:223:13:223:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:223:13:223:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:223:13:223:24 | ...::calloc | file://:0:0:0:0 | fn calloc |
|
||||
| main.rs:223:13:223:24 | ...::calloc | file://:0:0:0:0 | fn calloc |
|
||||
| main.rs:224:13:224:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| main.rs:224:13:224:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| main.rs:224:13:224:16 | libc | file://:0:0:0:0 | Crate(libc@0.2.174) |
|
||||
| main.rs:224:13:224:25 | ...::realloc | file://:0:0:0:0 | fn realloc |
|
||||
| main.rs:224:13:224:25 | ...::realloc | file://:0:0:0:0 | fn realloc |
|
||||
| main.rs:229:13:229:37 | ...::with_capacity | file://:0:0:0:0 | fn with_capacity |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
qltest_cargo_check: true
|
||||
qltest_use_nightly: true
|
||||
qltest_dependencies:
|
||||
- libc = { version = "0.2.11" }
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
@@ -1,13 +1,13 @@
|
||||
multiplePathResolutions
|
||||
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
|
||||
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| deallocation.rs:106:16:106:19 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| deallocation.rs:106:16:106:27 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| deallocation.rs:106:16:106:27 | ...::malloc | file://:0:0:0:0 | fn malloc |
|
||||
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
|
||||
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| deallocation.rs:112:3:112:6 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| deallocation.rs:112:3:112:12 | ...::free | file://:0:0:0:0 | fn free |
|
||||
| deallocation.rs:112:3:112:12 | ...::free | file://:0:0:0:0 | fn free |
|
||||
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.171) |
|
||||
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.172) |
|
||||
| deallocation.rs:112:29:112:32 | libc | file://:0:0:0:0 | Crate(libc@0.2.173) |
|
||||
| deallocation.rs:260:11:260:22 | ...::from | file://:0:0:0:0 | fn from |
|
||||
| deallocation.rs:260:11:260:22 | ...::from | file://:0:0:0:0 | fn from |
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
qltest_cargo_check: true
|
||||
qltest_use_nightly: true
|
||||
qltest_dependencies:
|
||||
- libc = { version = "0.2.11" }
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-03-17"
|
||||
Reference in New Issue
Block a user