@@ -9,79 +9,80 @@ private import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl
99
1010/**
1111 * Holds if the operator `op` with arity `arity` is overloaded to a trait with
12- * the canonical path `path` and the method name `method`.
12+ * the canonical path `path` and the method name `method`, and if it borrows its
13+ * first `borrows` arguments.
1314 */
14- private predicate isOverloaded ( string op , int arity , string path , string method ) {
15+ private predicate isOverloaded ( string op , int arity , string path , string method , int borrows ) {
1516 arity = 1 and
1617 (
1718 // Negation
18- op = "-" and path = "core::ops::arith::Neg" and method = "neg"
19+ op = "-" and path = "core::ops::arith::Neg" and method = "neg" and borrows = 0
1920 or
2021 // Not
21- op = "!" and path = "core::ops::bit::Not" and method = "not"
22+ op = "!" and path = "core::ops::bit::Not" and method = "not" and borrows = 0
2223 or
2324 // Dereference
24- op = "*" and path = "core::ops::deref::Deref" and method = "deref"
25+ op = "*" and path = "core::ops::deref::Deref" and method = "deref" and borrows = 0
2526 )
2627 or
2728 arity = 2 and
2829 (
2930 // Comparison operators
30- op = "==" and path = "core::cmp::PartialEq" and method = "eq"
31+ op = "==" and path = "core::cmp::PartialEq" and method = "eq" and borrows = 2
3132 or
32- op = "!=" and path = "core::cmp::PartialEq" and method = "ne"
33+ op = "!=" and path = "core::cmp::PartialEq" and method = "ne" and borrows = 2
3334 or
34- op = "<" and path = "core::cmp::PartialOrd" and method = "lt"
35+ op = "<" and path = "core::cmp::PartialOrd" and method = "lt" and borrows = 2
3536 or
36- op = "<=" and path = "core::cmp::PartialOrd" and method = "le"
37+ op = "<=" and path = "core::cmp::PartialOrd" and method = "le" and borrows = 2
3738 or
38- op = ">" and path = "core::cmp::PartialOrd" and method = "gt"
39+ op = ">" and path = "core::cmp::PartialOrd" and method = "gt" and borrows = 2
3940 or
40- op = ">=" and path = "core::cmp::PartialOrd" and method = "ge"
41+ op = ">=" and path = "core::cmp::PartialOrd" and method = "ge" and borrows = 2
4142 or
4243 // Arithmetic operators
43- op = "+" and path = "core::ops::arith::Add" and method = "add"
44+ op = "+" and path = "core::ops::arith::Add" and method = "add" and borrows = 0
4445 or
45- op = "-" and path = "core::ops::arith::Sub" and method = "sub"
46+ op = "-" and path = "core::ops::arith::Sub" and method = "sub" and borrows = 0
4647 or
47- op = "*" and path = "core::ops::arith::Mul" and method = "mul"
48+ op = "*" and path = "core::ops::arith::Mul" and method = "mul" and borrows = 0
4849 or
49- op = "/" and path = "core::ops::arith::Div" and method = "div"
50+ op = "/" and path = "core::ops::arith::Div" and method = "div" and borrows = 0
5051 or
51- op = "%" and path = "core::ops::arith::Rem" and method = "rem"
52+ op = "%" and path = "core::ops::arith::Rem" and method = "rem" and borrows = 0
5253 or
5354 // Arithmetic assignment expressions
54- op = "+=" and path = "core::ops::arith::AddAssign" and method = "add_assign"
55+ op = "+=" and path = "core::ops::arith::AddAssign" and method = "add_assign" and borrows = 1
5556 or
56- op = "-=" and path = "core::ops::arith::SubAssign" and method = "sub_assign"
57+ op = "-=" and path = "core::ops::arith::SubAssign" and method = "sub_assign" and borrows = 1
5758 or
58- op = "*=" and path = "core::ops::arith::MulAssign" and method = "mul_assign"
59+ op = "*=" and path = "core::ops::arith::MulAssign" and method = "mul_assign" and borrows = 1
5960 or
60- op = "/=" and path = "core::ops::arith::DivAssign" and method = "div_assign"
61+ op = "/=" and path = "core::ops::arith::DivAssign" and method = "div_assign" and borrows = 1
6162 or
62- op = "%=" and path = "core::ops::arith::RemAssign" and method = "rem_assign"
63+ op = "%=" and path = "core::ops::arith::RemAssign" and method = "rem_assign" and borrows = 1
6364 or
6465 // Bitwise operators
65- op = "&" and path = "core::ops::bit::BitAnd" and method = "bitand"
66+ op = "&" and path = "core::ops::bit::BitAnd" and method = "bitand" and borrows = 0
6667 or
67- op = "|" and path = "core::ops::bit::BitOr" and method = "bitor"
68+ op = "|" and path = "core::ops::bit::BitOr" and method = "bitor" and borrows = 0
6869 or
69- op = "^" and path = "core::ops::bit::BitXor" and method = "bitxor"
70+ op = "^" and path = "core::ops::bit::BitXor" and method = "bitxor" and borrows = 0
7071 or
71- op = "<<" and path = "core::ops::bit::Shl" and method = "shl"
72+ op = "<<" and path = "core::ops::bit::Shl" and method = "shl" and borrows = 0
7273 or
73- op = ">>" and path = "core::ops::bit::Shr" and method = "shr"
74+ op = ">>" and path = "core::ops::bit::Shr" and method = "shr" and borrows = 0
7475 or
7576 // Bitwise assignment operators
76- op = "&=" and path = "core::ops::bit::BitAndAssign" and method = "bitand_assign"
77+ op = "&=" and path = "core::ops::bit::BitAndAssign" and method = "bitand_assign" and borrows = 1
7778 or
78- op = "|=" and path = "core::ops::bit::BitOrAssign" and method = "bitor_assign"
79+ op = "|=" and path = "core::ops::bit::BitOrAssign" and method = "bitor_assign" and borrows = 1
7980 or
80- op = "^=" and path = "core::ops::bit::BitXorAssign" and method = "bitxor_assign"
81+ op = "^=" and path = "core::ops::bit::BitXorAssign" and method = "bitxor_assign" and borrows = 1
8182 or
82- op = "<<=" and path = "core::ops::bit::ShlAssign" and method = "shl_assign"
83+ op = "<<=" and path = "core::ops::bit::ShlAssign" and method = "shl_assign" and borrows = 1
8384 or
84- op = ">>=" and path = "core::ops::bit::ShrAssign" and method = "shr_assign"
85+ op = ">>=" and path = "core::ops::bit::ShrAssign" and method = "shr_assign" and borrows = 1
8586 )
8687}
8788
@@ -114,9 +115,9 @@ module Impl {
114115 * Holds if this operation is overloaded to the method `methodName` of the
115116 * trait `trait`.
116117 */
117- predicate isOverloaded ( Trait trait , string methodName ) {
118+ predicate isOverloaded ( Trait trait , string methodName , int borrows ) {
118119 isOverloaded ( this .getOperatorName ( ) , this .getNumberOfOperands ( ) , trait .getCanonicalPath ( ) ,
119- methodName )
120+ methodName , borrows )
120121 }
121122 }
122123}
0 commit comments