Skip to content

Commit c83f642

Browse files
Pretty print Fn traits in rustc_on_unimplemented
1 parent b20f40d commit c83f642

File tree

61 files changed

+169
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+169
-154
lines changed

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ symbols! {
316316
ToOwned,
317317
ToString,
318318
TokenStream,
319+
Trait,
319320
Try,
320321
TryCaptureGeneric,
321322
TryCapturePrintable,

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+14
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[
5353
sym::float,
5454
sym::_Self,
5555
sym::crate_local,
56+
sym::Trait,
5657
];
5758

5859
impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
@@ -183,6 +184,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
183184
flags.push((sym::cause, Some("MainFunctionType".to_string())));
184185
}
185186

187+
if let Some(kind) = self.tcx.fn_trait_kind_from_def_id(trait_ref.def_id)
188+
&& let ty::Tuple(args) = trait_ref.args.type_at(1).kind()
189+
{
190+
let args = args
191+
.iter()
192+
.map(|ty| ty.to_string())
193+
.collect::<Vec<_>>()
194+
.join(", ");
195+
flags.push((sym::Trait, Some(format!("{}({args})", kind.as_str()))));
196+
} else {
197+
flags.push((sym::Trait, Some(trait_ref.print_only_trait_path().to_string())));
198+
}
199+
186200
// Add all types without trimmed paths or visible paths, ensuring they end up with
187201
// their "canonical" def path.
188202
ty::print::with_no_trimmed_paths!(ty::print::with_no_visible_paths!({

library/core/src/ops/function.rs

+12-12
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]

tests/ui/closures/closure-expected.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
22
let x = Some(1);
33
let y = x.or_else(4);
4-
//~^ ERROR expected a `FnOnce<()>` closure, found `{integer}`
4+
//~^ ERROR expected a `FnOnce()` closure, found `{integer}`
55
}

tests/ui/closures/closure-expected.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
1+
error[E0277]: expected a `FnOnce()` closure, found `{integer}`
22
--> $DIR/closure-expected.rs:3:23
33
|
44
LL | let y = x.or_else(4);
5-
| ------- ^ expected an `FnOnce<()>` closure, found `{integer}`
5+
| ------- ^ expected an `FnOnce()` closure, found `{integer}`
66
| |
77
| required by a bound introduced by this call
88
|

tests/ui/closures/coerce-unsafe-to-closure.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: expected a `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
1+
error[E0277]: expected a `FnOnce(&str)` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
22
--> $DIR/coerce-unsafe-to-closure.rs:2:44
33
|
44
LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);

tests/ui/expr/malformed_closure/block_instead_of_closure_in_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
let number = 2;
3-
Some(true).filter({ //~ ERROR expected a `FnOnce<(&bool,)>` closure, found `bool`
3+
Some(true).filter({ //~ ERROR expected a `FnOnce(&bool)` closure, found `bool`
44
if number % 2 == 0 {
55
number == 0
66
} else {

tests/ui/expr/malformed_closure/block_instead_of_closure_in_arg.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: expected a `FnOnce<(&bool,)>` closure, found `bool`
1+
error[E0277]: expected a `FnOnce(&bool)` closure, found `bool`
22
--> $DIR/block_instead_of_closure_in_arg.rs:3:23
33
|
44
LL | Some(true).filter({
@@ -12,7 +12,7 @@ LL | || number != 0
1212
LL | || }
1313
| ||_________- this tail expression is of type `bool`
1414
LL | | });
15-
| |______^ expected an `FnOnce<(&bool,)>` closure, found `bool`
15+
| |______^ expected an `FnOnce(&bool)` closure, found `bool`
1616
|
1717
= help: the trait `for<'a> FnOnce<(&'a bool,)>` is not implemented for `bool`
1818
note: required by a bound in `Option::<T>::filter`

tests/ui/expr/malformed_closure/ruby_style_closure_successful_parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const x: usize =42;
22
fn main() {
3-
let p = Some(45).and_then({|x| //~ ERROR expected a `FnOnce<({integer},)>` closure, found `Option<usize>`
3+
let p = Some(45).and_then({|x| //~ ERROR expected a `FnOnce({integer})` closure, found `Option<usize>`
44
1 + 1;
55
Some(x * 2)
66
});

tests/ui/expr/malformed_closure/ruby_style_closure_successful_parse.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<usize>`
1+
error[E0277]: expected a `FnOnce({integer})` closure, found `Option<usize>`
22
--> $DIR/ruby_style_closure_successful_parse.rs:3:31
33
|
44
LL | let p = Some(45).and_then({|x|
@@ -9,7 +9,7 @@ LL | | 1 + 1;
99
LL | | Some(x * 2)
1010
| | ----------- this tail expression is of type `Option<usize>`
1111
LL | | });
12-
| |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<usize>`
12+
| |_____^ expected an `FnOnce({integer})` closure, found `Option<usize>`
1313
|
1414
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<usize>`
1515
note: required by a bound in `Option::<T>::and_then`

