Merge pull request #21918 from hvitved/rust/expose-resolution

Rust: Add `Impl::getSelf()` and `Impl::getTrait()`
This commit is contained in:
Tom Hvitved
2026-06-03 20:18:05 +02:00
committed by GitHub
29 changed files with 14329 additions and 56 deletions

View File

@@ -45,6 +45,7 @@ fn property_name(type_name: &str, field_name: &str) -> String {
(_, "ty") => "type_repr",
("Function", "body") => "function_body",
("ClosureExpr", "body") => "closure_body",
("Impl", "trait_") => "trait_ty",
_ if field_name.contains("record") => &field_name.replacen("record", "struct", 1),
_ => field_name,
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
description: Renamed `impl_trait_ties` to `impl_traits`
compatibility: full
impl_traits.rel: reorder impl_trait_ties(@impl id, @type_repr trait_ty) id trait_ty
impl_trait_ties.rel: delete

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs ea9c28694da3d0e90d09fc7d31824e35817c34720ea91e7c8bf8e7e74ffe4ee8 ea9c28694da3d0e90d09fc7d31824e35817c34720ea91e7c8bf8e7e74ffe4ee8
top.rs 2e8e3b4e42b172708bb3a6ec3a92a6577c576887019603ca3d0f045bbdbfdbac 2e8e3b4e42b172708bb3a6ec3a92a6577c576887019603ca3d0f045bbdbfdbac

View File

@@ -9451,7 +9451,7 @@ pub struct Impl {
pub is_default: bool,
pub is_unsafe: bool,
pub self_ty: Option<trap::Label<TypeRepr>>,
pub trait_: Option<trap::Label<TypeRepr>>,
pub trait_ty: Option<trap::Label<TypeRepr>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
}
@@ -9484,8 +9484,8 @@ impl trap::TrapEntry for Impl {
if let Some(v) = self.self_ty {
out.add_tuple("impl_self_ties", vec![id.into(), v.into()]);
}
if let Some(v) = self.trait_ {
out.add_tuple("impl_traits", vec![id.into(), v.into()]);
if let Some(v) = self.trait_ty {
out.add_tuple("impl_trait_ties", vec![id.into(), v.into()]);
}
if let Some(v) = self.visibility {
out.add_tuple("impl_visibilities", vec![id.into(), v.into()]);

View File

@@ -1229,7 +1229,7 @@ impl Translator<'_> {
let is_default = node.default_token().is_some();
let is_unsafe = node.unsafe_token().is_some();
let self_ty = node.self_ty().and_then(|x| self.emit_type(&x));
let trait_ = node.trait_().and_then(|x| self.emit_type(&x));
let trait_ty = node.trait_().and_then(|x| self.emit_type(&x));
let visibility = node.visibility().and_then(|x| self.emit_visibility(&x));
let where_clause = node.where_clause().and_then(|x| self.emit_where_clause(&x));
let label = self.trap.emit(generated::Impl {
@@ -1241,7 +1241,7 @@ impl Translator<'_> {
is_default,
is_unsafe,
self_ty,
trait_,
trait_ty,
visibility,
where_clause,
});

View File

@@ -69,7 +69,7 @@ lib/codeql/rust/elements/GenericParam.qll 87adf96aac385f2a182008a7b90aad46cf46d7
lib/codeql/rust/elements/GenericParamList.qll 25fcaa68bc7798d75974d12607fae0afc7f84d43091b2d0c66a504095ef05667 3b71115c6af0b8e7f84d8c2d5ac9f23595ad2b22dbd19a9ea71906ca99340878
lib/codeql/rust/elements/IdentPat.qll ad5f202316d4eeee3ca81ea445728f4ad7eb6bb7d81232bc958c22a93d064bf2 7ce2772e391e593d8fd23b2b44e26d0d7e780327ec973fcc9dce52a75fda0e36
lib/codeql/rust/elements/IfExpr.qll f62153e8098b3eb08b569d4e25c750bc686665651579db4bc9e11dcef8e75d63 55006a55d612f189e73caa02f7b4deda388c692f0a801cdda9f833f2afdca778
lib/codeql/rust/elements/Impl.qll ce5225fd97b184db7235bcf2561cf23c679de2fc96fecaeb8cbcf7935dd48fbd 3fe755118c3d0b1eb626f359da362ad75dbdcd1e09f09825b10038fb41ddb35c
lib/codeql/rust/elements/Impl.qll 0d69c9ace5dac87ed095cfd5d4a8baf7e17ebce1132f3a7d6fa2bf4325deff8d d908fc5da7d3a59fb0a286a6ce581bdabdb48c4ac6ecd070455c271c2352208c
lib/codeql/rust/elements/ImplTraitTypeRepr.qll 1d559b16c659f447a1bde94cc656718f20f133f767060437b755ac81eea9f852 de69c596701f0af4db28c5802d092a39c88a90bf42ea85aea25eecb79417e454
lib/codeql/rust/elements/IndexExpr.qll 0e2e9f018d06ae72be0fc4ddbc019a9aacd8a06f42b4c4431760bd149e7f2290 2bcfd557abd53a48e48de7915c4f2089107c62dfb3e732a904848248dfd3727b
lib/codeql/rust/elements/InferTypeRepr.qll 1b8bdcb574a7b6e7dd49f4cfb96655a6ccc355744b424b8c2593fe8218090d53 c20a2a5b0346dc277721deb450e732a47812c8e872ffb60aaba351b1708e9477
@@ -510,7 +510,7 @@ lib/codeql/rust/elements/internal/generated/GenericParam.qll 85ac027a42b3300febc
lib/codeql/rust/elements/internal/generated/GenericParamList.qll b18fa5fd435d94857c9863bbcc40571af0b1efba1b31ba9159c95568f5c58fce 6e70f1e9a1823d28d60e0e753ac8fbbe8deb10c94365f893b0c8f8ea4061b460
lib/codeql/rust/elements/internal/generated/IdentPat.qll 1fe5061759848fdc9588b27606efb1187ce9c13d12ad0a2a19666d250dd62db3 87dbc8b88c31079076a896b48e0c483a600d7d11c1c4bf266581bdfc9c93ae98
lib/codeql/rust/elements/internal/generated/IfExpr.qll 413dd7a20c6b98c0d2ad2e5b50981c14bf96c1a719ace3e341d78926219a5af7 c9a2d44e3baa6a265a29a683ca3c1683352457987c92f599c5771b4f3b4bafff
lib/codeql/rust/elements/internal/generated/Impl.qll 5afadb7f80c5ffbd5cd3816c6788ccb605fe4cb2d8c8507ec3f212913eac0ab5 761b72a5f35e2e766de6aa87d83b065f49b64f05b91ae47d0afbb20bb61c1003
lib/codeql/rust/elements/internal/generated/Impl.qll bdc3da08b23ab098e92927a57c2e99eeb78ea8561cf11accc51db3033492b500 4b45be6b0c51f03999619705104574d78c262ed2497921f2ca8696844b17addc
lib/codeql/rust/elements/internal/generated/ImplTraitTypeRepr.qll e376a2e34ba51df403d42b02afe25140543e3e53aaf04b9ea118eb575acb4644 dc3a7e3eac758423c90a9803cc40dfdf53818bd62ee894982cd636f6b1596dfc
lib/codeql/rust/elements/internal/generated/IndexExpr.qll cf951fc40f6690e966b4dc78fa9a6221aa5c6cade44759dcb52254f799292d11 1572e71918cc4e0b7e028331b6d98c9db23100a3646cd3874d1915e06ab6211d
lib/codeql/rust/elements/internal/generated/InferTypeRepr.qll 4f101c1cb1278e919f9195cac4aa0c768e304c1881394b500874e7627e62d6c4 dca3f85d0a78ecc8bf030b4324f0d219ffff60784a2ecf565a4257e888dea0ff
@@ -556,7 +556,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e
lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb
lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa
lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126
lib/codeql/rust/elements/internal/generated/ParentChild.qll b0e3c13b2ca75faaf0d92b2ca3d70cac7b78b3729aaccf635063cc5836c163af a340e8f34a6d7425f38845e789b4aeb83aec90c11429a68ad6632a5aa132fa57
lib/codeql/rust/elements/internal/generated/ParentChild.qll dc5e9e16e0d43cf25ebdce03b84aa3bf0f52fe0c61de4db4a9887c961290b37e b26f0f2c27b664d0fe53aba35955df31a58adad0963a951039b6c6bbd34f83ea
lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd
@@ -571,7 +571,7 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 8d0ea4f6c7f8203340bf
lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f
lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9
lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9
lib/codeql/rust/elements/internal/generated/Raw.qll 6e32bd7167d3eece2d22f893a92410129b1bd18e59533b1cf82f72f31465b43a bb25c56118df0e2755be2350cf307c19e6c4d85b2a39388c08f2cc1bad303692
lib/codeql/rust/elements/internal/generated/Raw.qll 6e38ac8ae1fbd7af0dd516f1c37e52e6ef1169103ad7dd998796ff8cd2dbac7a f4a7515e1757404b101ea3c8bb154d11d1babb138cb2afddf1618eab377d9625
lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66
lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05
lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 5b0663a6d234572fb3e467e276d019415caa95ef006438cc59b7af4e1783161e 0e27c8a8f0e323c0e4d6db01fca821bf07c0864d293cdf96fa891b10820c1e4b
@@ -691,7 +691,7 @@ test/extractor-tests/generated/GenericArgList/GenericArgList.ql 9bd6873e56a381a6
test/extractor-tests/generated/GenericParamList/GenericParamList.ql 206f270690f5c142777d43cf87b65d6dda5ec9f3953c17ee943fe3d0e7b7761c 38a6e0bbca916778f85b106609df6d5929baed006d55811ec0d71c75fe137e92
test/extractor-tests/generated/IdentPat/IdentPat.ql 23006eddf0ca1188e11ba5ee25ad62a83157b83e0b99119bf924c7f74fd8e70d 6e572f48f607f0ced309113304019ccc0a828f6ddd71e818369504dcf832a0b5
test/extractor-tests/generated/IfExpr/IfExpr.ql 540b21838ad3e1ed879b66c1903eb8517d280f99babcbf3c5307c278db42f003 a6f84a7588ce7587936f24375518a365c571210844b99cb614596e14dd5e4dfd
test/extractor-tests/generated/Impl/Impl.ql a36ea392729a6be3ee0cc0d8871b3682cf8f0c15fb657d4d35f2ca76eeef3a74 1fa345ca3b4c16c740b5684c7fdaf1116d52c2932287703b33143a08e4d7d38e
test/extractor-tests/generated/Impl/Impl.ql c96ec30d703aa607b7aad9f6eaca1b0069799cdefcc1481f4aa4f7378f477f7f 3528e1502b6f7b323d964630ecfb8255f683486b75300457e2a2d95aa36771f3
test/extractor-tests/generated/ImplTraitTypeRepr/ImplTraitTypeRepr.ql 311c6c1e18bd74fbcd367f940d2cf91777eaba6b3d6307149beb529216d086fb 16c7c81618d7f49da30b4f026dcacfb23ed130dbfcfa19b5cb44dc6e15101401
test/extractor-tests/generated/IndexExpr/IndexExpr.ql ecfca80175a78b633bf41684a0f8f5eebe0b8a23f8de9ff27142936687711263 27d4832911f7272376a199550d57d8488e75e0eeeeb7abbfb3b135350a30d277
test/extractor-tests/generated/InferTypeRepr/InferTypeRepr.ql 6ba01a9e229e7dfdb2878a0bdbeb6c0888c4a068984b820e7a48d4b84995daa2 7120cafd267e956dbb4af5e19d57237275d334ffe5ff0fb635d65d309381aa46

View File

@@ -13,7 +13,7 @@ import codeql.rust.elements.Visibility
import codeql.rust.elements.WhereClause
/**
* An `impl`` block.
* An `impl` block.
*
* For example:
* ```rust

View File

@@ -4,7 +4,11 @@
* INTERNAL: Do not use.
*/
private import rust
private import codeql.rust.elements.internal.generated.Impl
private import codeql.rust.internal.PathResolution as PathResolution
private import codeql.rust.internal.typeinference.Type
private import codeql.rust.internal.typeinference.TypeMention
/**
* INTERNAL: This module contains the customizable definition of `Impl` and should not
@@ -13,7 +17,7 @@ private import codeql.rust.elements.internal.generated.Impl
module Impl {
// the following QLdoc is generated: if you need to edit it, do it in the schema file
/**
* An `impl`` block.
* An `impl` block.
*
* For example:
* ```rust
@@ -26,9 +30,9 @@ module Impl {
override string toStringImpl() {
exists(string trait |
(
trait = this.getTrait().toAbbreviatedString() + " for "
trait = this.getTraitTy().toAbbreviatedString() + " for "
or
not this.hasTrait() and trait = ""
not this.hasTraitTy() and trait = ""
) and
result = "impl " + trait + this.getSelfTy().toAbbreviatedString() + " { ... }"
)
@@ -38,6 +42,40 @@ module Impl {
* Holds if this is an inherent `impl` block, that is, one that does not implement a trait.
*/
pragma[nomagic]
predicate isInherent() { not this.hasTrait() }
predicate isInherent() { not this.hasTraitTy() }
/**
* Gets the type being implemented.
*
* For example, in
*
* ```rust
* impl MyType { ... }
*
* impl MyTrait for MyType { ... }
* ```
*
* the type being implemented is in both cases `MyType`.
*/
TypeItem getSelf() {
result = this.getSelfTy().(TypeMention).getType().(DataType).getTypeItem()
}
/**
* Gets the trait being implemented, if any.
*
* For example, in
*
* ```rust
* impl MyType { ... }
*
* impl MyTrait for MyType { ... }
* ```
*
* the trait being implemented is in the second case `MyTrait`.
*/
Trait getTrait() {
result = PathResolution::resolvePath(this.getTraitTy().(PathTypeRepr).getPath())
}
}
}

View File

@@ -20,7 +20,7 @@ import codeql.rust.elements.WhereClause
*/
module Generated {
/**
* An `impl`` block.
* An `impl` block.
*
* For example:
* ```rust
@@ -109,16 +109,16 @@ module Generated {
final predicate hasSelfTy() { exists(this.getSelfTy()) }
/**
* Gets the trait of this impl, if it exists.
* Gets the trait ty of this impl, if it exists.
*/
TypeRepr getTrait() {
result = Synth::convertTypeReprFromRaw(Synth::convertImplToRaw(this).(Raw::Impl).getTrait())
TypeRepr getTraitTy() {
result = Synth::convertTypeReprFromRaw(Synth::convertImplToRaw(this).(Raw::Impl).getTraitTy())
}
/**
* Holds if `getTrait()` exists.
* Holds if `getTraitTy()` exists.
*/
final predicate hasTrait() { exists(this.getTrait()) }
final predicate hasTraitTy() { exists(this.getTraitTy()) }
/**
* Gets the visibility of this impl, if it exists.

View File

@@ -2328,7 +2328,7 @@ private module Impl {
private Element getImmediateChildOfImpl(Impl e, int index, string partialPredicateCall) {
exists(
int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList,
int nSelfTy, int nTrait, int nVisibility, int nWhereClause
int nSelfTy, int nTraitTy, int nVisibility, int nWhereClause
|
n = 0 and
nAttributeMacroExpansion = n + 1 and
@@ -2336,8 +2336,8 @@ private module Impl {
nAttr = nAssocItemList + e.getNumberOfAttrs() and
nGenericParamList = nAttr + 1 and
nSelfTy = nGenericParamList + 1 and
nTrait = nSelfTy + 1 and
nVisibility = nTrait + 1 and
nTraitTy = nSelfTy + 1 and
nVisibility = nTraitTy + 1 and
nWhereClause = nVisibility + 1 and
(
none()
@@ -2359,9 +2359,9 @@ private module Impl {
or
index = nGenericParamList and result = e.getSelfTy() and partialPredicateCall = "SelfTy()"
or
index = nSelfTy and result = e.getTrait() and partialPredicateCall = "Trait()"
index = nSelfTy and result = e.getTraitTy() and partialPredicateCall = "TraitTy()"
or
index = nTrait and result = e.getVisibility() and partialPredicateCall = "Visibility()"
index = nTraitTy and result = e.getVisibility() and partialPredicateCall = "Visibility()"
or
index = nVisibility and
result = e.getWhereClause() and

View File

@@ -6209,7 +6209,7 @@ module Raw {
/**
* INTERNAL: Do not use.
* An `impl`` block.
* An `impl` block.
*
* For example:
* ```rust
@@ -6262,9 +6262,9 @@ module Raw {
TypeRepr getSelfTy() { impl_self_ties(this, result) }
/**
* Gets the trait of this impl, if it exists.
* Gets the trait ty of this impl, if it exists.
*/
TypeRepr getTrait() { impl_traits(this, result) }
TypeRepr getTraitTy() { impl_trait_ties(this, result) }
/**
* Gets the visibility of this impl, if it exists.
@@ -6280,7 +6280,7 @@ module Raw {
private Element getImmediateChildOfImpl(Impl e, int index) {
exists(
int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList,
int nSelfTy, int nTrait, int nVisibility, int nWhereClause
int nSelfTy, int nTraitTy, int nVisibility, int nWhereClause
|
n = 0 and
nAttributeMacroExpansion = n + 1 and
@@ -6288,8 +6288,8 @@ module Raw {
nAttr = nAssocItemList + e.getNumberOfAttrs() and
nGenericParamList = nAttr + 1 and
nSelfTy = nGenericParamList + 1 and
nTrait = nSelfTy + 1 and
nVisibility = nTrait + 1 and
nTraitTy = nSelfTy + 1 and
nVisibility = nTraitTy + 1 and
nWhereClause = nVisibility + 1 and
(
none()
@@ -6304,9 +6304,9 @@ module Raw {
or
index = nGenericParamList and result = e.getSelfTy()
or
index = nSelfTy and result = e.getTrait()
index = nSelfTy and result = e.getTraitTy()
or
index = nTrait and result = e.getVisibility()
index = nTraitTy and result = e.getVisibility()
or
index = nVisibility and result = e.getWhereClause()
)

View File

@@ -838,7 +838,7 @@ private TypeItemNode resolveBuiltin(TypeRepr tr) {
final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
Path getSelfPath() { result = super.getSelfTy().(PathTypeRepr).getPath() }
Path getTraitPath() { result = super.getTrait().(PathTypeRepr).getPath() }
Path getTraitPath() { result = super.getTraitTy().(PathTypeRepr).getPath() }
TypeItemNode resolveSelfTyBuiltin() { result = resolveBuiltin(this.(Impl).getSelfTy()) }

View File

@@ -42,7 +42,7 @@ private predicate hasFirstNonTrivialTraitBound(TypeParamItemNode tp, Path traitB
*/
pragma[nomagic]
predicate isBlanketLike(ImplItemNode i, TypePath blanketSelfPath, TypeParam blanketTypeParam) {
i.(Impl).hasTrait() and
i.(Impl).hasTraitTy() and
(
blanketTypeParam = i.getBlanketImplementationTypeParam() and
blanketSelfPath.isEmpty()

View File

@@ -174,7 +174,7 @@ private module Input2Common {
exists(Impl impl |
abs = impl and
condition = impl.getSelfTy() and
constraint = impl.getTrait()
constraint = impl.getTraitTy()
)
or
transitive = true and
@@ -1542,7 +1542,7 @@ private module AssocFunctionResolution {
boolean hasReceiver
|
afc.hasSyntacticInfo(name, arity, typeQualifier, traitQualifier, hasReceiver) and
if not afc.hasATrait() and i.(Impl).hasTrait()
if not afc.hasATrait() and i.(Impl).hasTraitTy()
then callVisibleImplTraitCandidate(afc, i)
else any()
|
@@ -2532,7 +2532,7 @@ private module AssocFunctionResolution {
AssocFunctionCallCand afcc, TypeAbstraction abs, AssocFunctionType constraint
) {
potentialInstantiationOf0(afcc, abs, constraint) and
if abs.(Impl).hasTrait()
if abs.(Impl).hasTraitTy()
then
// inherent functions take precedence over trait functions, so only allow
// trait functions when there are no matching inherent functions
@@ -2584,7 +2584,7 @@ private module AssocFunctionResolution {
exists(AssocFunctionCall afc, FunctionPosition selfPos |
afcc = MkAssocFunctionCallCand(afc, selfPos, _, _) and
blanketLikeCandidate(afc, _, selfPos, abs, constraint, _, _) and
if abs.(Impl).hasTrait()
if abs.(Impl).hasTraitTy()
then
// inherent functions take precedence over trait functions, so only allow
// trait functions when there are no matching inherent functions

View File

@@ -2907,9 +2907,9 @@ impl_self_ties(
);
#keyset[id]
impl_traits(
impl_trait_ties(
int id: @impl ref,
int trait: @type_repr ref
int trait_ty: @type_repr ref
);
#keyset[id]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
description: Renamed `impl_traits` to `impl_trait_ties`
compatibility: full
impl_trait_ties.rel: reorder impl_traits(@impl id, @type_repr trait) id trait
impl_traits.rel: delete

View File

@@ -26,7 +26,7 @@ private newtype TCallable =
or
// If a method implements a public trait it is exposed through the trait.
// We overapproximate this by including all trait method implementations.
exists(R::Impl impl | impl.hasTrait() and impl.getAssocItemList().getAssocItem(_) = api)
exists(R::Impl impl | impl.hasTraitTy() and impl.getAssocItemList().getAssocItem(_) = api)
)
}

View File

@@ -11,7 +11,7 @@ query predicate canonicalPath(Addressable a, string path) {
a =
any(ImplItemNode i |
i.resolveSelfTy() instanceof Str and
not i.(Impl).hasTrait()
not i.(Impl).hasTraitTy()
).getAnAssocItem() and
a.(Function).getName().getText() = "trim"
) and

View File

@@ -52,7 +52,7 @@ GenericArgList/gen_generic_arg_list.rs cfb072d3b48f9dd568c23d4dfefba28766628678f
GenericParamList/gen_generic_param_list.rs 3a1981a7c4731329ad6da0d887f09be04f31342d94f44711ac0ac455930f773a 3a1981a7c4731329ad6da0d887f09be04f31342d94f44711ac0ac455930f773a
IdentPat/gen_ident_pat.rs 87f9201ca47683ff6f12a0c844c062fdedb6d86546794522d358b117ba0fe477 87f9201ca47683ff6f12a0c844c062fdedb6d86546794522d358b117ba0fe477
IfExpr/gen_if_expr.rs 2df66735394ebb20db29d3fbf2721ad4812afbe8d4614d03f26265c1f481f1e8 2df66735394ebb20db29d3fbf2721ad4812afbe8d4614d03f26265c1f481f1e8
Impl/gen_impl.rs cfab33eb5e98b425b1d88be5f09f742be6c4f8d402e1becd4421aabb0431aadd cfab33eb5e98b425b1d88be5f09f742be6c4f8d402e1becd4421aabb0431aadd
Impl/gen_impl.rs a3f91dbcbb89f660e1c67eb6211def495cced5ab069515c6151e442365f64899 a3f91dbcbb89f660e1c67eb6211def495cced5ab069515c6151e442365f64899
ImplTraitTypeRepr/gen_impl_trait_type_repr.rs ebfa4d350ae5759bf7df6adf790d2d892c7a0d708f3340ccf3e12a681cb78f00 ebfa4d350ae5759bf7df6adf790d2d892c7a0d708f3340ccf3e12a681cb78f00
IndexExpr/gen_index_expr.rs 22d7f81ba43dc63f1f49e21a2c25ce25a1b8f6e8e95e1a66f518f010a4d73c61 22d7f81ba43dc63f1f49e21a2c25ce25a1b8f6e8e95e1a66f518f010a4d73c61
InferTypeRepr/gen_infer_type_repr.rs cd50eaeffdf16e0e896b14b665590251a4d383c123502ed667d8b1f75000f559 cd50eaeffdf16e0e896b14b665590251a4d383c123502ed667d8b1f75000f559

View File

@@ -7,7 +7,7 @@ getAttr
getGenericParamList
getSelfTy
| gen_impl.rs:4:5:9:5 | impl MyTrait for MyType { ... } | gen_impl.rs:7:22:7:27 | MyType |
getTrait
getTraitTy
| gen_impl.rs:4:5:9:5 | impl MyTrait for MyType { ... } | gen_impl.rs:7:10:7:16 | MyTrait |
getVisibility
getWhereClause

View File

@@ -38,8 +38,8 @@ query predicate getSelfTy(Impl x, TypeRepr getSelfTy) {
toBeTested(x) and not x.isUnknown() and getSelfTy = x.getSelfTy()
}
query predicate getTrait(Impl x, TypeRepr getTrait) {
toBeTested(x) and not x.isUnknown() and getTrait = x.getTrait()
query predicate getTraitTy(Impl x, TypeRepr getTraitTy) {
toBeTested(x) and not x.isUnknown() and getTraitTy = x.getTraitTy()
}
query predicate getVisibility(Impl x, Visibility getVisibility) {

View File

@@ -1,7 +1,7 @@
// generated by codegen, do not edit
fn test_impl() -> () {
// An `impl`` block.
// An `impl` block.
//
// For example:
impl MyTrait for MyType {

View File

@@ -797,7 +797,7 @@ macro_expansion.rs:
# 84| getSegment(): [PathSegment] MyDerive::<...>
# 83| getGenericArgList(): [GenericArgList] <...>
# 84| getIdentifier(): [NameRef] MyDerive
# 83| getTrait(): [PathTypeRepr] ...::Debug
# 83| getTraitTy(): [PathTypeRepr] ...::Debug
# 83| getPath(): [Path] ...::Debug
# 83| getQualifier(): [Path] ...::fmt
# 83| getQualifier(): [Path] $crate
@@ -901,7 +901,7 @@ macro_expansion.rs:
# 89| getSegment(): [PathSegment] MyDeriveEnum::<...>
# 88| getGenericArgList(): [GenericArgList] <...>
# 89| getIdentifier(): [NameRef] MyDeriveEnum
# 88| getTrait(): [PathTypeRepr] ...::PartialEq
# 88| getTraitTy(): [PathTypeRepr] ...::PartialEq
# 88| getPath(): [Path] ...::PartialEq
# 88| getQualifier(): [Path] ...::cmp
# 88| getQualifier(): [Path] $crate
@@ -921,7 +921,7 @@ macro_expansion.rs:
# 89| getSegment(): [PathSegment] MyDeriveEnum::<...>
# 88| getGenericArgList(): [GenericArgList] <...>
# 89| getIdentifier(): [NameRef] MyDeriveEnum
# 88| getTrait(): [PathTypeRepr] ...::Eq
# 88| getTraitTy(): [PathTypeRepr] ...::Eq
# 88| getPath(): [Path] ...::Eq
# 88| getQualifier(): [Path] ...::cmp
# 88| getQualifier(): [Path] $crate
@@ -984,7 +984,7 @@ macro_expansion.rs:
# 99| getPath(): [Path] MyDeriveUnion
# 99| getSegment(): [PathSegment] MyDeriveUnion
# 99| getIdentifier(): [NameRef] MyDeriveUnion
# 98| getTrait(): [PathTypeRepr] MyTrait
# 98| getTraitTy(): [PathTypeRepr] MyTrait
# 98| getPath(): [Path] MyTrait
# 98| getSegment(): [PathSegment] MyTrait
# 98| getIdentifier(): [NameRef] MyTrait

View File

@@ -1269,7 +1269,7 @@ class _:
@annotate(Impl)
class _:
"""
An `impl`` block.
An `impl` block.
For example:
```rust

2
rust/schema/ast.py generated
View File

@@ -312,7 +312,7 @@ class Impl(Item, ):
is_default: predicate
is_unsafe: predicate
self_ty: optional["TypeRepr"] | child
trait_: optional["TypeRepr"] | child
trait_ty: optional["TypeRepr"] | child
visibility: optional["Visibility"] | child
where_clause: optional["WhereClause"] | child