Merge branch 'main' into macrometric2

This commit is contained in:
Geoffrey White
2025-10-30 10:19:11 +00:00
committed by GitHub
139 changed files with 6564 additions and 4384 deletions

View File

@@ -15,5 +15,5 @@ extensions:
- ["<_ as futures_util::io::AsyncBufReadExt>::read_until", "Argument[self].Reference", "Argument[1].Reference", "taint", "manual"]
- ["<_ as futures_util::io::AsyncBufReadExt>::fill_buf", "Argument[self]", "ReturnValue.Future.Field[core::result::Result::Ok(0)]", "taint", "manual"]
- ["<_ as futures_util::io::AsyncBufReadExt>::lines", "Argument[self]", "ReturnValue", "taint", "manual"]
- ["<alloc::boxed::Box as core::iter::traits::iterator::Iterator>::next", "Argument[self]", "ReturnValue.Future.Field[core::option::Option::Some(0)]", "taint", "manual"]
- ["<_ as futures_io::if_std::AsyncBufRead>::poll_fill_buf", "Argument[self].Reference", "ReturnValue.Field[core::task::poll::Poll::Ready(0)].Field[core::result::Result::Ok(0)]", "taint", "manual"]
- ["<_ as futures_io::if_std::AsyncRead>::poll_read", "Argument[self].Reference", "Argument[1].Reference", "taint", "manual"]

View File

@@ -9,6 +9,4 @@ extensions:
extensible: summaryModel
data:
- ["<futures_rustls::TlsConnector>::connect", "Argument[1]", "ReturnValue.Future.Field[core::result::Result::Ok(0)]", "taint", "manual"]
- ["<futures_rustls::client::TlsStream as futures_io::if_std::AsyncRead>::poll_read", "Argument[self].Reference", "Argument[1].Reference", "taint", "manual"]
- ["<rustls::conn::ConnectionCommon>::reader", "Argument[self]", "ReturnValue", "taint", "manual"]
- ["<rustls::conn::connection::Reader as std::io::Read>::read", "Argument[self]", "Argument[0].Reference", "taint", "manual"]

View File

@@ -10,7 +10,3 @@ extensions:
extensible: summaryModel
data:
- ["<std::net::tcp::TcpStream>::try_clone", "Argument[self]", "ReturnValue.Field[core::result::Result::Ok(0)]", "taint", "manual"]
- ["<std::net::tcp::TcpStream as std::io::Read>::read", "Argument[self]", "Argument[0].Reference", "taint", "manual"]
- ["<std::net::tcp::TcpStream as std::io::Read>::read_to_string", "Argument[self]", "Argument[0].Reference", "taint", "manual"]
- ["<std::net::tcp::TcpStream as std::io::Read>::read_to_end", "Argument[self]", "Argument[0].Reference", "taint", "manual"]
- ["<std::net::tcp::TcpStream as std::io::Read>::read_exact", "Argument[self]", "Argument[0].Reference", "taint", "manual"]

View File

