@@ -257,6 +257,10 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
257257 )
258258 )
259259 or
260+ n1 = n2 .( RefExpr ) .getExpr ( ) and
261+ prefix1 .isEmpty ( ) and
262+ prefix2 = TypePath:: singleton ( TRefTypeParameter ( ) )
263+ or
260264 n1 = n2 .( DerefExpr ) .getExpr ( ) and
261265 prefix1 = TypePath:: singleton ( TRefTypeParameter ( ) ) and
262266 prefix2 .isEmpty ( )
@@ -973,43 +977,9 @@ private Type inferFieldExprType(AstNode n, TypePath path) {
973977 )
974978}
975979
976- /**
977- * Gets the type of `n` at `path`, where `n` is either a reference expression
978- * `& x` or an expression `x` inside a reference expression `& x`.
979- */
980+ /** Gets the root type of the reference expression `re`. */
980981pragma [ nomagic]
981- private Type inferRefExprType ( Expr e , TypePath path ) {
982- exists ( RefExpr re |
983- e = re and
984- path .isEmpty ( ) and
985- result = TRefType ( )
986- or
987- e = re and
988- exists ( TypePath exprPath | result = inferType ( re .getExpr ( ) , exprPath ) |
989- if exprPath .isCons ( TRefTypeParameter ( ) , _)
990- then
991- // `&x` simply means `x` when `x` already has reference type
992- path = exprPath
993- else (
994- path = TypePath:: cons ( TRefTypeParameter ( ) , exprPath ) and
995- not ( exprPath .isEmpty ( ) and result = TRefType ( ) )
996- )
997- )
998- or
999- e = re .getExpr ( ) and
1000- exists ( TypePath exprPath , TypePath refPath , Type exprType |
1001- result = inferType ( re , exprPath ) and
1002- exprPath .isCons ( TRefTypeParameter ( ) , refPath ) and
1003- exprType = inferType ( e )
1004- |
1005- if exprType = TRefType ( )
1006- then
1007- // `&x` simply means `x` when `x` already has reference type
1008- path = exprPath
1009- else path = refPath
1010- )
1011- )
1012- }
982+ private Type inferRefExprType ( RefExpr re ) { exists ( re ) and result = TRefType ( ) }
1013983
1014984pragma [ nomagic]
1015985private Type inferTryExprType ( TryExpr te , TypePath path ) {
@@ -1505,7 +1475,8 @@ private module Cached {
15051475 or
15061476 result = inferFieldExprType ( n , path )
15071477 or
1508- result = inferRefExprType ( n , path )
1478+ result = inferRefExprType ( n ) and
1479+ path .isEmpty ( )
15091480 or
15101481 result = inferTryExprType ( n , path )
15111482 or
0 commit comments