@@ -772,45 +772,48 @@ private Type inferCallExprBaseType(AstNode n, TypePath path) {
772
772
n = a .getNodeAt ( apos ) and
773
773
result = CallExprBaseMatching:: inferAccessType ( a , apos , path0 )
774
774
|
775
- (
775
+ if
776
776
apos .isBorrowed ( true )
777
777
or
778
- // The desugaring of the unary `*e` is `*Deref::deref(&e)`. To handle the
779
- // deref expression after the call we must strip a `&` from the type at
780
- // the return position.
781
- apos .isReturn ( ) and a instanceof DerefExpr
782
- ) and
783
- path0 .isCons ( TRefTypeParameter ( ) , path )
784
- or
785
- apos .isBorrowed ( false ) and
786
- exists ( Type argType | argType = inferType ( n ) |
787
- if argType = TRefType ( )
778
+ // The desugaring of the unary `*e` is `*Deref::deref(&e)` and the
779
+ // desugaring of `a[b]` is `*Index::index(&a, b)`. To handle the deref
780
+ // expression after the call we must strip a `&` from the type at the
781
+ // return position.
782
+ apos .isReturn ( ) and
783
+ ( a instanceof DerefExpr or a instanceof IndexExpr )
784
+ then path0 .isCons ( TRefTypeParameter ( ) , path )
785
+ else
786
+ if apos .isBorrowed ( false )
788
787
then
789
- path = path0 and
790
- path0 .isCons ( TRefTypeParameter ( ) , _)
791
- or
792
- // adjust for implicit deref
793
- not path0 .isCons ( TRefTypeParameter ( ) , _) and
794
- not ( path0 .isEmpty ( ) and result = TRefType ( ) ) and
795
- path = TypePath:: cons ( TRefTypeParameter ( ) , path0 )
796
- else (
797
- not (
798
- argType .( StructType ) .asItemNode ( ) instanceof StringStruct and
799
- result .( StructType ) .asItemNode ( ) instanceof Builtins:: Str
800
- ) and
801
- (
802
- not path0 .isCons ( TRefTypeParameter ( ) , _) and
803
- not ( path0 .isEmpty ( ) and result = TRefType ( ) ) and
804
- path = path0
805
- or
806
- // adjust for implicit borrow
807
- path0 .isCons ( TRefTypeParameter ( ) , path )
788
+ exists ( Type argType | argType = inferType ( n ) |
789
+ if argType = TRefType ( )
790
+ then
791
+ path = path0 and
792
+ path0 .isCons ( TRefTypeParameter ( ) , _)
793
+ or
794
+ // adjust for implicit deref
795
+ not path0 .isCons ( TRefTypeParameter ( ) , _) and
796
+ not ( path0 .isEmpty ( ) and result = TRefType ( ) ) and
797
+ path = TypePath:: cons ( TRefTypeParameter ( ) , path0 )
798
+ else (
799
+ not (
800
+ argType .( StructType ) .asItemNode ( ) instanceof StringStruct and
801
+ result .( StructType ) .asItemNode ( ) instanceof Builtins:: Str
802
+ ) and
803
+ (
804
+ not path0 .isCons ( TRefTypeParameter ( ) , _) and
805
+ not ( path0 .isEmpty ( ) and result = TRefType ( ) ) and
806
+ path = path0
807
+ or
808
+ // adjust for implicit borrow
809
+ path0 .isCons ( TRefTypeParameter ( ) , path )
810
+ )
811
+ )
808
812
)
813
+ else (
814
+ not apos .isBorrowed ( _) and
815
+ path = path0
809
816
)
810
- )
811
- or
812
- not apos .isBorrowed ( _) and
813
- path = path0
814
817
)
815
818
}
816
819
@@ -1116,8 +1119,8 @@ private class Vec extends Struct {
1116
1119
*/
1117
1120
pragma [ nomagic]
1118
1121
private Type inferIndexExprType ( IndexExpr ie , TypePath path ) {
1119
- // TODO: Should be implemented as method resolution, using the special
1120
- // `std::ops:: Index` trait .
1122
+ // TODO: Method resolution to the `std::ops::Index` trait can handle the
1123
+ // `Index` instances for slices and arrays .
1121
1124
exists ( TypePath exprPath , Builtins:: BuiltinType t |
1122
1125
TStruct ( t ) = inferType ( ie .getIndex ( ) ) and
1123
1126
(
@@ -1129,8 +1132,6 @@ private Type inferIndexExprType(IndexExpr ie, TypePath path) {
1129
1132
) and
1130
1133
result = inferType ( ie .getBase ( ) , exprPath )
1131
1134
|
1132
- exprPath .isCons ( any ( Vec v ) .getElementTypeParameter ( ) , path )
1133
- or
1134
1135
exprPath .isCons ( any ( ArrayTypeParameter tp ) , path )
1135
1136
or
1136
1137
exists ( TypePath path0 |
@@ -1601,8 +1602,8 @@ private module Debug {
1601
1602
private Locatable getRelevantLocatable ( ) {
1602
1603
exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
1603
1604
result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
1604
- filepath .matches ( "%/sqlx .rs" ) and
1605
- startline = [ 56 .. 60 ]
1605
+ filepath .matches ( "%/main .rs" ) and
1606
+ startline = [ 1854 .. 1880 ]
1606
1607
)
1607
1608
}
1608
1609
0 commit comments