]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/ops/arith.rs
Auto merge of #101837 - scottmcm:box-array-from-vec, r=m-ou-se
[rust.git] / library / core / src / ops / arith.rs
index e367be8c167c720d64ecb26125d4d25c963e7980..75c52d3ecfc8bd56d7350362d90c5dff4e58ea55 100644 (file)
 /// ```
 #[lang = "add"]
 #[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(
-    bootstrap,
-    rustc_on_unimplemented(
-        on(
-            all(_Self = "{integer}", Rhs = "{float}"),
-            message = "cannot add a float to an integer",
-        ),
-        on(
-            all(_Self = "{float}", Rhs = "{integer}"),
-            message = "cannot add an integer to a float",
-        ),
-        message = "cannot add `{Rhs}` to `{Self}`",
-        label = "no implementation for `{Self} + {Rhs}`"
-    )
-)]
-#[cfg_attr(
-    not(bootstrap),
-    rustc_on_unimplemented(
-        on(
-            all(_Self = "{integer}", Rhs = "{float}"),
-            message = "cannot add a float to an integer",
-        ),
-        on(
-            all(_Self = "{float}", Rhs = "{integer}"),
-            message = "cannot add an integer to a float",
-        ),
-        message = "cannot add `{Rhs}` to `{Self}`",
-        label = "no implementation for `{Self} + {Rhs}`",
-        append_const_msg,
-    )
+#[rustc_on_unimplemented(
+    on(all(_Self = "{integer}", Rhs = "{float}"), message = "cannot add a float to an integer",),
+    on(all(_Self = "{float}", Rhs = "{integer}"), message = "cannot add an integer to a float",),
+    message = "cannot add `{Rhs}` to `{Self}`",
+    label = "no implementation for `{Self} + {Rhs}`",
+    append_const_msg
 )]
 #[doc(alias = "+")]
+#[const_trait]
 pub trait Add<Rhs = Self> {
     /// The resulting type after applying the `+` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -201,9 +178,11 @@ fn add(self, other: $t) -> $t { self + other }
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_on_unimplemented(
     message = "cannot subtract `{Rhs}` from `{Self}`",
-    label = "no implementation for `{Self} - {Rhs}`"
+    label = "no implementation for `{Self} - {Rhs}`",
+    append_const_msg
 )]
 #[doc(alias = "-")]
+#[const_trait]
 pub trait Sub<Rhs = Self> {
     /// The resulting type after applying the `-` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -333,6 +312,7 @@ fn sub(self, other: $t) -> $t { self - other }
     label = "no implementation for `{Self} * {Rhs}`"
 )]
 #[doc(alias = "*")]
+#[const_trait]
 pub trait Mul<Rhs = Self> {
     /// The resulting type after applying the `*` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -466,6 +446,7 @@ fn mul(self, other: $t) -> $t { self * other }
     label = "no implementation for `{Self} / {Rhs}`"
 )]
 #[doc(alias = "/")]
+#[const_trait]
 pub trait Div<Rhs = Self> {
     /// The resulting type after applying the `/` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -568,6 +549,7 @@ fn div(self, other: $t) -> $t { self / other }
     label = "no implementation for `{Self} % {Rhs}`"
 )]
 #[doc(alias = "%")]
+#[const_trait]
 pub trait Rem<Rhs = Self> {
     /// The resulting type after applying the `%` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -682,6 +664,7 @@ fn rem(self, other: $t) -> $t { self % other }
 #[lang = "neg"]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(alias = "-")]
+#[const_trait]
 pub trait Neg {
     /// The resulting type after applying the `-` operator.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -755,6 +738,7 @@ fn neg(self) -> $t { -self }
 )]
 #[doc(alias = "+")]
 #[doc(alias = "+=")]
+#[const_trait]
 pub trait AddAssign<Rhs = Self> {
     /// Performs the `+=` operation.
     ///
@@ -822,6 +806,7 @@ fn add_assign(&mut self, other: $t) { *self += other }
 )]
 #[doc(alias = "-")]
 #[doc(alias = "-=")]
+#[const_trait]
 pub trait SubAssign<Rhs = Self> {
     /// Performs the `-=` operation.
     ///
@@ -880,6 +865,7 @@ fn sub_assign(&mut self, other: $t) { *self -= other }
 )]
 #[doc(alias = "*")]
 #[doc(alias = "*=")]
+#[const_trait]
 pub trait MulAssign<Rhs = Self> {
     /// Performs the `*=` operation.
     ///
@@ -938,6 +924,7 @@ fn mul_assign(&mut self, other: $t) { *self *= other }
 )]
 #[doc(alias = "/")]
 #[doc(alias = "/=")]
+#[const_trait]
 pub trait DivAssign<Rhs = Self> {
     /// Performs the `/=` operation.
     ///
@@ -999,6 +986,7 @@ fn div_assign(&mut self, other: $t) { *self /= other }
 )]
 #[doc(alias = "%")]
 #[doc(alias = "%=")]
+#[const_trait]
 pub trait RemAssign<Rhs = Self> {
     /// Performs the `%=` operation.
     ///