@@ -901,14 +901,14 @@ private predicate assocFunctionInfo(
/**
* Holds if function `f` with the name `name` and the arity `arity` exists in
* blanket implementation `impl` of `trait`, and the type at position
* blanket (like) implementation `impl` of `trait`, and the type at position
* `pos` is `t`.
*
* `blanketPath` points to the type `blanketTypeParam` inside `t`, which
* is the type parameter used in the blanket implementation.
*/
pragma[nomagic]
private predicate functionInfoBlanket(
private predicate functionInfoBlanketLike(
Function f, string name, int arity, ImplItemNode impl, Trait trait, FunctionPosition pos,
AssocFunctionType t, TypePath blanketPath, TypeParam blanketTypeParam
) {
@@ -1027,19 +1027,20 @@ private module MethodResolution {
/**
* Holds if method `m` with the name `name` and the arity `arity` exists in
* blanket implementation `impl` of `trait`, and the type of the `self`
* blanket (like) implementation `impl` of `trait`, and the type of the `self`
* parameter is `selfType`.
*
* `blanketPath` points to the type `blanketTypeParam` inside `selfType`, which
* is the type parameter used in the blanket implementation.
*/
pragma[nomagic]
private predicate methodInfoBlanket(
private predicate methodInfoBlanketLike(
Method m, string name, int arity, ImplItemNode impl, Trait trait, AssocFunctionType selfType,
TypePath blanketPath, TypeParam blanketTypeParam
) {
exists(FunctionPosition pos |
functionInfoBlanket(m, name, arity, impl, trait, pos, selfType, blanketPath, blanketTypeParam) and
functionInfoBlanketLike(m, name, arity, impl, trait, pos, selfType, blanketPath,
blanketTypeParam) and
pos.isSelf()
)
}
@@ -1113,8 +1114,8 @@ private module MethodResolution {
}
/**
* Holds if method call `mc` may target a method in blanket implementation `i`
* with `self` parameter having type `selfType`.
* Holds if method call `mc` may target a method in blanket (like) implementation
* `impl` with `self` parameter having type `selfType`.
*
* `blanketPath` points to the type `blanketTypeParam` inside `selfType`, which
* is the type parameter used in the blanket implementation.
@@ -1125,13 +1126,13 @@ private module MethodResolution {
*/
bindingset[mc]
pragma[inline_late]
private predicate methodCallBlanketCandidate(
private predicate methodCallBlanketLikeCandidate(
MethodCall mc, Method m, ImplItemNode impl, AssocFunctionType self, TypePath blanketPath,
TypeParam blanketTypeParam
) {
exists(string name, int arity |
mc.hasNameAndArity(name, arity) and
methodInfoBlanket(m, name, arity, impl, _, self, blanketPath, blanketTypeParam)
methodInfoBlanketLike(m, name, arity, impl, _, self, blanketPath, blanketTypeParam)
|
methodCallVisibleImplTraitCandidate(mc, impl)
or
@@ -1216,6 +1217,23 @@ private module MethodResolution {
borrow), i, _)
}
/**
* Holds if the method inside blanket-like implementation `impl` with matching name
* and arity can be ruled out as a target of this call, either because the candidate
* receiver type represented by `derefChain` and `borrow` is incompatible with the `self`
* parameter type, or because the blanket constraint is not satisfied.
*/
pragma[nomagic]
private predicate hasIncompatibleBlanketLikeTarget(
ImplItemNode impl, string derefChain, boolean borrow
) {
ReceiverIsNotInstantiationOfBlanketLikeSelfParam::argIsNotInstantiationOf(MkMethodCallCand(this,
derefChain, borrow), impl, _)
or
ReceiverSatisfiesBlanketLikeConstraint::dissatisfiesBlanketConstraint(MkMethodCallCand(this,
derefChain, borrow), impl)
}
/**
* Same as `getACandidateReceiverTypeAt`, but with traits substituted in for types
* with trait bounds.
@@ -1234,11 +1252,10 @@ private module MethodResolution {
isComplexRootStripped(strippedTypePath, result)
}
bindingset[strippedTypePath, strippedType, derefChain, borrow]
private predicate hasNoCompatibleTargetCheck(
bindingset[derefChain, borrow, strippedTypePath, strippedType]
private predicate hasNoCompatibleNonBlanketLikeTargetCheck(
string derefChain, boolean borrow, TypePath strippedTypePath, Type strippedType
) {
// todo: also check that all blanket implementation candidates are incompatible
forall(ImplOrTraitItemNode i |
methodCallNonBlanketCandidate(this, _, i, _, strippedTypePath, strippedType)
|
@@ -1246,6 +1263,30 @@ private module MethodResolution {
)
}
bindingset[derefChain, borrow, strippedTypePath, strippedType]
private predicate hasNoCompatibleTargetCheck(
string derefChain, boolean borrow, TypePath strippedTypePath, Type strippedType
) {
this.hasNoCompatibleNonBlanketLikeTargetCheck(derefChain, borrow, strippedTypePath,
strippedType) and
forall(ImplItemNode i | methodCallBlanketLikeCandidate(this, _, i, _, _, _) |
this.hasIncompatibleBlanketLikeTarget(i, derefChain, borrow)
)
}
bindingset[derefChain, borrow, strippedTypePath, strippedType]
private predicate hasNoCompatibleNonBlanketTargetCheck(
string derefChain, boolean borrow, TypePath strippedTypePath, Type strippedType
) {
this.hasNoCompatibleNonBlanketLikeTargetCheck(derefChain, borrow, strippedTypePath,
strippedType) and
forall(ImplItemNode i |
methodCallBlanketLikeCandidate(this, _, i, _, _, _) and not i.isBlanketImplementation()
|
this.hasIncompatibleBlanketLikeTarget(i, derefChain, borrow)
)
}
/**
* Holds if the candidate receiver type represented by `derefChain` does not
* have a matching method target.
@@ -1256,7 +1297,7 @@ private module MethodResolution {
this.supportsAutoDerefAndBorrow()
or
// needed for the `hasNoCompatibleTarget` check in
// `SatisfiesBlanketConstraintInput::hasBlanketCandidate`
// `ReceiverSatisfiesBlanketLikeConstraintInput::hasBlanketCandidate`
derefChain = ""
) and
exists(TypePath strippedTypePath, Type strippedType |
@@ -1266,6 +1307,26 @@ private module MethodResolution {
)
}
/**
* Holds if the candidate receiver type represented by `derefChain` does not have
* a matching non-blanket method target.
*/
pragma[nomagic]
predicate hasNoCompatibleNonBlanketTargetNoBorrow(string derefChain) {
(
this.supportsAutoDerefAndBorrow()
or
// needed for the `hasNoCompatibleTarget` check in
// `ReceiverSatisfiesBlanketLikeConstraintInput::hasBlanketCandidate`
derefChain = ""
) and
exists(TypePath strippedTypePath, Type strippedType |
not derefChain.matches("%.ref") and // no need to try a borrow if the last thing we did was a deref
strippedType = this.getComplexStrippedType(derefChain, false, strippedTypePath) and
this.hasNoCompatibleNonBlanketTargetCheck(derefChain, false, strippedTypePath, strippedType)
)
}
/**
* Holds if the candidate receiver type represented by `derefChain`, followed
* by a borrow, does not have a matching method target.
@@ -1275,7 +1336,21 @@ private module MethodResolution {
exists(TypePath strippedTypePath, Type strippedType |
this.hasNoCompatibleTargetNoBorrow(derefChain) and
strippedType = this.getComplexStrippedType(derefChain, true, strippedTypePath) and
this.hasNoCompatibleTargetCheck(derefChain, true, strippedTypePath, strippedType)
this.hasNoCompatibleNonBlanketLikeTargetCheck(derefChain, true, strippedTypePath,
strippedType)
)
}
/**
* Holds if the candidate receiver type represented by `derefChain`, followed
* by a borrow, does not have a matching non-blanket method target.
*/
pragma[nomagic]
predicate hasNoCompatibleNonBlanketTargetBorrow(string derefChain) {
exists(TypePath strippedTypePath, Type strippedType |
this.hasNoCompatibleTargetNoBorrow(derefChain) and
strippedType = this.getComplexStrippedType(derefChain, true, strippedTypePath) and
this.hasNoCompatibleNonBlanketTargetCheck(derefChain, true, strippedTypePath, strippedType)
)
}
@@ -1470,11 +1545,11 @@ private module MethodResolution {
}
pragma[nomagic]
predicate hasNoCompatibleTarget() {
mc_.hasNoCompatibleTargetBorrow(derefChain) and
predicate hasNoCompatibleNonBlanketTarget() {
mc_.hasNoCompatibleNonBlanketTargetBorrow(derefChain) and
borrow = true
or
mc_.hasNoCompatibleTargetNoBorrow(derefChain) and
mc_.hasNoCompatibleNonBlanketTargetNoBorrow(derefChain) and
borrow = false
}
@@ -1555,20 +1630,20 @@ private module MethodResolution {
Location getLocation() { result = mc_.getLocation() }
}
private module ReceiverSatisfiesBlanketConstraintInput implements
private module ReceiverSatisfiesBlanketLikeConstraintInput implements
BlanketImplementation::SatisfiesBlanketConstraintInputSig<MethodCallCand>
{
pragma[nomagic]
predicate hasBlanketCandidate(
MethodCallCand mcc, ImplItemNode impl, TypePath blanketPath, TypeParam blanketTypeParam
) {
exists(MethodCall mc, string name, int arity |
mcc.hasSignature(mc, _, _, name, arity) and
methodCallBlanketCandidate(mc, _, impl, _, blanketPath, blanketTypeParam) and
exists(MethodCall mc |
mc = mcc.getMethodCall() and
methodCallBlanketLikeCandidate(mc, _, impl, _, blanketPath, blanketTypeParam) and
// Only apply blanket implementations when no other implementations are possible;
// this is to account for codebases that use the (unstable) specialization feature
// (https://rust-lang.github.io/rfcs/1210-impl-specialization.html)
mcc.hasNoCompatibleTarget()
(mcc.hasNoCompatibleNonBlanketTarget() or not impl.isBlanketImplementation())
|
mcc.hasNoBorrow()
or
@@ -1577,9 +1652,9 @@ private module MethodResolution {
}
}
private module ReceiverSatisfiesBlanketConstraint =
private module ReceiverSatisfiesBlanketLikeConstraint =
BlanketImplementation::SatisfiesBlanketConstraint<MethodCallCand,
ReceiverSatisfiesBlanketConstraintInput>;
ReceiverSatisfiesBlanketLikeConstraintInput>;
/**
* A configuration for matching the type of a receiver against the type of
@@ -1600,8 +1675,8 @@ private module MethodResolution {
|
methodCallNonBlanketCandidate(mc, m, i, selfType, strippedTypePath, strippedType)
or
methodCallBlanketCandidate(mc, m, i, selfType, _, _) and
ReceiverSatisfiesBlanketConstraint::satisfiesBlanketConstraint(mcc, i)
methodCallBlanketLikeCandidate(mc, m, i, selfType, _, _) and
ReceiverSatisfiesBlanketLikeConstraint::satisfiesBlanketConstraint(mcc, i)
)
}
@@ -1626,6 +1701,30 @@ private module MethodResolution {
private module ReceiverIsInstantiationOfSelfParam =
ArgIsInstantiationOf<MethodCallCand, ReceiverIsInstantiationOfSelfParamInput>;
/**
* A configuration for anti-matching the type of a receiver against the type of
* a `self` parameter belonging to a blanket (like) implementation.
*/
private module ReceiverIsNotInstantiationOfBlanketLikeSelfParamInput implements
IsInstantiationOfInputSig<MethodCallCand, AssocFunctionType>
{
pragma[nomagic]
predicate potentialInstantiationOf(
MethodCallCand mcc, TypeAbstraction abs, AssocFunctionType constraint
) {
methodCallBlanketLikeCandidate(mcc.getMethodCall(), _, abs, constraint, _, _) and
if abs.(Impl).hasTrait()
then
// inherent methods take precedence over trait methods, so only allow
// trait methods when there are no matching inherent methods
mcc.hasNoInherentTarget()
else any()
}
}
private module ReceiverIsNotInstantiationOfBlanketLikeSelfParam =
ArgIsInstantiationOf<MethodCallCand, ReceiverIsNotInstantiationOfBlanketLikeSelfParamInput>;
/**
* A configuration for matching the type qualifier of a method call
* against the type being implemented in an `impl` block. For example,
@@ -1679,10 +1778,6 @@ private module MethodResolution {
ReceiverIsInstantiationOfSelfParamInput::potentialInstantiationOf0(mcc, abs, constraint) and
abs = any(Impl i | not i.hasTrait())
}
predicate relevantConstraint(AssocFunctionType constraint) {
methodInfo(_, _, _, _, constraint, _, _)
}
}
private module ReceiverIsNotInstantiationOfInherentSelfParam =
@@ -1812,8 +1907,12 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
}
pragma[nomagic]
private Type getInferredSelfType(string derefChain, boolean borrow, TypePath path) {
result = this.getACandidateReceiverTypeAt(derefChain, borrow, path)
private Type getInferredSelfType(AccessPosition apos, string derefChainBorrow, TypePath path) {
exists(string derefChain, boolean borrow |
result = this.getACandidateReceiverTypeAt(derefChain, borrow, path) and
derefChainBorrow = encodeDerefChainBorrow(derefChain, borrow) and
apos.isSelf()
)
}
pragma[nomagic]
@@ -1839,11 +1938,7 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
bindingset[derefChainBorrow]
Type getInferredType(string derefChainBorrow, AccessPosition apos, TypePath path) {
exists(string derefChain, boolean borrow |
derefChainBorrow = encodeDerefChainBorrow(derefChain, borrow) and
apos.isSelf() and
result = this.getInferredSelfType(derefChain, borrow, path)
)
result = this.getInferredSelfType(apos, derefChainBorrow, path)
or
result = this.getInferredNonSelfType(apos, path)
}
@@ -1948,18 +2043,18 @@ private module NonMethodResolution {
}
pragma[nomagic]
private predicate functionInfoBlanketRelevantPos(
private predicate functionInfoBlanketLikeRelevantPos(
NonMethodFunction f, string name, int arity, ImplItemNode impl, Trait trait,
FunctionPosition pos, AssocFunctionType t, TypePath blanketPath, TypeParam blanketTypeParam
) {
functionInfoBlanket(f, name, arity, impl, trait, pos, t, blanketPath, blanketTypeParam) and
functionInfoBlanketLike(f, name, arity, impl, trait, pos, t, blanketPath, blanketTypeParam) and
(
if pos.isReturn()
then
// We only check that the context of the call provides relevant type information
// when no argument can
not exists(FunctionPosition pos0 |
functionInfoBlanket(f, name, arity, impl, trait, pos0, _, _, _) and
functionInfoBlanketLike(f, name, arity, impl, trait, pos0, _, _, _) and
not pos0.isReturn()
)
else any()
@@ -1967,10 +2062,10 @@ private module NonMethodResolution {
}
pragma[nomagic]
private predicate blanketCallTraitCandidate(Element fc, Trait trait) {
private predicate blanketLikeCallTraitCandidate(Element fc, Trait trait) {
exists(string name, int arity |
fc.(NonMethodCall).hasNameAndArity(name, arity) and
functionInfoBlanketRelevantPos(_, name, arity, _, trait, _, _, _, _)
functionInfoBlanketLikeRelevantPos(_, name, arity, _, trait, _, _, _, _)
|
not fc.(Call).hasTrait()
or
@@ -1978,7 +2073,7 @@ private module NonMethodResolution {
)
}
private module BlanketTraitIsVisible = TraitIsVisible<blanketCallTraitCandidate/2>;
private module BlanketTraitIsVisible = TraitIsVisible<blanketLikeCallTraitCandidate/2>;
/** A (potential) non-method call, `f(x)`. */
final class NonMethodCall extends CallExpr {
@@ -2037,13 +2132,13 @@ private module NonMethodResolution {
}
pragma[nomagic]
predicate resolveCallTargetBlanketCandidate(
predicate resolveCallTargetBlanketLikeCandidate(
ImplItemNode impl, FunctionPosition pos, TypePath blanketPath, TypeParam blanketTypeParam
) {
exists(string name, int arity, Trait trait, AssocFunctionType t |
this.hasNameAndArity(name, arity) and
exists(this.getTypeAt(pos, blanketPath)) and
functionInfoBlanketRelevantPos(_, name, arity, impl, trait, pos, t, blanketPath,
functionInfoBlanketLikeRelevantPos(_, name, arity, impl, trait, pos, t, blanketPath,
blanketTypeParam) and
BlanketTraitIsVisible::traitIsVisible(this, trait)
)
@@ -2080,7 +2175,7 @@ private module NonMethodResolution {
private newtype TCallAndBlanketPos =
MkCallAndBlanketPos(NonMethodCall fc, FunctionPosition pos) {
fc.resolveCallTargetBlanketCandidate(_, pos, _, _)
fc.resolveCallTargetBlanketLikeCandidate(_, pos, _, _)
}
/** A call tagged with a position. */
@@ -2106,7 +2201,7 @@ private module NonMethodResolution {
) {
exists(NonMethodCall fc, FunctionPosition pos |
fcp = MkCallAndBlanketPos(fc, pos) and
fc.resolveCallTargetBlanketCandidate(impl, pos, blanketPath, blanketTypeParam)
fc.resolveCallTargetBlanketLikeCandidate(impl, pos, blanketPath, blanketTypeParam)
)
}
}
@@ -2129,12 +2224,12 @@ private module NonMethodResolution {
exists(FunctionPosition pos |
ArgSatisfiesBlanketConstraint::satisfiesBlanketConstraint(fcp, abs) and
fcp = MkCallAndBlanketPos(_, pos) and
functionInfoBlanketRelevantPos(_, _, _, abs, _, pos, constraint, _, _)
functionInfoBlanketLikeRelevantPos(_, _, _, abs, _, pos, constraint, _, _)
)
}
predicate relevantConstraint(AssocFunctionType constraint) {
functionInfoBlanketRelevantPos(_, _, _, _, _, _, constraint, _, _)
functionInfoBlanketLikeRelevantPos(_, _, _, _, _, _, constraint, _, _)
}
}

View File

@@ -143,7 +143,11 @@ class NonAliasPathTypeMention extends PathTypeMention {
)
}
private TypeMention getPositionalTypeArgument0(int i) {
/**
* Gets the positional type argument at index `i` that occurs in this path, if
* any.
*/
private TypeMention getPathPositionalTypeArgument(int i) {
result = this.getSegment().getGenericArgList().getTypeArg(i)
or
// `Option::<i32>::Some` is valid in addition to `Option::Some::<i32>`
@@ -151,25 +155,61 @@ class NonAliasPathTypeMention extends PathTypeMention {
result = this.getQualifier().getSegment().getGenericArgList().getTypeArg(i)
}
private TypeMention getPositionalTypeArgument(int i) {
result = this.getPositionalTypeArgument0(i)
/**
* Gets the type mention that instantiates the implicit `Self` type parameter
* for this path, if it occurs in the position of a trait bound.
*/
private TypeMention getSelfTraitBoundArg() {
exists(ImplItemNode impl | this = impl.getTraitPath() and result = impl.(Impl).getSelfTy())
or
exists(Trait subTrait |
this = subTrait.getATypeBound().getTypeRepr().(PathTypeRepr).getPath() and
result.(SelfTypeParameterMention).getTrait() = subTrait
)
or
exists(TypeParamItemNode tp | this = tp.getABoundPath() and result = tp)
}
private Type getDefaultPositionalTypeArgument(int i, TypePath path) {
// If a type argument is not given in the path, then we use the default for
// the type parameter if one exists for the type.
not exists(this.getPositionalTypeArgument0(i)) and
result = this.resolveRootType().getTypeParameterDefault(i) and
not exists(this.getPathPositionalTypeArgument(i)) and
// Defaults only apply to type mentions in type annotations
this = any(PathTypeRepr ptp).getPath().getQualifier*()
this = any(PathTypeRepr ptp).getPath().getQualifier*() and
exists(Type ty, TypePath prefix |
ty = this.resolveRootType().getTypeParameterDefault(i).resolveTypeAt(prefix) and
if not ty = TSelfTypeParameter(resolved)
then result = ty and path = prefix
else
// When a default contains an implicit `Self` type parameter, it should
// be substituted for the type that implements the trait.
exists(TypePath suffix |
path = prefix.append(suffix) and
result = this.getSelfTraitBoundArg().resolveTypeAt(suffix)
)
)
}
private Type getPositionalTypeArgument(int i, TypePath path) {
result = this.getPathPositionalTypeArgument(i).resolveTypeAt(path)
or
result = this.getDefaultPositionalTypeArgument(i, path)
}
/**
* Gets the type for this path for the type parameter `tp` at `path`, when the
* type parameter does not correspond directly to a type mention.
*/
private Type getTypeForTypeParameterAt(TypeParameter tp, TypePath path) {
exists(int i |
result = this.getPositionalTypeArgument(pragma[only_bind_into](i), path) and
tp = this.resolveRootType().getPositionalTypeParameter(pragma[only_bind_into](i))
)
}
/** Gets the type mention in this path for the type parameter `tp`, if any. */
pragma[nomagic]
private TypeMention getTypeMentionForTypeParameter(TypeParameter tp) {
exists(int i |
result = this.getPositionalTypeArgument(pragma[only_bind_into](i)) and
tp = this.resolveRootType().getPositionalTypeParameter(pragma[only_bind_into](i))
)
or
exists(TypeAlias alias |
result = this.getAnAssocTypeArgument(alias) and
tp = TAssociatedTypeTypeParameter(alias)
@@ -237,9 +277,17 @@ class NonAliasPathTypeMention extends PathTypeMention {
typePath.isEmpty() and
result = this.resolveRootType()
or
exists(TypeParameter tp, TypePath suffix |
result = this.getTypeMentionForTypeParameter(tp).resolveTypeAt(suffix) and
typePath = TypePath::cons(tp, suffix)
exists(TypeParameter tp, TypePath suffix | typePath = TypePath::cons(tp, suffix) |
result = this.getTypeForTypeParameterAt(tp, suffix)
or
result = this.getTypeMentionForTypeParameter(tp).resolveTypeAt(suffix)
)
or
// When the path refers to a trait, then the implicit `Self` type parameter
// should be instantiated from the context.
exists(TypePath suffix |
result = this.getSelfTraitBoundArg().resolveTypeAt(suffix) and
typePath = TypePath::cons(TSelfTypeParameter(resolved), suffix)
)
}
}
@@ -296,6 +344,11 @@ class TraitMention extends TypeMention instanceof TraitItemNode {
typePath.isEmpty() and
result = TTrait(this)
or
// The implicit `Self` type parameter occurs at the `Self` type parameter
// position.
typePath = TypePath::singleton(TSelfTypeParameter(this)) and
result = TSelfTypeParameter(this)
or
exists(TypeAlias alias |
alias = super.getAnAssocItem() and
typePath = TypePath::singleton(result) and

View File

@@ -132,4 +132,17 @@ module SatisfiesBlanketConstraint<
SatisfiesBlanketConstraint::satisfiesConstraintType(ato, TTrait(traitBound), _, _)
)
}
/**
* Holds if the argument type `at` does _not_ satisfy the first non-trivial blanket
* constraint of `impl`.
*/
pragma[nomagic]
predicate dissatisfiesBlanketConstraint(ArgumentType at, ImplItemNode impl) {
exists(ArgumentTypeAndBlanketOffset ato, Trait traitBound |
ato = MkArgumentTypeAndBlanketOffset(at, _) and
SatisfiesBlanketConstraintInput::relevantConstraint(ato, impl, traitBound) and
SatisfiesBlanketConstraint::dissatisfiesConstraint(ato, TTrait(traitBound))
)
}
}

View File

@@ -74,7 +74,9 @@ module PartitionedCookieConfig implements DataFlow::ConfigSig {
node instanceof Barrier
}
predicate observeDiffInformedIncrementalMode() { any() }
predicate observeDiffInformedIncrementalMode() {
none() // only used negatively
}
}
module InsecureCookieFlow = TaintTracking::Global<InsecureCookieConfig>;

View File

@@ -32,7 +32,9 @@ module AccessAfterLifetimeConfig implements DataFlow::ConfigSig {
predicate observeDiffInformedIncrementalMode() { any() }
Location getASelectedSourceLocation(DataFlow::Node source) {
exists(Variable target, DataFlow::Node sink | result = target.getLocation() |
exists(Variable target, DataFlow::Node sink |
result = [target.getLocation(), source.getLocation()]
|
isSink(sink) and
narrowDereferenceAfterLifetime(source, sink, target)
)

View File

@@ -7,25 +7,25 @@ models
| 6 | Source: reqwest::blocking::get; ReturnValue.Field[core::result::Result::Ok(0)]; remote |
| 7 | Source: reqwest::get; ReturnValue.Future.Field[core::result::Result::Ok(0)]; remote |
| 8 | Summary: <_ as futures_io::if_std::AsyncBufRead>::poll_fill_buf; Argument[self].Reference; ReturnValue.Field[core::task::poll::Poll::Ready(0)].Field[core::result::Result::Ok(0)]; taint |
| 9 | Summary: <_ as futures_util::io::AsyncBufReadExt>::fill_buf; Argument[self]; ReturnValue.Future.Field[core::result::Result::Ok(0)]; taint |
| 10 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_line; Argument[self].Reference; Argument[0].Reference; taint |
| 11 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_line; Argument[self]; Argument[0].Reference; taint |
| 12 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_until; Argument[self].Reference; Argument[1].Reference; taint |
| 13 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_until; Argument[self]; Argument[1].Reference; taint |
| 14 | Summary: <_ as futures_util::io::AsyncReadExt>::read; Argument[self].Reference; Argument[0].Reference; taint |
| 15 | Summary: <_ as futures_util::io::AsyncReadExt>::read; Argument[self]; Argument[0].Reference; taint |
| 16 | Summary: <_ as futures_util::io::AsyncReadExt>::read_to_end; Argument[self].Reference; Argument[0].Reference; taint |
| 17 | Summary: <_ as futures_util::io::AsyncReadExt>::read_to_end; Argument[self]; Argument[0].Reference; taint |
| 18 | Summary: <_ as std::io::BufRead>::read_line; Argument[self]; Argument[0].Reference; taint |
| 19 | Summary: <_ as std::io::Read>::read; Argument[self]; Argument[0].Reference; taint |
| 20 | Summary: <_ as std::io::Read>::take; Argument[self]; ReturnValue; taint |
| 21 | Summary: <_ as tokio::io::util::async_read_ext::AsyncReadExt>::read; Argument[self]; Argument[0].Reference; taint |
| 22 | Summary: <core::option::Option>::unwrap; Argument[self].Field[core::option::Option::Some(0)]; ReturnValue; value |
| 23 | Summary: <core::pin::Pin>::new; Argument[0].Reference; ReturnValue; value |
| 24 | Summary: <core::pin::Pin>::new; Argument[0]; ReturnValue; value |
| 25 | Summary: <core::result::Result>::unwrap; Argument[self].Field[core::result::Result::Ok(0)]; ReturnValue; value |
| 26 | Summary: <futures_rustls::TlsConnector>::connect; Argument[1]; ReturnValue.Future.Field[core::result::Result::Ok(0)]; taint |
| 27 | Summary: <futures_rustls::client::TlsStream as futures_io::if_std::AsyncRead>::poll_read; Argument[self].Reference; Argument[1].Reference; taint |
| 9 | Summary: <_ as futures_io::if_std::AsyncRead>::poll_read; Argument[self].Reference; Argument[1].Reference; taint |
| 10 | Summary: <_ as futures_util::io::AsyncBufReadExt>::fill_buf; Argument[self]; ReturnValue.Future.Field[core::result::Result::Ok(0)]; taint |
| 11 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_line; Argument[self].Reference; Argument[0].Reference; taint |
| 12 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_line; Argument[self]; Argument[0].Reference; taint |
| 13 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_until; Argument[self].Reference; Argument[1].Reference; taint |
| 14 | Summary: <_ as futures_util::io::AsyncBufReadExt>::read_until; Argument[self]; Argument[1].Reference; taint |
| 15 | Summary: <_ as futures_util::io::AsyncReadExt>::read; Argument[self].Reference; Argument[0].Reference; taint |
| 16 | Summary: <_ as futures_util::io::AsyncReadExt>::read; Argument[self]; Argument[0].Reference; taint |
| 17 | Summary: <_ as futures_util::io::AsyncReadExt>::read_to_end; Argument[self].Reference; Argument[0].Reference; taint |
| 18 | Summary: <_ as futures_util::io::AsyncReadExt>::read_to_end; Argument[self]; Argument[0].Reference; taint |
| 19 | Summary: <_ as std::io::BufRead>::read_line; Argument[self]; Argument[0].Reference; taint |
| 20 | Summary: <_ as std::io::Read>::read; Argument[self]; Argument[0].Reference; taint |
| 21 | Summary: <_ as std::io::Read>::take; Argument[self]; ReturnValue; taint |
| 22 | Summary: <_ as tokio::io::util::async_read_ext::AsyncReadExt>::read; Argument[self]; Argument[0].Reference; taint |
| 23 | Summary: <core::option::Option>::unwrap; Argument[self].Field[core::option::Option::Some(0)]; ReturnValue; value |
| 24 | Summary: <core::pin::Pin>::new; Argument[0].Reference; ReturnValue; value |
| 25 | Summary: <core::pin::Pin>::new; Argument[0]; ReturnValue; value |
| 26 | Summary: <core::result::Result>::unwrap; Argument[self].Field[core::result::Result::Ok(0)]; ReturnValue; value |
| 27 | Summary: <futures_rustls::TlsConnector>::connect; Argument[1]; ReturnValue.Future.Field[core::result::Result::Ok(0)]; taint |
| 28 | Summary: <futures_util::io::buf_reader::BufReader>::new; Argument[0]; ReturnValue; taint |
| 29 | Summary: <reqwest::async_impl::response::Response>::bytes; Argument[self]; ReturnValue.Future.Field[core::result::Result::Ok(0)]; taint |
| 30 | Summary: <reqwest::async_impl::response::Response>::chunk; Argument[self]; ReturnValue.Future.Field[core::result::Result::Ok(0)].Field[core::option::Option::Some(0)]; taint |
@@ -34,10 +34,9 @@ models
| 33 | Summary: <reqwest::blocking::response::Response>::text; Argument[self]; ReturnValue.Field[core::result::Result::Ok(0)]; taint |
| 34 | Summary: <reqwest::blocking::response::Response>::text_with_charset; Argument[self]; ReturnValue.Field[core::result::Result::Ok(0)]; taint |
| 35 | Summary: <std::io::buffered::bufreader::BufReader>::new; Argument[0]; ReturnValue; taint |
| 36 | Summary: <std::net::tcp::TcpStream as std::io::Read>::read; Argument[self]; Argument[0].Reference; taint |
| 37 | Summary: <tokio::net::tcp::stream::TcpStream>::peek; Argument[self]; Argument[0].Reference; taint |
| 38 | Summary: <tokio::net::tcp::stream::TcpStream>::try_read; Argument[self]; Argument[0].Reference; taint |
| 39 | Summary: <tokio::net::tcp::stream::TcpStream>::try_read_buf; Argument[self]; Argument[0].Reference; taint |
| 36 | Summary: <tokio::net::tcp::stream::TcpStream>::peek; Argument[self]; Argument[0].Reference; taint |
| 37 | Summary: <tokio::net::tcp::stream::TcpStream>::try_read; Argument[self]; Argument[0].Reference; taint |
| 38 | Summary: <tokio::net::tcp::stream::TcpStream>::try_read_buf; Argument[self]; Argument[0].Reference; taint |
edges
| test.rs:11:9:11:22 | remote_string1 | test.rs:12:10:12:23 | remote_string1 | provenance | |
| test.rs:11:26:11:47 | ...::get | test.rs:11:26:11:62 | ...::get(...) [Ok] | provenance | Src:MaD:6 |
@@ -47,21 +46,21 @@ edges
| test.rs:11:26:11:71 | TryExpr | test.rs:11:9:11:22 | remote_string1 | provenance | |
| test.rs:14:9:14:22 | remote_string2 | test.rs:15:10:15:23 | remote_string2 | provenance | |
| test.rs:14:26:14:47 | ...::get | test.rs:14:26:14:62 | ...::get(...) [Ok] | provenance | Src:MaD:6 |
| test.rs:14:26:14:62 | ...::get(...) [Ok] | test.rs:14:26:14:71 | ... .unwrap() | provenance | MaD:25 |
| test.rs:14:26:14:62 | ...::get(...) [Ok] | test.rs:14:26:14:71 | ... .unwrap() | provenance | MaD:26 |
| test.rs:14:26:14:71 | ... .unwrap() | test.rs:14:26:14:78 | ... .text() [Ok] | provenance | MaD:33 |
| test.rs:14:26:14:78 | ... .text() [Ok] | test.rs:14:26:14:87 | ... .unwrap() | provenance | MaD:25 |
| test.rs:14:26:14:78 | ... .text() [Ok] | test.rs:14:26:14:87 | ... .unwrap() | provenance | MaD:26 |
| test.rs:14:26:14:87 | ... .unwrap() | test.rs:14:9:14:22 | remote_string2 | provenance | |
| test.rs:17:9:17:22 | remote_string3 | test.rs:18:10:18:23 | remote_string3 | provenance | |
| test.rs:17:26:17:47 | ...::get | test.rs:17:26:17:62 | ...::get(...) [Ok] | provenance | Src:MaD:6 |
| test.rs:17:26:17:62 | ...::get(...) [Ok] | test.rs:17:26:17:71 | ... .unwrap() | provenance | MaD:25 |
| test.rs:17:26:17:62 | ...::get(...) [Ok] | test.rs:17:26:17:71 | ... .unwrap() | provenance | MaD:26 |
| test.rs:17:26:17:71 | ... .unwrap() | test.rs:17:26:17:98 | ... .text_with_charset(...) [Ok] | provenance | MaD:34 |
| test.rs:17:26:17:98 | ... .text_with_charset(...) [Ok] | test.rs:17:26:17:107 | ... .unwrap() | provenance | MaD:25 |
| test.rs:17:26:17:98 | ... .text_with_charset(...) [Ok] | test.rs:17:26:17:107 | ... .unwrap() | provenance | MaD:26 |
| test.rs:17:26:17:107 | ... .unwrap() | test.rs:17:9:17:22 | remote_string3 | provenance | |
| test.rs:20:9:20:22 | remote_string4 | test.rs:21:10:21:23 | remote_string4 | provenance | |
| test.rs:20:26:20:47 | ...::get | test.rs:20:26:20:62 | ...::get(...) [Ok] | provenance | Src:MaD:6 |
| test.rs:20:26:20:62 | ...::get(...) [Ok] | test.rs:20:26:20:71 | ... .unwrap() | provenance | MaD:25 |
| test.rs:20:26:20:62 | ...::get(...) [Ok] | test.rs:20:26:20:71 | ... .unwrap() | provenance | MaD:26 |
| test.rs:20:26:20:71 | ... .unwrap() | test.rs:20:26:20:79 | ... .bytes() [Ok] | provenance | MaD:32 |
| test.rs:20:26:20:79 | ... .bytes() [Ok] | test.rs:20:26:20:88 | ... .unwrap() | provenance | MaD:25 |
| test.rs:20:26:20:79 | ... .bytes() [Ok] | test.rs:20:26:20:88 | ... .unwrap() | provenance | MaD:26 |
| test.rs:20:26:20:88 | ... .unwrap() | test.rs:20:9:20:22 | remote_string4 | provenance | |
| test.rs:23:9:23:22 | remote_string5 | test.rs:24:10:24:23 | remote_string5 | provenance | |
| test.rs:23:26:23:37 | ...::get | test.rs:23:26:23:52 | ...::get(...) [future, Ok] | provenance | Src:MaD:7 |
@@ -87,7 +86,7 @@ edges
| test.rs:29:24:29:57 | TryExpr | test.rs:29:9:29:20 | mut request1 | provenance | |
| test.rs:30:10:30:25 | request1.chunk() [future, Ok, Some] | test.rs:30:10:30:31 | await ... [Ok, Some] | provenance | |
| test.rs:30:10:30:31 | await ... [Ok, Some] | test.rs:30:10:30:32 | TryExpr [Some] | provenance | |
| test.rs:30:10:30:32 | TryExpr [Some] | test.rs:30:10:30:41 | ... .unwrap() | provenance | MaD:22 |
| test.rs:30:10:30:32 | TryExpr [Some] | test.rs:30:10:30:41 | ... .unwrap() | provenance | MaD:23 |
| test.rs:31:15:31:25 | Some(...) [Some] | test.rs:31:20:31:24 | chunk | provenance | |
| test.rs:31:20:31:24 | chunk | test.rs:32:14:32:18 | chunk | provenance | |
| test.rs:31:29:31:44 | request1.chunk() [future, Ok, Some] | test.rs:31:29:31:50 | await ... [Ok, Some] | provenance | |
@@ -106,8 +105,7 @@ edges
| test.rs:67:24:67:58 | TryExpr | test.rs:67:9:67:20 | mut response | provenance | |
| test.rs:67:31:67:42 | send_request | test.rs:67:24:67:51 | sender.send_request(...) [future, Ok] | provenance | Src:MaD:2 |
| test.rs:68:11:68:18 | response | test.rs:68:10:68:18 | &response | provenance | |
| test.rs:155:13:155:22 | mut stream | test.rs:162:29:162:39 | [post] &mut buffer [&ref] | provenance | MaD:19 |
| test.rs:155:13:155:22 | mut stream | test.rs:162:29:162:39 | [post] &mut buffer [&ref] | provenance | MaD:36 |
| test.rs:155:13:155:22 | mut stream | test.rs:162:29:162:39 | [post] &mut buffer [&ref] | provenance | MaD:20 |
| test.rs:155:26:155:53 | ...::connect | test.rs:155:26:155:62 | ...::connect(...) [Ok] | provenance | Src:MaD:3 |
| test.rs:155:26:155:62 | ...::connect(...) [Ok] | test.rs:155:26:155:63 | TryExpr | provenance | |
| test.rs:155:26:155:63 | TryExpr | test.rs:155:13:155:22 | mut stream | provenance | |
@@ -119,17 +117,17 @@ edges
| test.rs:174:26:174:61 | ...::connect_timeout | test.rs:174:26:174:105 | ...::connect_timeout(...) [Ok] | provenance | Src:MaD:4 |
| test.rs:174:26:174:105 | ...::connect_timeout(...) [Ok] | test.rs:174:26:174:106 | TryExpr | provenance | |
| test.rs:174:26:174:106 | TryExpr | test.rs:174:13:174:22 | mut stream | provenance | |
| test.rs:182:21:182:30 | mut reader | test.rs:185:44:185:52 | [post] &mut line [&ref] | provenance | MaD:18 |
| test.rs:182:34:182:64 | ...::new(...) | test.rs:182:34:182:74 | ... .take(...) | provenance | MaD:20 |
| test.rs:182:21:182:30 | mut reader | test.rs:185:44:185:52 | [post] &mut line [&ref] | provenance | MaD:19 |
| test.rs:182:34:182:64 | ...::new(...) | test.rs:182:34:182:74 | ... .take(...) | provenance | MaD:21 |
| test.rs:182:34:182:74 | ... .take(...) | test.rs:182:21:182:30 | mut reader | provenance | |
| test.rs:182:58:182:63 | stream | test.rs:182:34:182:64 | ...::new(...) | provenance | MaD:35 |
| test.rs:185:44:185:52 | [post] &mut line [&ref] | test.rs:185:49:185:52 | [post] line | provenance | |
| test.rs:185:49:185:52 | [post] line | test.rs:192:35:192:38 | line | provenance | |
| test.rs:192:35:192:38 | line | test.rs:192:34:192:38 | &line | provenance | |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:232:35:232:46 | [post] &mut buffer1 [&ref] | provenance | MaD:37 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:236:36:236:47 | [post] &mut buffer2 [&ref] | provenance | MaD:21 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:252:41:252:51 | [post] &mut buffer [&ref] | provenance | MaD:38 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:275:45:275:55 | [post] &mut buffer [&ref] | provenance | MaD:39 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:232:35:232:46 | [post] &mut buffer1 [&ref] | provenance | MaD:36 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:236:36:236:47 | [post] &mut buffer2 [&ref] | provenance | MaD:22 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:252:41:252:51 | [post] &mut buffer [&ref] | provenance | MaD:37 |
| test.rs:224:9:224:24 | mut tokio_stream | test.rs:275:45:275:55 | [post] &mut buffer [&ref] | provenance | MaD:38 |
| test.rs:224:28:224:57 | ...::connect | test.rs:224:28:224:66 | ...::connect(...) [future, Ok] | provenance | Src:MaD:5 |
| test.rs:224:28:224:66 | ...::connect(...) [future, Ok] | test.rs:224:28:224:72 | await ... [Ok] | provenance | |
| test.rs:224:28:224:72 | await ... [Ok] | test.rs:224:28:224:73 | TryExpr | provenance | |
@@ -159,22 +157,22 @@ edges
| test.rs:380:13:380:22 | mut reader | test.rs:386:44:386:49 | reader | provenance | |
| test.rs:380:13:380:22 | mut reader | test.rs:399:68:399:73 | reader | provenance | |
| test.rs:380:13:380:22 | mut reader | test.rs:403:31:403:36 | reader | provenance | |
| test.rs:380:13:380:22 | mut reader | test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | provenance | MaD:14 |
| test.rs:380:13:380:22 | mut reader | test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | provenance | MaD:15 |
| test.rs:380:13:380:22 | mut reader | test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | provenance | MaD:16 |
| test.rs:380:13:380:22 | mut reader | test.rs:408:55:408:60 | reader | provenance | |
| test.rs:380:26:380:60 | connector.connect(...) [future, Ok] | test.rs:380:26:380:66 | await ... [Ok] | provenance | |
| test.rs:380:26:380:66 | await ... [Ok] | test.rs:380:26:380:67 | TryExpr | provenance | |
| test.rs:380:26:380:67 | TryExpr | test.rs:380:13:380:22 | mut reader | provenance | |
| test.rs:380:57:380:59 | tcp | test.rs:380:26:380:60 | connector.connect(...) [future, Ok] | provenance | MaD:26 |
| test.rs:380:57:380:59 | tcp | test.rs:380:26:380:60 | connector.connect(...) [future, Ok] | provenance | MaD:27 |
| test.rs:381:15:381:20 | reader | test.rs:381:14:381:20 | &reader | provenance | |
| test.rs:386:17:386:26 | mut pinned | test.rs:387:19:387:24 | pinned | provenance | |
| test.rs:386:17:386:26 | mut pinned | test.rs:389:56:389:66 | [post] &mut buffer [&ref] | provenance | MaD:27 |
| test.rs:386:17:386:26 | mut pinned | test.rs:389:56:389:66 | [post] &mut buffer [&ref] | provenance | MaD:9 |
| test.rs:386:17:386:26 | mut pinned [&ref] | test.rs:387:19:387:24 | pinned [&ref] | provenance | |
| test.rs:386:17:386:26 | mut pinned [&ref] | test.rs:389:56:389:66 | [post] &mut buffer [&ref] | provenance | MaD:27 |
| test.rs:386:17:386:26 | mut pinned [&ref] | test.rs:389:56:389:66 | [post] &mut buffer [&ref] | provenance | MaD:9 |
| test.rs:386:30:386:50 | ...::new(...) | test.rs:386:17:386:26 | mut pinned | provenance | |
| test.rs:386:30:386:50 | ...::new(...) [&ref] | test.rs:386:17:386:26 | mut pinned [&ref] | provenance | |
| test.rs:386:39:386:49 | &mut reader [&ref] | test.rs:386:30:386:50 | ...::new(...) | provenance | MaD:23 |
| test.rs:386:39:386:49 | &mut reader [&ref] | test.rs:386:30:386:50 | ...::new(...) [&ref] | provenance | MaD:24 |
| test.rs:386:39:386:49 | &mut reader [&ref] | test.rs:386:30:386:50 | ...::new(...) | provenance | MaD:24 |
| test.rs:386:39:386:49 | &mut reader [&ref] | test.rs:386:30:386:50 | ...::new(...) [&ref] | provenance | MaD:25 |
| test.rs:386:44:386:49 | reader | test.rs:386:39:386:49 | &mut reader [&ref] | provenance | |
| test.rs:387:19:387:24 | pinned | test.rs:387:18:387:24 | &pinned | provenance | |
| test.rs:387:19:387:24 | pinned [&ref] | test.rs:387:18:387:24 | &pinned | provenance | |
@@ -183,35 +181,35 @@ edges
| test.rs:389:61:389:66 | [post] buffer | test.rs:392:23:392:33 | buffer[...] | provenance | |
| test.rs:391:23:391:28 | buffer | test.rs:391:22:391:28 | &buffer | provenance | |
| test.rs:392:23:392:33 | buffer[...] | test.rs:392:22:392:33 | &... | provenance | |
| test.rs:399:63:399:73 | &mut reader [&ref] | test.rs:399:76:399:87 | [post] &mut buffer1 [&ref] | provenance | MaD:14 |
| test.rs:399:63:399:73 | &mut reader [&ref] | test.rs:399:76:399:87 | [post] &mut buffer1 [&ref] | provenance | MaD:15 |
| test.rs:399:68:399:73 | reader | test.rs:399:63:399:73 | &mut reader [&ref] | provenance | |
| test.rs:399:76:399:87 | [post] &mut buffer1 [&ref] | test.rs:399:81:399:87 | [post] buffer1 | provenance | |
| test.rs:399:81:399:87 | [post] buffer1 | test.rs:400:19:400:40 | buffer1[...] | provenance | |
| test.rs:400:19:400:40 | buffer1[...] | test.rs:400:18:400:40 | &... | provenance | |
| test.rs:403:31:403:36 | reader | test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | provenance | MaD:14 |
| test.rs:403:31:403:36 | reader | test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | provenance | MaD:15 |
| test.rs:403:43:403:54 | [post] &mut buffer2 [&ref] | test.rs:403:48:403:54 | [post] buffer2 | provenance | |
| test.rs:403:48:403:54 | [post] buffer2 | test.rs:405:19:405:40 | buffer2[...] | provenance | |
| test.rs:405:19:405:40 | buffer2[...] | test.rs:405:18:405:40 | &... | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:409:15:409:21 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:413:44:413:50 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:423:41:423:47 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:437:26:437:43 | reader2.fill_buf() [future, Ok] | provenance | MaD:9 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:437:26:437:43 | reader2.fill_buf() [future, Ok] | provenance | MaD:10 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:444:44:444:50 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:457:68:457:74 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:461:31:461:37 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | provenance | MaD:14 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | provenance | MaD:15 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | provenance | MaD:16 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:467:44:467:50 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:479:26:479:43 | reader2.fill_buf() [future, Ok] | provenance | MaD:9 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:479:26:479:43 | reader2.fill_buf() [future, Ok] | provenance | MaD:10 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:486:31:486:37 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:486:57:486:65 | [post] &mut line [&ref] | provenance | MaD:12 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:486:57:486:65 | [post] &mut line [&ref] | provenance | MaD:13 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:486:57:486:65 | [post] &mut line [&ref] | provenance | MaD:14 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:493:31:493:37 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:493:49:493:57 | [post] &mut line [&ref] | provenance | MaD:10 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:493:49:493:57 | [post] &mut line [&ref] | provenance | MaD:11 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:493:49:493:57 | [post] &mut line [&ref] | provenance | MaD:12 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:500:31:500:37 | reader2 | provenance | |
| test.rs:408:13:408:23 | mut reader2 | test.rs:500:51:500:61 | [post] &mut buffer [&ref] | provenance | MaD:16 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:500:51:500:61 | [post] &mut buffer [&ref] | provenance | MaD:17 |
| test.rs:408:13:408:23 | mut reader2 | test.rs:500:51:500:61 | [post] &mut buffer [&ref] | provenance | MaD:18 |
| test.rs:408:27:408:61 | ...::new(...) | test.rs:408:13:408:23 | mut reader2 | provenance | |
| test.rs:408:55:408:60 | reader | test.rs:408:27:408:61 | ...::new(...) | provenance | MaD:28 |
| test.rs:409:15:409:21 | reader2 | test.rs:409:14:409:21 | &reader2 | provenance | |
@@ -221,8 +219,8 @@ edges
| test.rs:413:17:413:26 | mut pinned [&ref] | test.rs:416:26:416:54 | pinned.poll_fill_buf(...) [Ready, Ok] | provenance | MaD:8 |
| test.rs:413:30:413:51 | ...::new(...) | test.rs:413:17:413:26 | mut pinned | provenance | |
| test.rs:413:30:413:51 | ...::new(...) [&ref] | test.rs:413:17:413:26 | mut pinned [&ref] | provenance | |
| test.rs:413:39:413:50 | &mut reader2 [&ref] | test.rs:413:30:413:51 | ...::new(...) | provenance | MaD:23 |
| test.rs:413:39:413:50 | &mut reader2 [&ref] | test.rs:413:30:413:51 | ...::new(...) [&ref] | provenance | MaD:24 |
| test.rs:413:39:413:50 | &mut reader2 [&ref] | test.rs:413:30:413:51 | ...::new(...) | provenance | MaD:24 |
| test.rs:413:39:413:50 | &mut reader2 [&ref] | test.rs:413:30:413:51 | ...::new(...) [&ref] | provenance | MaD:25 |
| test.rs:413:44:413:50 | reader2 | test.rs:413:39:413:50 | &mut reader2 [&ref] | provenance | |
| test.rs:414:19:414:24 | pinned | test.rs:414:18:414:24 | &pinned | provenance | |
| test.rs:414:19:414:24 | pinned [&ref] | test.rs:414:18:414:24 | &pinned | provenance | |
@@ -237,8 +235,8 @@ edges
| test.rs:423:27:423:48 | ...::new(...) | test.rs:423:27:423:71 | ... .poll_fill_buf(...) [Ready, Ok] | provenance | MaD:8 |
| test.rs:423:27:423:48 | ...::new(...) [&ref] | test.rs:423:27:423:71 | ... .poll_fill_buf(...) [Ready, Ok] | provenance | MaD:8 |
| test.rs:423:27:423:71 | ... .poll_fill_buf(...) [Ready, Ok] | test.rs:423:17:423:23 | buffer2 [Ready, Ok] | provenance | |
| test.rs:423:36:423:47 | &mut reader2 [&ref] | test.rs:423:27:423:48 | ...::new(...) | provenance | MaD:23 |
| test.rs:423:36:423:47 | &mut reader2 [&ref] | test.rs:423:27:423:48 | ...::new(...) [&ref] | provenance | MaD:24 |
| test.rs:423:36:423:47 | &mut reader2 [&ref] | test.rs:423:27:423:48 | ...::new(...) | provenance | MaD:24 |
| test.rs:423:36:423:47 | &mut reader2 [&ref] | test.rs:423:27:423:48 | ...::new(...) [&ref] | provenance | MaD:25 |
| test.rs:423:41:423:47 | reader2 | test.rs:423:36:423:47 | &mut reader2 [&ref] | provenance | |
| test.rs:424:20:424:26 | buffer2 [Ready, Ok] | test.rs:425:17:425:36 | ...::Ready(...) [Ready, Ok] | provenance | |
| test.rs:424:20:424:26 | buffer2 [Ready, Ok] | test.rs:426:27:426:33 | buffer2 [Ready, Ok] | provenance | |
@@ -251,20 +249,27 @@ edges
| test.rs:437:26:437:49 | await ... [Ok] | test.rs:437:26:437:50 | TryExpr | provenance | |
| test.rs:437:26:437:50 | TryExpr | test.rs:437:17:437:22 | buffer | provenance | |
| test.rs:444:17:444:26 | mut pinned | test.rs:445:19:445:24 | pinned | provenance | |
| test.rs:444:17:444:26 | mut pinned | test.rs:447:56:447:66 | [post] &mut buffer [&ref] | provenance | MaD:9 |
| test.rs:444:17:444:26 | mut pinned [&ref] | test.rs:445:19:445:24 | pinned [&ref] | provenance | |
| test.rs:444:17:444:26 | mut pinned [&ref] | test.rs:447:56:447:66 | [post] &mut buffer [&ref] | provenance | MaD:9 |
| test.rs:444:30:444:51 | ...::new(...) | test.rs:444:17:444:26 | mut pinned | provenance | |
| test.rs:444:30:444:51 | ...::new(...) [&ref] | test.rs:444:17:444:26 | mut pinned [&ref] | provenance | |
| test.rs:444:39:444:50 | &mut reader2 [&ref] | test.rs:444:30:444:51 | ...::new(...) | provenance | MaD:23 |
| test.rs:444:39:444:50 | &mut reader2 [&ref] | test.rs:444:30:444:51 | ...::new(...) [&ref] | provenance | MaD:24 |
| test.rs:444:39:444:50 | &mut reader2 [&ref] | test.rs:444:30:444:51 | ...::new(...) | provenance | MaD:24 |
| test.rs:444:39:444:50 | &mut reader2 [&ref] | test.rs:444:30:444:51 | ...::new(...) [&ref] | provenance | MaD:25 |
| test.rs:444:44:444:50 | reader2 | test.rs:444:39:444:50 | &mut reader2 [&ref] | provenance | |
| test.rs:445:19:445:24 | pinned | test.rs:445:18:445:24 | &pinned | provenance | |
| test.rs:445:19:445:24 | pinned [&ref] | test.rs:445:18:445:24 | &pinned | provenance | |
| test.rs:457:63:457:74 | &mut reader2 [&ref] | test.rs:457:77:457:88 | [post] &mut buffer1 [&ref] | provenance | MaD:14 |
| test.rs:447:56:447:66 | [post] &mut buffer [&ref] | test.rs:447:61:447:66 | [post] buffer | provenance | |
| test.rs:447:61:447:66 | [post] buffer | test.rs:448:19:448:24 | buffer | provenance | |
| test.rs:447:61:447:66 | [post] buffer | test.rs:450:23:450:33 | buffer[...] | provenance | |
| test.rs:448:19:448:24 | buffer | test.rs:448:18:448:24 | &buffer | provenance | |
| test.rs:450:23:450:33 | buffer[...] | test.rs:450:22:450:33 | &... | provenance | |
| test.rs:457:63:457:74 | &mut reader2 [&ref] | test.rs:457:77:457:88 | [post] &mut buffer1 [&ref] | provenance | MaD:15 |
| test.rs:457:68:457:74 | reader2 | test.rs:457:63:457:74 | &mut reader2 [&ref] | provenance | |
| test.rs:457:77:457:88 | [post] &mut buffer1 [&ref] | test.rs:457:82:457:88 | [post] buffer1 | provenance | |
| test.rs:457:82:457:88 | [post] buffer1 | test.rs:458:19:458:40 | buffer1[...] | provenance | |
| test.rs:458:19:458:40 | buffer1[...] | test.rs:458:18:458:40 | &... | provenance | |
| test.rs:461:31:461:37 | reader2 | test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | provenance | MaD:14 |
| test.rs:461:31:461:37 | reader2 | test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | provenance | MaD:15 |
| test.rs:461:44:461:55 | [post] &mut buffer2 [&ref] | test.rs:461:49:461:55 | [post] buffer2 | provenance | |
| test.rs:461:49:461:55 | [post] buffer2 | test.rs:462:19:462:40 | buffer2[...] | provenance | |
| test.rs:462:19:462:40 | buffer2[...] | test.rs:462:18:462:40 | &... | provenance | |
@@ -274,8 +279,8 @@ edges
| test.rs:467:17:467:26 | mut pinned [&ref] | test.rs:470:26:470:54 | pinned.poll_fill_buf(...) [Ready, Ok] | provenance | MaD:8 |
| test.rs:467:30:467:51 | ...::new(...) | test.rs:467:17:467:26 | mut pinned | provenance | |
| test.rs:467:30:467:51 | ...::new(...) [&ref] | test.rs:467:17:467:26 | mut pinned [&ref] | provenance | |
| test.rs:467:39:467:50 | &mut reader2 [&ref] | test.rs:467:30:467:51 | ...::new(...) | provenance | MaD:23 |
| test.rs:467:39:467:50 | &mut reader2 [&ref] | test.rs:467:30:467:51 | ...::new(...) [&ref] | provenance | MaD:24 |
| test.rs:467:39:467:50 | &mut reader2 [&ref] | test.rs:467:30:467:51 | ...::new(...) | provenance | MaD:24 |
| test.rs:467:39:467:50 | &mut reader2 [&ref] | test.rs:467:30:467:51 | ...::new(...) [&ref] | provenance | MaD:25 |
| test.rs:467:44:467:50 | reader2 | test.rs:467:39:467:50 | &mut reader2 [&ref] | provenance | |
| test.rs:468:19:468:24 | pinned | test.rs:468:18:468:24 | &pinned | provenance | |
| test.rs:468:19:468:24 | pinned [&ref] | test.rs:468:18:468:24 | &pinned | provenance | |
@@ -290,15 +295,15 @@ edges
| test.rs:479:26:479:43 | reader2.fill_buf() [future, Ok] | test.rs:479:26:479:49 | await ... [Ok] | provenance | |
| test.rs:479:26:479:49 | await ... [Ok] | test.rs:479:26:479:50 | TryExpr | provenance | |
| test.rs:479:26:479:50 | TryExpr | test.rs:479:17:479:22 | buffer | provenance | |
| test.rs:486:31:486:37 | reader2 | test.rs:486:57:486:65 | [post] &mut line [&ref] | provenance | MaD:12 |
| test.rs:486:31:486:37 | reader2 | test.rs:486:57:486:65 | [post] &mut line [&ref] | provenance | MaD:13 |
| test.rs:486:57:486:65 | [post] &mut line [&ref] | test.rs:486:62:486:65 | [post] line | provenance | |
| test.rs:486:62:486:65 | [post] line | test.rs:487:19:487:22 | line | provenance | |
| test.rs:487:19:487:22 | line | test.rs:487:18:487:22 | &line | provenance | |
| test.rs:493:31:493:37 | reader2 | test.rs:493:49:493:57 | [post] &mut line [&ref] | provenance | MaD:10 |
| test.rs:493:31:493:37 | reader2 | test.rs:493:49:493:57 | [post] &mut line [&ref] | provenance | MaD:11 |
| test.rs:493:49:493:57 | [post] &mut line [&ref] | test.rs:493:54:493:57 | [post] line | provenance | |
| test.rs:493:54:493:57 | [post] line | test.rs:494:19:494:22 | line | provenance | |
| test.rs:494:19:494:22 | line | test.rs:494:18:494:22 | &line | provenance | |
| test.rs:500:31:500:37 | reader2 | test.rs:500:51:500:61 | [post] &mut buffer [&ref] | provenance | MaD:16 |
| test.rs:500:31:500:37 | reader2 | test.rs:500:51:500:61 | [post] &mut buffer [&ref] | provenance | MaD:17 |
| test.rs:500:51:500:61 | [post] &mut buffer [&ref] | test.rs:500:56:500:61 | [post] buffer | provenance | |
| test.rs:500:56:500:61 | [post] buffer | test.rs:501:19:501:24 | buffer | provenance | |
| test.rs:501:19:501:24 | buffer | test.rs:501:18:501:24 | &buffer | provenance | |
@@ -512,6 +517,12 @@ nodes
| test.rs:445:18:445:24 | &pinned | semmle.label | &pinned |
| test.rs:445:19:445:24 | pinned | semmle.label | pinned |
| test.rs:445:19:445:24 | pinned [&ref] | semmle.label | pinned [&ref] |
| test.rs:447:56:447:66 | [post] &mut buffer [&ref] | semmle.label | [post] &mut buffer [&ref] |
| test.rs:447:61:447:66 | [post] buffer | semmle.label | [post] buffer |
| test.rs:448:18:448:24 | &buffer | semmle.label | &buffer |
| test.rs:448:19:448:24 | buffer | semmle.label | buffer |
| test.rs:450:22:450:33 | &... | semmle.label | &... |
| test.rs:450:23:450:33 | buffer[...] | semmle.label | buffer[...] |
| test.rs:457:63:457:74 | &mut reader2 [&ref] | semmle.label | &mut reader2 [&ref] |
| test.rs:457:68:457:74 | reader2 | semmle.label | reader2 |
| test.rs:457:77:457:88 | [post] &mut buffer1 [&ref] | semmle.label | [post] &mut buffer1 [&ref] |
@@ -598,6 +609,8 @@ testFailures
| test.rs:427:26:427:28 | buf | test.rs:373:19:373:36 | ...::connect | test.rs:427:26:427:28 | buf | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:438:18:438:23 | buffer | test.rs:373:19:373:36 | ...::connect | test.rs:438:18:438:23 | buffer | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:445:18:445:24 | &pinned | test.rs:373:19:373:36 | ...::connect | test.rs:445:18:445:24 | &pinned | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:448:18:448:24 | &buffer | test.rs:373:19:373:36 | ...::connect | test.rs:448:18:448:24 | &buffer | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:450:22:450:33 | &... | test.rs:373:19:373:36 | ...::connect | test.rs:450:22:450:33 | &... | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:458:18:458:40 | &... | test.rs:373:19:373:36 | ...::connect | test.rs:458:18:458:40 | &... | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:462:18:462:40 | &... | test.rs:373:19:373:36 | ...::connect | test.rs:462:18:462:40 | &... | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |
| test.rs:468:18:468:24 | &pinned | test.rs:373:19:373:36 | ...::connect | test.rs:468:18:468:24 | &pinned | $@ | test.rs:373:19:373:36 | ...::connect | ...::connect |

View File

@@ -445,9 +445,9 @@ mod futures_rustls {
sink(&pinned); // $ hasTaintFlow=url
let mut cx = Context::from_waker(futures::task::noop_waker_ref());
let bytes_read = pinned.poll_read(&mut cx, &mut buffer);
sink(&buffer); // $ MISSING: hasTaintFlow=url
sink(&buffer); // $ hasTaintFlow=url
if let Poll::Ready(Ok(n)) = bytes_read {
sink(&buffer[..n]); // $ MISSING: hasTaintFlow=url
sink(&buffer[..n]); // $ hasTaintFlow=url
}
}

View File

@@ -5,9 +5,13 @@ multipleCallTargets
| dereference.rs:184:17:184:30 | ... .foo() |
| dereference.rs:186:17:186:25 | S.bar(...) |
| dereference.rs:187:17:187:29 | S.bar(...) |
| main.rs:2437:13:2437:31 | ...::from(...) |
| main.rs:2438:13:2438:31 | ...::from(...) |
| main.rs:2439:13:2439:31 | ...::from(...) |
| main.rs:2445:13:2445:31 | ...::from(...) |
| main.rs:2446:13:2446:31 | ...::from(...) |
| main.rs:2447:13:2447:31 | ...::from(...) |
| main.rs:589:9:589:14 | S4.m() |
| main.rs:590:9:590:18 | ...::m(...) |
| main.rs:591:9:591:20 | ... .m() |
| main.rs:592:9:592:24 | ...::m(...) |
| main.rs:2519:13:2519:31 | ...::from(...) |
| main.rs:2520:13:2520:31 | ...::from(...) |
| main.rs:2521:13:2521:31 | ...::from(...) |
| main.rs:2527:13:2527:31 | ...::from(...) |
| main.rs:2528:13:2528:31 | ...::from(...) |
| main.rs:2529:13:2529:31 | ...::from(...) |

View File

@@ -184,6 +184,85 @@ mod extension_trait_blanket_impl {
}
}
mod blanket_like_impl {
#[derive(Debug, Copy, Clone)]
struct S1;
#[derive(Debug, Copy, Clone)]
struct S2;
trait MyTrait1 {
// MyTrait1::m1
fn m1(self);
}
trait MyTrait2 {
// MyTrait2::m2
fn m2(self);
}
trait MyTrait3 {
// MyTrait3::m3
fn m3(self);
}
trait MyTrait4a {
// MyTrait4a::m4
fn m4(self);
}
trait MyTrait4b {
// MyTrait4b::m4
fn m4(self);
}
impl MyTrait1 for S1 {
// S1::m1
fn m1(self) {}
}
impl MyTrait3 for S1 {
// S1::m3
fn m3(self) {}
}
impl<T: MyTrait1 + Copy> MyTrait2 for &T {
// MyTrait2Ref::m2
fn m2(self) {
self.m1() // $ target=MyTrait1::m1
}
}
impl MyTrait2 for &&S1 {
// MyTrait2RefRefS1::m2
fn m2(self) {
self.m1() // $ MISSING: target=S1::m1
}
}
impl<T: MyTrait3> MyTrait4a for T {
// MyTrait4aBlanket::m4
fn m4(self) {
self.m3() // $ target=MyTrait3::m3
}
}
impl<T> MyTrait4b for &T {
// MyTrait4bRef::m4
fn m4(self) {}
}
pub fn test_basic_blanket() {
let x1 = S1.m1(); // $ target=S1::m1
let x2 = (&S1).m2(); // $ target=MyTrait2Ref::m2
let x3 = (&&S1).m2(); // $ target=MyTrait2RefRefS1::m2
let x4 = S1.m4(); // $ target=MyTrait4aBlanket::m4
let x5 = (&S1).m4(); // $ target=MyTrait4bRef::m4
let x6 = S2.m4(); // $ target=MyTrait4bRef::m4
let x7 = (&S2).m4(); // $ target=MyTrait4bRef::m4
}
}
pub mod sql_exec {
// a highly simplified model of `MySqlConnection.execute` in SQLx

View File

@@ -535,6 +535,37 @@ mod impl_overlap {
}
}
trait MyTrait1 {
// MyTrait1::m
fn m(&self) {}
}
trait MyTrait2: MyTrait1 {}
#[derive(Debug)]
struct S4;
impl MyTrait1 for S4 {
// <S4_as_MyTrait1>::m
fn m(&self) {}
}
impl MyTrait2 for S4 {}
#[derive(Debug)]
struct S5<T5>(T5);
impl MyTrait1 for S5<i32> {
// <S5<i32>_as_MyTrait1>::m
fn m(&self) {}
}
impl MyTrait2 for S5<i32> {}
impl MyTrait1 for S5<bool> {}
impl MyTrait2 for S5<bool> {}
pub fn f() {
let x = S1;
println!("{:?}", x.common_method()); // $ target=S1::common_method
@@ -554,6 +585,13 @@ mod impl_overlap {
let w = S3(S1);
println!("{:?}", w.m(x)); // $ target=S3<T>::m
println!("{:?}", S3::m(&w, x)); // $ target=S3<T>::m
S4.m(); // $ target=<S4_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m
S4::m(&S4); // $ target=<S4_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m
S5(0i32).m(); // $ target=<S5<i32>_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m
S5::m(&S5(0i32)); // $ target=<S5<i32>_as_MyTrait1>::m $ SPURIOUS: target=MyTrait1::m
S5(true).m(); // $ target=MyTrait1::m
S5::m(&S5(true)); // $ target=MyTrait1::m
}
}
@@ -652,6 +690,50 @@ mod type_parameter_bounds {
}
}
mod trait_default_self_type_parameter {
// A trait with a type parameter that defaults to `Self`.
trait TraitWithSelfTp<A = Option<Self>> {
// TraitWithSelfTp::get_a
fn get_a(&self) -> A;
}
fn get_a<A, T: TraitWithSelfTp<A>>(thing: &T) -> A {
thing.get_a() // $ target=TraitWithSelfTp::get_a
}
// The trait bound on `T` uses the default for `A` which contains `Self`
fn tp_uses_default<S: TraitWithSelfTp>(thing: S) -> i64 {
let _ms = thing.get_a(); // $ target=TraitWithSelfTp::get_a type=_ms:T.S
0
}
// The supertrait uses the default for `A` which contains `Self`
trait SubTraitOfTraitWithSelfTp: TraitWithSelfTp + Sized {}
fn get_a_through_tp<S: SubTraitOfTraitWithSelfTp>(thing: &S) {
// `thing` is a `TraitWithSelfTp` through the trait hierarchy
let _ms = get_a(thing); // $ target=get_a type=_ms:T.S
}
struct MyStruct {
value: i32,
}
// The implementing trait uses the default for `A` which contains `Self`
impl TraitWithSelfTp for MyStruct {
fn get_a(&self) -> Option<Self> {
Some(MyStruct { value: self.value }) // $ fieldof=MyStruct
}
}
impl SubTraitOfTraitWithSelfTp for MyStruct {}
pub fn test() {
let s = MyStruct { value: 0 };
let _ms = get_a(&s); // $ target=get_a type=_ms:T.MyStruct
}
}
mod function_trait_bounds {
#[derive(Debug, Clone, Copy)]
struct MyThing<T> {
@@ -2753,6 +2835,7 @@ fn main() {
method_impl::g(method_impl::Foo {}, method_impl::Foo {}); // $ target=g
method_non_parametric_impl::f(); // $ target=f
method_non_parametric_trait_impl::f(); // $ target=f
trait_default_self_type_parameter::test(); // $ target=test
function_trait_bounds::f(); // $ target=f
associated_type_in_trait::f(); // $ target=f
generic_enum::f(); // $ target=f