tests/ui/extern/extern-wrong-value-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() {
77
// extern functions are extern "C" fn
88
let _x: extern "C" fn() = f; // OK
99
is_fn(f);
10-
//~^ ERROR expected a `Fn<()>` closure, found `extern "C" fn() {f}`
10+
//~^ ERROR expected a `Fn()` closure, found `extern "C" fn() {f}`
1111
}

tests/ui/extern/extern-wrong-value-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() {f}`
1+
error[E0277]: expected a `Fn()` closure, found `extern "C" fn() {f}`
22
--> $DIR/extern-wrong-value-type.rs:9:11
33
|
44
LL | is_fn(f);
5-
| ----- ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}`
5+
| ----- ^ expected an `Fn()` closure, found `extern "C" fn() {f}`
66
| |
77
| required by a bound introduced by this call
88
|

tests/ui/fn/fn-trait-formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ fn main() {
1717
//~| found struct `Box<dyn FnMut() -> isize>`
1818

1919
needs_fn(1);
20-
//~^ ERROR expected a `Fn<(isize,)>` closure, found `{integer}`
20+
//~^ ERROR expected a `Fn(isize)` closure, found `{integer}`
2121
}

tests/ui/fn/fn-trait-formatting.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ LL | let _: () = Box::new(|| -> isize { unimplemented!() }) as Box<dyn FnMut
3939
= note: expected unit type `()`
4040
found struct `Box<dyn FnMut() -> isize>`
4141

42-
error[E0277]: expected a `Fn<(isize,)>` closure, found `{integer}`
42+
error[E0277]: expected a `Fn(isize)` closure, found `{integer}`
4343
--> $DIR/fn-trait-formatting.rs:19:14
4444
|
4545
LL | needs_fn(1);
46-
| -------- ^ expected an `Fn<(isize,)>` closure, found `{integer}`
46+
| -------- ^ expected an `Fn(isize)` closure, found `{integer}`
4747
| |
4848
| required by a bound introduced by this call
4949
|

tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Fun {
1010

1111
impl<T> Fun for T {
1212
type F<'a> = Self;
13-
//~^ ERROR expected a `Fn<()>` closure, found `T`
13+
//~^ ERROR expected a `Fn()` closure, found `T`
1414
}
1515

1616
fn main() {

tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `T`
1+
error[E0277]: expected a `Fn()` closure, found `T`
22
--> $DIR/issue-68642-broken-llvm-ir.rs:12:18
33
|
44
LL | type F<'a> = Self;
5-
| ^^^^ expected an `Fn<()>` closure, found `T`
5+
| ^^^^ expected an `Fn()` closure, found `T`
66
|
77
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
88
note: required by a bound in `Fun::F`

tests/ui/generic-associated-types/issue-68643-broken-mir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Fun {
1010

1111
impl<T> Fun for T {
1212
type F<'a> = Self;
13-
//~^ ERROR expected a `Fn<()>` closure, found `T`
13+
//~^ ERROR expected a `Fn()` closure, found `T`
1414
}
1515

1616
pub fn main() {

tests/ui/generic-associated-types/issue-68643-broken-mir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `T`
1+
error[E0277]: expected a `Fn()` closure, found `T`
22
--> $DIR/issue-68643-broken-mir.rs:12:18
33
|
44
LL | type F<'a> = Self;
5-
| ^^^^ expected an `Fn<()>` closure, found `T`
5+
| ^^^^ expected an `Fn()` closure, found `T`
66
|
77
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
88
note: required by a bound in `Fun::F`

tests/ui/generic-associated-types/issue-68644-codegen-selection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Fun {
1010

1111
impl<T> Fun for T {
1212
type F<'a> = Self;
13-
//~^ ERROR expected a `Fn<()>` closure, found `T`
13+
//~^ ERROR expected a `Fn()` closure, found `T`
1414
}
1515

1616
fn main() {

tests/ui/generic-associated-types/issue-68644-codegen-selection.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `T`
1+
error[E0277]: expected a `Fn()` closure, found `T`
22
--> $DIR/issue-68644-codegen-selection.rs:12:18
33
|
44
LL | type F<'a> = Self;
5-
| ^^^^ expected an `Fn<()>` closure, found `T`
5+
| ^^^^ expected an `Fn()` closure, found `T`
66
|
77
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
88
note: required by a bound in `Fun::F`

tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Fun {
1010

1111
impl<T> Fun for T {
1212
type F<'a> = Self;
13-
//~^ ERROR expected a `Fn<()>` closure, found `T`
13+
//~^ ERROR expected a `Fn()` closure, found `T`
1414
}
1515

1616
fn main() {

tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `T`
1+
error[E0277]: expected a `Fn()` closure, found `T`
22
--> $DIR/issue-68645-codegen-fulfillment.rs:12:18
33
|
44
LL | type F<'a> = Self;
5-
| ^^^^ expected an `Fn<()>` closure, found `T`
5+
| ^^^^ expected an `Fn()` closure, found `T`
66
|
77
= note: wrap the `T` in a closure with no arguments: `|| { /* code */ }`
88
note: required by a bound in `Fun::F`

tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())`
1+
error[E0277]: expected a `Fn(&'w ())` closure, found `fn(&'w ())`
22
--> $DIR/fn-ptr.rs:12:5
33
|
44
LL | ice();
5-
| ^^^ expected an `Fn<(&'w (),)>` closure, found `fn(&'w ())`
5+
| ^^^ expected an `Fn(&'w ())` closure, found `fn(&'w ())`
66
|
77
= help: the trait `for<'w> Fn<(&'w (),)>` is not implemented for `fn(&'w ())`
88
note: required by a bound in `ice`

tests/ui/higher-ranked/trait-bounds/fn-ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ where
1010

1111
fn main() {
1212
ice();
13-
//[classic]~^ ERROR expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())`
13+
//[classic]~^ ERROR expected a `Fn(&'w ())` closure, found `fn(&'w ())`
1414
}

tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F`
1+
error[E0277]: expected a `Fn(<_ as ATC<'a>>::Type)` closure, found `F`
22
--> $DIR/issue-62529-3.rs:25:14
33
|
44
LL | call(f, ());
5-
| ---- ^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F`
5+
| ---- ^ expected an `Fn(<_ as ATC<'a>>::Type)` closure, found `F`
66
| |
77
| required by a bound introduced by this call
88
|

tests/ui/implied-bounds/issue-100690.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ impl<'a, T: 'a> Handle<'a, T, UIView<'a, T>, Result<(), io::Error>> for TUIHandl
3535
F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static,
3636
{
3737
real_dispatch(f)
38-
//~^ ERROR expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
39-
//~| NOTE expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
38+
//~^ ERROR expected a `FnOnce(&mut UIView<'_, T>)` closure, found `F`
39+
//~| NOTE expected an `FnOnce(&mut UIView<'_, T>)` closure, found `F`
4040
//~| NOTE expected a closure with arguments
4141
//~| NOTE required by a bound introduced by this call
4242
}

tests/ui/implied-bounds/issue-100690.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
1+
error[E0277]: expected a `FnOnce(&mut UIView<'_, T>)` closure, found `F`
22
--> $DIR/issue-100690.rs:37:23
33
|
44
LL | real_dispatch(f)
5-
| ------------- ^ expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F`
5+
| ------------- ^ expected an `FnOnce(&mut UIView<'_, T>)` closure, found `F`
66
| |
77
| required by a bound introduced by this call
88
|

tests/ui/intrinsics/const-eval-select-bad.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const fn not_fn_items() {
88
//~^ ERROR this argument must be a function item
99
//~| ERROR this argument must be a function item
1010
const_eval_select((), 42, 0xDEADBEEF);
11-
//~^ ERROR expected a `FnOnce<()>` closure
12-
//~| ERROR expected a `FnOnce<()>` closure
11+
//~^ ERROR expected a `FnOnce()` closure
12+
//~| ERROR expected a `FnOnce()` closure
1313
//~| ERROR this argument must be a function item
1414
//~| ERROR this argument must be a function item
1515
}

tests/ui/intrinsics/const-eval-select-bad.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ LL | const_eval_select((), 42, 0xDEADBEEF);
2525
= note: expected a function item, found {integer}
2626
= help: consult the documentation on `const_eval_select` for more information
2727

28-
error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
28+
error[E0277]: expected a `FnOnce()` closure, found `{integer}`
2929
--> $DIR/const-eval-select-bad.rs:10:27
3030
|
3131
LL | const_eval_select((), 42, 0xDEADBEEF);
32-
| ----------------- ^^ expected an `FnOnce<()>` closure, found `{integer}`
32+
| ----------------- ^^ expected an `FnOnce()` closure, found `{integer}`
3333
| |
3434
| required by a bound introduced by this call
3535
|
@@ -47,11 +47,11 @@ LL | const_eval_select((), 42, 0xDEADBEEF);
4747
= note: expected a function item, found {integer}
4848
= help: consult the documentation on `const_eval_select` for more information
4949

50-
error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
50+
error[E0277]: expected a `FnOnce()` closure, found `{integer}`
5151
--> $DIR/const-eval-select-bad.rs:10:31
5252
|
5353
LL | const_eval_select((), 42, 0xDEADBEEF);
54-
| ----------------- ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `{integer}`
54+
| ----------------- ^^^^^^^^^^ expected an `FnOnce()` closure, found `{integer}`
5555
| |
5656
| required by a bound introduced by this call
5757
|

tests/ui/issues/issue-22034.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ fn main() {
66
let ptr: *mut () = core::ptr::null_mut();
77
let _: &mut dyn Fn() = unsafe {
88
&mut *(ptr as *mut dyn Fn())
9-
//~^ ERROR expected a `Fn<()>` closure, found `()`
9+
//~^ ERROR expected a `Fn()` closure, found `()`
1010
};
1111
}

tests/ui/issues/issue-22034.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: expected a `Fn<()>` closure, found `()`
1+
error[E0277]: expected a `Fn()` closure, found `()`
22
--> $DIR/issue-22034.rs:8:16
33
|
44
LL | &mut *(ptr as *mut dyn Fn())
5-
| ^^^ expected an `Fn<()>` closure, found `()`
5+
| ^^^ expected an `Fn()` closure, found `()`
66
|
77
= help: the trait `Fn<()>` is not implemented for `()`
88
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`

0 commit comments

Comments
 (0)