@@ -5,6 +5,23 @@ macro_rules! forward_ref_unop {
5
5
forward_ref_unop!( impl $imp, $method for $t,
6
6
#[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
7
7
} ;
8
+ ( impl const $imp: ident, $method: ident for $t: ty) => {
9
+ forward_ref_unop!( impl const $imp, $method for $t,
10
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
11
+ } ;
12
+ // Equivalent to the non-const version, with the addition of `rustc_const_unstable`
13
+ ( impl const $imp: ident, $method: ident for $t: ty, #[ $attr: meta] ) => {
14
+ #[ $attr]
15
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "90080" ) ]
16
+ impl const $imp for & $t {
17
+ type Output = <$t as $imp>:: Output ;
18
+
19
+ #[ inline]
20
+ fn $method( self ) -> <$t as $imp>:: Output {
21
+ $imp:: $method( * self )
22
+ }
23
+ }
24
+ } ;
8
25
( impl $imp: ident, $method: ident for $t: ty, #[ $attr: meta] ) => {
9
26
#[ $attr]
10
27
impl $imp for & $t {
@@ -25,6 +42,45 @@ macro_rules! forward_ref_binop {
25
42
forward_ref_binop!( impl $imp, $method for $t, $u,
26
43
#[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
27
44
} ;
45
+ ( impl const $imp: ident, $method: ident for $t: ty, $u: ty) => {
46
+ forward_ref_binop!( impl const $imp, $method for $t, $u,
47
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
48
+ } ;
49
+ // Equivalent to the non-const version, with the addition of `rustc_const_unstable`
50
+ ( impl const $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
51
+ #[ $attr]
52
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "90080" ) ]
53
+ impl <' a> const $imp<$u> for & ' a $t {
54
+ type Output = <$t as $imp<$u>>:: Output ;
55
+
56
+ #[ inline]
57
+ fn $method( self , other: $u) -> <$t as $imp<$u>>:: Output {
58
+ $imp:: $method( * self , other)
59
+ }
60
+ }
61
+
62
+ #[ $attr]
63
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "90080" ) ]
64
+ impl const $imp<& $u> for $t {
65
+ type Output = <$t as $imp<$u>>:: Output ;
66
+
67
+ #[ inline]
68
+ fn $method( self , other: & $u) -> <$t as $imp<$u>>:: Output {
69
+ $imp:: $method( self , * other)
70
+ }
71
+ }
72
+
73
+ #[ $attr]
74
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "90080" ) ]
75
+ impl const $imp<& $u> for & $t {
76
+ type Output = <$t as $imp<$u>>:: Output ;
77
+
78
+ #[ inline]
79
+ fn $method( self , other: & $u) -> <$t as $imp<$u>>:: Output {
80
+ $imp:: $method( * self , * other)
81
+ }
82
+ }
83
+ } ;
28
84
( impl $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
29
85
#[ $attr]
30
86
impl <' a> $imp<$u> for & ' a $t {
@@ -65,6 +121,21 @@ macro_rules! forward_ref_op_assign {
65
121
forward_ref_op_assign!( impl $imp, $method for $t, $u,
66
122
#[ stable( feature = "op_assign_builtins_by_ref" , since = "1.22.0" ) ] ) ;
67
123
} ;
124
+ ( impl const $imp: ident, $method: ident for $t: ty, $u: ty) => {
125
+ forward_ref_op_assign!( impl const $imp, $method for $t, $u,
126
+ #[ stable( feature = "op_assign_builtins_by_ref" , since = "1.22.0" ) ] ) ;
127
+ } ;
128
+ // Equivalent to the non-const version, with the addition of `rustc_const_unstable`
129
+ ( impl const $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
130
+ #[ $attr]
131
+ #[ rustc_const_unstable( feature = "const_ops" , issue = "90080" ) ]
132
+ impl const $imp<& $u> for $t {
133
+ #[ inline]
134
+ fn $method( & mut self , other: & $u) {
135
+ $imp:: $method( self , * other) ;
136
+ }
137
+ }
138
+ } ;
68
139
( impl $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
69
140
#[ $attr]
70
141
impl $imp<& $u> for $t {
0 commit comments