mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Rust: Implement TypeMention for paths that access associated types on concrete types
This commit is contained in:
@@ -75,7 +75,7 @@ abstract class Type extends TType {
|
||||
abstract TypeParameter getPositionalTypeParameter(int i);
|
||||
|
||||
/** Gets the default type for the `i`th type parameter, if any. */
|
||||
TypeMention getTypeParameterDefault(int i) { none() }
|
||||
TypeRepr getTypeParameterDefault(int i) { none() }
|
||||
|
||||
/**
|
||||
* Gets a type parameter of this type.
|
||||
@@ -129,7 +129,7 @@ class DataType extends Type, TDataType {
|
||||
result = TTypeParamTypeParameter(typeItem.getGenericParamList().getTypeParam(i))
|
||||
}
|
||||
|
||||
override TypeMention getTypeParameterDefault(int i) {
|
||||
override TypeRepr getTypeParameterDefault(int i) {
|
||||
result = typeItem.getGenericParamList().getTypeParam(i).getDefaultType()
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class TraitType extends Type, TTrait {
|
||||
result.(SelfTypeParameter).getTrait() = trait
|
||||
}
|
||||
|
||||
override TypeMention getTypeParameterDefault(int i) {
|
||||
override TypeRepr getTypeParameterDefault(int i) {
|
||||
result = trait.getGenericParamList().getTypeParam(i).getDefaultType()
|
||||
}
|
||||
|
||||
|
||||
@@ -134,8 +134,8 @@ class TypePath = M1::TypePath;
|
||||
|
||||
module TypePath = M1::TypePath;
|
||||
|
||||
private module Input2 implements InputSig2<TypeMention> {
|
||||
TypeMention getABaseTypeMention(Type t) { none() }
|
||||
private module Input2 implements InputSig2<PreTypeMention> {
|
||||
PreTypeMention getABaseTypeMention(Type t) { none() }
|
||||
|
||||
Type getATypeParameterConstraint(TypeParameter tp, TypePath path) {
|
||||
exists(TypeMention tm | result = tm.getTypeAt(path) |
|
||||
@@ -158,7 +158,7 @@ private module Input2 implements InputSig2<TypeMention> {
|
||||
* inference module for more information.
|
||||
*/
|
||||
predicate conditionSatisfiesConstraint(
|
||||
TypeAbstraction abs, TypeMention condition, TypeMention constraint, boolean transitive
|
||||
TypeAbstraction abs, PreTypeMention condition, PreTypeMention constraint, boolean transitive
|
||||
) {
|
||||
// `impl` blocks implementing traits
|
||||
transitive = false and
|
||||
@@ -208,7 +208,7 @@ private module Input2 implements InputSig2<TypeMention> {
|
||||
}
|
||||
}
|
||||
|
||||
private module M2 = Make2<TypeMention, Input2>;
|
||||
private module M2 = Make2<PreTypeMention, Input2>;
|
||||
|
||||
import M2
|
||||
|
||||
@@ -1960,7 +1960,7 @@ private module MethodResolution {
|
||||
pragma[nomagic]
|
||||
predicate hasTypeQualifiedCandidate(ImplItemNode impl) {
|
||||
exists(getCallExprTypeQualifier(this, _)) and
|
||||
CallExprImpl::getResolvedFunction(this) = impl.getASuccessor(_)
|
||||
CallExprImpl::getResolvedFunction(this) = impl.getADescendant()
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
|
||||
@@ -10,7 +10,11 @@ private import TypeInference::Consistency as Consistency
|
||||
import TypeInference::Consistency
|
||||
|
||||
query predicate illFormedTypeMention(TypeMention tm) {
|
||||
Consistency::illFormedTypeMention(tm) and
|
||||
// NOTE: We do not use `illFormedTypeMention` from the shared library as it is
|
||||
// instantiated with `PreTypeMention` and we are interested in inconsistencies
|
||||
// for `TypeMention`.
|
||||
not exists(tm.getTypeAt(TypePath::nil())) and
|
||||
exists(tm.getLocation()) and
|
||||
// avoid overlap with `PathTypeMention`
|
||||
not tm instanceof PathTypeReprMention and
|
||||
// known limitation for type mentions that would mention an escaping type parameter
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user