Skip to content

Commit 7d58eae

Browse files
Pretty print Fn traits in rustc_on_unimplemented
1 parent 561e4cb commit 7d58eae

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

core/src/ops/function.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::marker::Tuple;
5656
#[lang = "fn"]
5757
#[stable(feature = "rust1", since = "1.0.0")]
5858
#[rustc_paren_sugar]
59-
#[rustc_on_unimplemented(
59+
#[cfg_attr(not(bootstrap), rustc_on_unimplemented(
6060
on(
6161
Args = "()",
6262
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@@ -67,9 +67,9 @@ use crate::marker::Tuple;
6767
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
6868
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
6969
),
70-
message = "expected a `{Fn}<{Args}>` closure, found `{Self}`",
71-
label = "expected an `Fn<{Args}>` closure, found `{Self}`"
72-
)]
70+
message = "expected a `{Trait}` closure, found `{Self}`",
71+
label = "expected an `{Trait}` closure, found `{Self}`"
72+
))]
7373
#[fundamental] // so that regex can rely that `&str: !FnMut`
7474
#[must_use = "closures are lazy and do nothing unless called"]
7575
// FIXME(effects) #[const_trait]
@@ -143,7 +143,7 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
143143
#[lang = "fn_mut"]
144144
#[stable(feature = "rust1", since = "1.0.0")]
145145
#[rustc_paren_sugar]
146-
#[rustc_on_unimplemented(
146+
#[cfg_attr(not(bootstrap), rustc_on_unimplemented(
147147
on(
148148
Args = "()",
149149
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@@ -154,9 +154,9 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
154154
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
155155
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
156156
),
157-
message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`",
158-
label = "expected an `FnMut<{Args}>` closure, found `{Self}`"
159-
)]
157+
message = "expected a `{Trait}` closure, found `{Self}`",
158+
label = "expected an `{Trait}` closure, found `{Self}`"
159+
))]
160160
#[fundamental] // so that regex can rely that `&str: !FnMut`
161161
#[must_use = "closures are lazy and do nothing unless called"]
162162
// FIXME(effects) #[const_trait]
@@ -222,7 +222,7 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
222222
#[lang = "fn_once"]
223223
#[stable(feature = "rust1", since = "1.0.0")]
224224
#[rustc_paren_sugar]
225-
#[rustc_on_unimplemented(
225+
#[cfg_attr(not(bootstrap), rustc_on_unimplemented(
226226
on(
227227
Args = "()",
228228
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@@ -233,9 +233,9 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
233233
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
234234
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
235235
),
236-
message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`",
237-
label = "expected an `FnOnce<{Args}>` closure, found `{Self}`"
238-
)]
236+
message = "expected a `{Trait}` closure, found `{Self}`",
237+
label = "expected an `{Trait}` closure, found `{Self}`"
238+
))]
239239
#[fundamental] // so that regex can rely that `&str: !FnMut`
240240
#[must_use = "closures are lazy and do nothing unless called"]
241241
// FIXME(effects) #[const_trait]

0 commit comments

Comments
 (0)