@@ -713,12 +713,34 @@ abstract class ImplOrTraitItemNode extends ItemNode {
713713 predicate hasAssocItem ( string name ) { name = this .getAnAssocItem ( ) .getName ( ) }
714714}
715715
716+ private TypeItemNode resolveBuiltin ( TypeRepr tr ) {
717+ tr instanceof SliceTypeRepr and
718+ result instanceof Builtins:: SliceType
719+ or
720+ tr instanceof ArrayTypeRepr and
721+ result instanceof Builtins:: ArrayType
722+ or
723+ tr instanceof RefTypeRepr and
724+ result instanceof Builtins:: RefType
725+ or
726+ tr instanceof PtrTypeRepr and
727+ result instanceof Builtins:: PtrType
728+ or
729+ result .( Builtins:: TupleType ) .getArity ( ) = tr .( TupleTypeRepr ) .getNumberOfFields ( )
730+ }
731+
716732final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
717733 Path getSelfPath ( ) { result = super .getSelfTy ( ) .( PathTypeRepr ) .getPath ( ) }
718734
719735 Path getTraitPath ( ) { result = super .getTrait ( ) .( PathTypeRepr ) .getPath ( ) }
720736
721- TypeItemNode resolveSelfTy ( ) { result = resolvePath ( this .getSelfPath ( ) ) }
737+ TypeItemNode resolveSelfTyBuiltin ( ) { result = resolveBuiltin ( this .( Impl ) .getSelfTy ( ) ) }
738+
739+ TypeItemNode resolveSelfTy ( ) {
740+ result = resolvePath ( this .getSelfPath ( ) )
741+ or
742+ result = this .resolveSelfTyBuiltin ( )
743+ }
722744
723745 TraitItemNode resolveTraitTy ( ) { result = resolvePath ( this .getTraitPath ( ) ) }
724746
@@ -893,7 +915,11 @@ private class ModuleItemNode extends ModuleLikeNode instanceof Module {
893915}
894916
895917private class ImplItemNodeImpl extends ImplItemNode {
896- TypeItemNode resolveSelfTyCand ( ) { result = resolvePathCand ( this .getSelfPath ( ) ) }
918+ TypeItemNode resolveSelfTyCand ( ) {
919+ result = resolvePathCand ( this .getSelfPath ( ) )
920+ or
921+ result = this .resolveSelfTyBuiltin ( )
922+ }
897923
898924 TraitItemNode resolveTraitTyCand ( ) { result = resolvePathCand ( this .getTraitPath ( ) ) }
899925}
@@ -1764,6 +1790,10 @@ private ItemNode resolvePathCand0(RelevantPath path, Namespace ns) {
17641790 or
17651791 result = resolveUseTreeListItem ( _, _, path , _) and
17661792 ns = result .getNamespace ( )
1793+ or
1794+ result = resolveBuiltin ( path .getSegment ( ) .getTypeRepr ( ) ) and
1795+ not path .getSegment ( ) .hasTraitTypeRepr ( ) and
1796+ ns .isType ( )
17671797}
17681798
17691799pragma [ nomagic]
@@ -2141,7 +2171,9 @@ pragma[nomagic]
21412171private predicate builtin ( string name , ItemNode i ) {
21422172 exists ( BuiltinSourceFile builtins |
21432173 builtins .getFile ( ) .getBaseName ( ) = "types.rs" and
2144- i = builtins .getASuccessor ( name )
2174+ i = builtins .getASuccessor ( name ) and
2175+ not name = [ "Array" , "Slice" , "Ref" , "Ptr" ] and
2176+ not name .matches ( "Tuple%" )
21452177 )
21462178}
21472179
0 commit comments