diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll b/rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll index 326a4cf09ef..d96fd892c73 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/FunctionOverloading.qll @@ -164,13 +164,13 @@ private predicate hasEquivalentPositionalSibling( | forall(TypePath path0, Type t | t = getAssocFunctionNonTypeParameterTypeAt(impl, f, pos, path0) and - path = path0.getAPrefixOrSelf() + path = path0.getAPrefix() | t = getAssocFunctionNonTypeParameterTypeAt(sibling, f1, pos, path0) ) and forall(TypePath path0, Type t | t = getAssocFunctionNonTypeParameterTypeAt(sibling, f1, pos, path0) and - path = path0.getAPrefixOrSelf() + path = path0.getAPrefix() | t = getAssocFunctionNonTypeParameterTypeAt(impl, f, pos, path0) ) diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll b/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll index 3e9c823c570..e7e4bbb717c 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/TypeInference.qll @@ -1185,7 +1185,7 @@ private module ContextTyping { private Type inferCallTypeFromContextCand(AstNode n, TypePath prefix, TypePath path) { result = inferCallType(n, false, path) and hasUnknownType(n) and - prefix = path.getAPrefixOrSelf() + prefix = path.getAPrefix() } pragma[nomagic] @@ -2704,10 +2704,9 @@ private module NonMethodResolution { // For inherent implementations of generic types, we also need to check the type being // implemented. We arbitrarily choose the first type parameter of the type being implemented // to represent this case. - f = impl.getASuccessor(_) and + f = impl.getAnAssocItem() and not impl.(Impl).hasTrait() and tp = TTypeParamTypeParameter(impl.resolveSelfTy().getTypeParam(0)) and - not f.hasSelfParam() and pos.isSelf() } @@ -2813,8 +2812,7 @@ private module NonMethodResolution { pragma[nomagic] NonMethodFunction resolveCallTargetNonBlanketCand(ImplItemNode i) { not this.hasTrait() and - result = this.getPathResolutionResolved() and - result = i.getASuccessor(_) and + result = this.getPathResolutionResolved(i) and not exists(this.resolveCallTargetViaPathResolution()) and functionResolutionDependsOnArgument(i, result, _, _) } diff --git a/rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll b/rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll index a1177e55cc9..4865dd82ef8 100644 --- a/rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll +++ b/rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll @@ -206,6 +206,7 @@ private module MkTypeMention bool { true } @@ -31,7 +31,7 @@ mod method_call_trait_path_disambig { } } impl SecondTrait for S { - // S::method2 + // S_as_SecondTrait::method2 fn method2(&self) -> i64 { 1 } @@ -56,14 +56,14 @@ mod method_call_trait_path_disambig { let _b1 = FirstTrait::method(&s); // $ type=_b1:bool target=FirstTrait::method let _b2 = ::method(&s); // $ type=_b2:bool target=FirstTrait::method let _b3 = ::method(&Default::default()); // $ type=_b3:bool target=FirstTrait::method target=default - let _b4 = ::method2(&s); // $ type=_b4:bool target=S::method2 - let _b5 = ::method2(&Default::default()); // $ type=_b5:bool target=S::method2 target=default + let _b4 = ::method2(&s); // $ type=_b4:bool target=S_as_FirstTrait::method2 + let _b5 = ::method2(&Default::default()); // $ type=_b5:bool target=S_as_FirstTrait::method2 target=default let _n1 = SecondTrait::method(&s); // $ type=_n1:i64 target=SecondTrait::method let _n2 = ::method(&s); // $ type=_n2:i64 target=SecondTrait::method let _n3 = ::method(&Default::default()); // $ type=_n3:i64 target=SecondTrait::method target=default - let _n4 = ::method2(&s); // $ type=_n4:i64 target=S::method2 - let _n5 = ::method2(&Default::default()); // $ type=_n5:i64 target=S::method2 target=default + let _n4 = ::method2(&s); // $ type=_n4:i64 target=S_as_SecondTrait::method2 + let _n5 = ::method2(&Default::default()); // $ type=_n5:i64 target=S_as_SecondTrait::method2 target=default ::function(); // $ target=S::function ::function(); // $ target=S2::function diff --git a/shared/util/codeql/util/UnboundList.qll b/shared/util/codeql/util/UnboundList.qll index 5cd2362c14e..5cfe06d02ee 100644 --- a/shared/util/codeql/util/UnboundList.qll +++ b/shared/util/codeql/util/UnboundList.qll @@ -140,7 +140,7 @@ module Make Input> { * Only holds when this list is non-empty, and only returns proper prefixes. */ bindingset[this] - UnboundList getPrefix(int i) { + UnboundList getProperPrefix(int i) { exists(string regexp, int occurrenceOffset | regexp = "[0-9]+\\." | exists(this.regexpFind(regexp, i, occurrenceOffset)) and result = this.prefix(occurrenceOffset) @@ -153,13 +153,13 @@ module Make Input> { * Only holds when this list is non-empty, and only returns proper prefixes. */ bindingset[this] - UnboundList getAPrefix() { result = this.getPrefix(_) } + UnboundList getAProperPrefix() { result = this.getProperPrefix(_) } /** * Gets a prefix of this list, including the list itself. */ bindingset[this] - UnboundList getAPrefixOrSelf() { result = [this, this.getAPrefix()] } + UnboundList getAPrefix() { result = [this, this.getAProperPrefix()] } } /** Provides predicates for constructing `UnboundList`s. */