Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 08ac185

Browse files
committed
append_const_msg for std traits
1 parent 77b0c47 commit 08ac185

File tree

2 files changed

+16
-59
lines changed

2 files changed

+16
-59
lines changed

library/core/src/cmp.rs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,10 @@ use self::Ordering::*;
204204
#[stable(feature = "rust1", since = "1.0.0")]
205205
#[doc(alias = "==")]
206206
#[doc(alias = "!=")]
207-
#[cfg_attr(
208-
bootstrap,
209-
rustc_on_unimplemented(
210-
message = "can't compare `{Self}` with `{Rhs}`",
211-
label = "no implementation for `{Self} == {Rhs}`"
212-
)
213-
)]
214-
#[cfg_attr(
215-
not(bootstrap),
216-
rustc_on_unimplemented(
217-
message = "can't compare `{Self}` with `{Rhs}`",
218-
label = "no implementation for `{Self} == {Rhs}`",
219-
append_const_msg,
220-
)
207+
#[rustc_on_unimplemented(
208+
message = "can't compare `{Self}` with `{Rhs}`",
209+
label = "no implementation for `{Self} == {Rhs}`",
210+
append_const_msg
221211
)]
222212
#[const_trait]
223213
#[rustc_diagnostic_item = "PartialEq"]
@@ -1076,20 +1066,10 @@ impl const PartialOrd for Ordering {
10761066
#[doc(alias = "<")]
10771067
#[doc(alias = "<=")]
10781068
#[doc(alias = ">=")]
1079-
#[cfg_attr(
1080-
bootstrap,
1081-
rustc_on_unimplemented(
1082-
message = "can't compare `{Self}` with `{Rhs}`",
1083-
label = "no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`",
1084-
)
1085-
)]
1086-
#[cfg_attr(
1087-
not(bootstrap),
1088-
rustc_on_unimplemented(
1089-
message = "can't compare `{Self}` with `{Rhs}`",
1090-
label = "no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`",
1091-
append_const_msg,
1092-
)
1069+
#[rustc_on_unimplemented(
1070+
message = "can't compare `{Self}` with `{Rhs}`",
1071+
label = "no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`",
1072+
append_const_msg
10931073
)]
10941074
#[const_trait]
10951075
#[rustc_diagnostic_item = "PartialOrd"]

library/core/src/ops/arith.rs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,12 @@
6565
/// ```
6666
#[lang = "add"]
6767
#[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
9874
)]
9975
#[doc(alias = "+")]
10076
#[const_trait]
@@ -202,7 +178,8 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
202178
#[stable(feature = "rust1", since = "1.0.0")]
203179
#[rustc_on_unimplemented(
204180
message = "cannot subtract `{Rhs}` from `{Self}`",
205-
label = "no implementation for `{Self} - {Rhs}`"
181+
label = "no implementation for `{Self} - {Rhs}`",
182+
append_const_msg
206183
)]
207184
#[doc(alias = "-")]
208185
#[const_trait]

0 commit comments

Comments
 (0)