mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Also apply adjustedAccessType in RelevantAccess
This commit is contained in:
@@ -697,7 +697,7 @@ mod trait_associated_type {
|
||||
println!("{:?}", x3.put(1).unwrap()); // $ method=S::put method=unwrap
|
||||
|
||||
// Call to default implementation in `trait` block
|
||||
println!("{:?}", x3.putTwo(2, 3).unwrap()); // $ method=putTwo MISSING: method=unwrap
|
||||
println!("{:?}", x3.putTwo(2, 3).unwrap()); // $ method=putTwo method=unwrap
|
||||
|
||||
let x4 = g(S); // $ MISSING: type=x4:AT
|
||||
println!("{:?}", x4);
|
||||
|
||||
@@ -778,6 +778,9 @@ inferType
|
||||
| main.rs:697:33:697:33 | 1 | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:700:18:700:23 | "{:?}\\n" | | {EXTERNAL LOCATION} | str |
|
||||
| main.rs:700:26:700:27 | x3 | | main.rs:619:5:620:13 | S |
|
||||
| main.rs:700:26:700:40 | x3.putTwo(...) | | main.rs:568:5:571:5 | Wrapper |
|
||||
| main.rs:700:26:700:40 | x3.putTwo(...) | A | main.rs:639:36:639:50 | AssociatedParam |
|
||||
| main.rs:700:26:700:49 | ... .unwrap() | | main.rs:639:36:639:50 | AssociatedParam |
|
||||
| main.rs:700:36:700:36 | 2 | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:700:39:700:39 | 3 | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:702:20:702:20 | S | | main.rs:619:5:620:13 | S |
|
||||
|
||||
@@ -985,17 +985,18 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
|
||||
private module AccessConstraint {
|
||||
predicate relevantAccessConstraint(
|
||||
Access a, AccessPosition apos, TypePath path, Type constraint
|
||||
Access a, Declaration target, AccessPosition apos, TypePath path, Type constraint
|
||||
) {
|
||||
exists(DeclarationPosition dpos |
|
||||
accessDeclarationPositionMatch(apos, dpos) and
|
||||
typeParameterConstraintHasTypeParameter(a.getTarget(), dpos, path, _, constraint, _, _)
|
||||
target = a.getTarget() and
|
||||
typeParameterConstraintHasTypeParameter(target, dpos, path, _, constraint, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
private newtype TRelevantAccess =
|
||||
MkRelevantAccess(Access a, AccessPosition apos, TypePath path) {
|
||||
relevantAccessConstraint(a, apos, path, _)
|
||||
MkRelevantAccess(Access a, Declaration target, AccessPosition apos, TypePath path) {
|
||||
relevantAccessConstraint(a, target, apos, path, _)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1004,19 +1005,20 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
*/
|
||||
private class RelevantAccess extends MkRelevantAccess {
|
||||
Access a;
|
||||
Declaration target;
|
||||
AccessPosition apos;
|
||||
TypePath path;
|
||||
|
||||
RelevantAccess() { this = MkRelevantAccess(a, apos, path) }
|
||||
RelevantAccess() { this = MkRelevantAccess(a, target, apos, path) }
|
||||
|
||||
Type getTypeAt(TypePath suffix) {
|
||||
a.getInferredType(apos, path.appendInverse(suffix)) = result
|
||||
adjustedAccessType(a, apos, target, path.appendInverse(suffix), result)
|
||||
}
|
||||
|
||||
/** Holds if this relevant access has the type `type` and should satisfy `constraint`. */
|
||||
predicate hasTypeConstraint(Type type, Type constraint) {
|
||||
type = a.getInferredType(apos, path) and
|
||||
relevantAccessConstraint(a, apos, path, constraint)
|
||||
adjustedAccessType(a, apos, target, path, type) and
|
||||
relevantAccessConstraint(a, target, apos, path, constraint)
|
||||
}
|
||||
|
||||
string toString() {
|
||||
@@ -1076,7 +1078,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
TypeAbstraction abs, TypeMention sub, TypePath path, Type t
|
||||
) {
|
||||
exists(TypeMention constraintMention |
|
||||
at = MkRelevantAccess(a, apos, prefix) and
|
||||
at = MkRelevantAccess(a, _, apos, prefix) and
|
||||
hasConstraintMention(at, abs, sub, constraint, constraintMention) and
|
||||
conditionSatisfiesConstraintTypeAt(abs, sub, constraintMention, path, t)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user