|
65 | 65 | /// ``` |
66 | 66 | #[lang = "add"] |
67 | 67 | #[stable(feature = "rust1", since = "1.0.0")] |
68 | | -#[cfg_attr( |
69 | | - bootstrap, |
70 | | - rustc_on_unimplemented( |
71 | | - on( |
72 | | - all(_Self = "{integer}", Rhs = "{float}"), |
73 | | - message = "cannot add a float to an integer", |
74 | | - ), |
75 | | - on( |
76 | | - all(_Self = "{float}", Rhs = "{integer}"), |
77 | | - message = "cannot add an integer to a float", |
78 | | - ), |
79 | | - message = "cannot add `{Rhs}` to `{Self}`", |
80 | | - label = "no implementation for `{Self} + {Rhs}`" |
81 | | - ) |
82 | | -)] |
83 | | -#[cfg_attr( |
84 | | - not(bootstrap), |
85 | | - rustc_on_unimplemented( |
86 | | - on( |
87 | | - all(_Self = "{integer}", Rhs = "{float}"), |
88 | | - message = "cannot add a float to an integer", |
89 | | - ), |
90 | | - on( |
91 | | - all(_Self = "{float}", Rhs = "{integer}"), |
92 | | - message = "cannot add an integer to a float", |
93 | | - ), |
94 | | - message = "cannot add `{Rhs}` to `{Self}`", |
95 | | - label = "no implementation for `{Self} + {Rhs}`", |
96 | | - append_const_msg, |
97 | | - ) |
| 68 | +#[rustc_on_unimplemented( |
| 69 | + on(all(_Self = "{integer}", Rhs = "{float}"), message = "cannot add a float to an integer",), |
| 70 | + on(all(_Self = "{float}", Rhs = "{integer}"), message = "cannot add an integer to a float",), |
| 71 | + message = "cannot add `{Rhs}` to `{Self}`", |
| 72 | + label = "no implementation for `{Self} + {Rhs}`", |
| 73 | + append_const_msg |
98 | 74 | )] |
99 | 75 | #[doc(alias = "+")] |
| 76 | +#[const_trait] |
100 | 77 | pub trait Add<Rhs = Self> { |
101 | 78 | /// The resulting type after applying the `+` operator. |
102 | 79 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -201,9 +178,11 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
201 | 178 | #[stable(feature = "rust1", since = "1.0.0")] |
202 | 179 | #[rustc_on_unimplemented( |
203 | 180 | message = "cannot subtract `{Rhs}` from `{Self}`", |
204 | | - label = "no implementation for `{Self} - {Rhs}`" |
| 181 | + label = "no implementation for `{Self} - {Rhs}`", |
| 182 | + append_const_msg |
205 | 183 | )] |
206 | 184 | #[doc(alias = "-")] |
| 185 | +#[const_trait] |
207 | 186 | pub trait Sub<Rhs = Self> { |
208 | 187 | /// The resulting type after applying the `-` operator. |
209 | 188 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -333,6 +312,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
333 | 312 | label = "no implementation for `{Self} * {Rhs}`" |
334 | 313 | )] |
335 | 314 | #[doc(alias = "*")] |
| 315 | +#[const_trait] |
336 | 316 | pub trait Mul<Rhs = Self> { |
337 | 317 | /// The resulting type after applying the `*` operator. |
338 | 318 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -466,6 +446,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
466 | 446 | label = "no implementation for `{Self} / {Rhs}`" |
467 | 447 | )] |
468 | 448 | #[doc(alias = "/")] |
| 449 | +#[const_trait] |
469 | 450 | pub trait Div<Rhs = Self> { |
470 | 451 | /// The resulting type after applying the `/` operator. |
471 | 452 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -568,6 +549,7 @@ div_impl_float! { f32 f64 } |
568 | 549 | label = "no implementation for `{Self} % {Rhs}`" |
569 | 550 | )] |
570 | 551 | #[doc(alias = "%")] |
| 552 | +#[const_trait] |
571 | 553 | pub trait Rem<Rhs = Self> { |
572 | 554 | /// The resulting type after applying the `%` operator. |
573 | 555 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -682,6 +664,7 @@ rem_impl_float! { f32 f64 } |
682 | 664 | #[lang = "neg"] |
683 | 665 | #[stable(feature = "rust1", since = "1.0.0")] |
684 | 666 | #[doc(alias = "-")] |
| 667 | +#[const_trait] |
685 | 668 | pub trait Neg { |
686 | 669 | /// The resulting type after applying the `-` operator. |
687 | 670 | #[stable(feature = "rust1", since = "1.0.0")] |
@@ -755,6 +738,7 @@ neg_impl! { isize i8 i16 i32 i64 i128 f32 f64 } |
755 | 738 | )] |
756 | 739 | #[doc(alias = "+")] |
757 | 740 | #[doc(alias = "+=")] |
| 741 | +#[const_trait] |
758 | 742 | pub trait AddAssign<Rhs = Self> { |
759 | 743 | /// Performs the `+=` operation. |
760 | 744 | /// |
@@ -822,6 +806,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
822 | 806 | )] |
823 | 807 | #[doc(alias = "-")] |
824 | 808 | #[doc(alias = "-=")] |
| 809 | +#[const_trait] |
825 | 810 | pub trait SubAssign<Rhs = Self> { |
826 | 811 | /// Performs the `-=` operation. |
827 | 812 | /// |
@@ -880,6 +865,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
880 | 865 | )] |
881 | 866 | #[doc(alias = "*")] |
882 | 867 | #[doc(alias = "*=")] |
| 868 | +#[const_trait] |
883 | 869 | pub trait MulAssign<Rhs = Self> { |
884 | 870 | /// Performs the `*=` operation. |
885 | 871 | /// |
@@ -938,6 +924,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
938 | 924 | )] |
939 | 925 | #[doc(alias = "/")] |
940 | 926 | #[doc(alias = "/=")] |
| 927 | +#[const_trait] |
941 | 928 | pub trait DivAssign<Rhs = Self> { |
942 | 929 | /// Performs the `/=` operation. |
943 | 930 | /// |
@@ -999,6 +986,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } |
999 | 986 | )] |
1000 | 987 | #[doc(alias = "%")] |
1001 | 988 | #[doc(alias = "%=")] |
| 989 | +#[const_trait] |
1002 | 990 | pub trait RemAssign<Rhs = Self> { |
1003 | 991 | /// Performs the `%=` operation. |
1004 | 992 | /// |
|
0 commit comments