@@ -5,6 +5,23 @@ macro_rules! forward_ref_unop {
55 forward_ref_unop!( impl $imp, $method for $t,
66 #[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
77 } ;
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+ } ;
825 ( impl $imp: ident, $method: ident for $t: ty, #[ $attr: meta] ) => {
926 #[ $attr]
1027 impl $imp for & $t {
@@ -25,6 +42,45 @@ macro_rules! forward_ref_binop {
2542 forward_ref_binop!( impl $imp, $method for $t, $u,
2643 #[ stable( feature = "rust1" , since = "1.0.0" ) ] ) ;
2744 } ;
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+ } ;
2884 ( impl $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
2985 #[ $attr]
3086 impl <' a> $imp<$u> for & ' a $t {
@@ -65,6 +121,21 @@ macro_rules! forward_ref_op_assign {
65121 forward_ref_op_assign!( impl $imp, $method for $t, $u,
66122 #[ stable( feature = "op_assign_builtins_by_ref" , since = "1.22.0" ) ] ) ;
67123 } ;
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+ } ;
68139 ( impl $imp: ident, $method: ident for $t: ty, $u: ty, #[ $attr: meta] ) => {
69140 #[ $attr]
70141 impl $imp<& $u> for $t {
0 commit comments