1
Fork 0

Pretty print Fn traits in rustc_on_unimplemented

This commit is contained in:
Michael Goulet 2023-10-05 01:50:00 +00:00
parent b20f40dba9
commit c83f642f12
61 changed files with 169 additions and 154 deletions

View file

@ -316,6 +316,7 @@ symbols! {
ToOwned, ToOwned,
ToString, ToString,
TokenStream, TokenStream,
Trait,
Try, Try,
TryCaptureGeneric, TryCaptureGeneric,
TryCapturePrintable, TryCapturePrintable,

View file

@ -53,6 +53,7 @@ static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[
sym::float, sym::float,
sym::_Self, sym::_Self,
sym::crate_local, sym::crate_local,
sym::Trait,
]; ];
impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
@ -183,6 +184,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
flags.push((sym::cause, Some("MainFunctionType".to_string()))); flags.push((sym::cause, Some("MainFunctionType".to_string())));
} }
if let Some(kind) = self.tcx.fn_trait_kind_from_def_id(trait_ref.def_id)
&& let ty::Tuple(args) = trait_ref.args.type_at(1).kind()
{
let args = args
.iter()
.map(|ty| ty.to_string())
.collect::<Vec<_>>()
.join(", ");
flags.push((sym::Trait, Some(format!("{}({args})", kind.as_str()))));
} else {
flags.push((sym::Trait, Some(trait_ref.print_only_trait_path().to_string())));
}
// Add all types without trimmed paths or visible paths, ensuring they end up with // Add all types without trimmed paths or visible paths, ensuring they end up with
// their "canonical" def path. // their "canonical" def path.
ty::print::with_no_trimmed_paths!(ty::print::with_no_visible_paths!({ ty::print::with_no_trimmed_paths!(ty::print::with_no_visible_paths!({

View file

@ -56,7 +56,7 @@ use crate::marker::Tuple;
#[lang = "fn"] #[lang = "fn"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar] #[rustc_paren_sugar]
#[rustc_on_unimplemented( #[cfg_attr(not(bootstrap), rustc_on_unimplemented(
on( on(
Args = "()", Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@ -67,9 +67,9 @@ use crate::marker::Tuple;
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
), ),
message = "expected a `{Fn}<{Args}>` closure, found `{Self}`", message = "expected a `{Trait}` closure, found `{Self}`",
label = "expected an `Fn<{Args}>` closure, found `{Self}`" label = "expected an `{Trait}` closure, found `{Self}`"
)] ))]
#[fundamental] // so that regex can rely that `&str: !FnMut` #[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"] #[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait] // FIXME(effects) #[const_trait]
@ -143,7 +143,7 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
#[lang = "fn_mut"] #[lang = "fn_mut"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar] #[rustc_paren_sugar]
#[rustc_on_unimplemented( #[cfg_attr(not(bootstrap), rustc_on_unimplemented(
on( on(
Args = "()", Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@ -154,9 +154,9 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
), ),
message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`", message = "expected a `{Trait}` closure, found `{Self}`",
label = "expected an `FnMut<{Args}>` closure, found `{Self}`" label = "expected an `{Trait}` closure, found `{Self}`"
)] ))]
#[fundamental] // so that regex can rely that `&str: !FnMut` #[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"] #[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait] // FIXME(effects) #[const_trait]
@ -222,7 +222,7 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
#[lang = "fn_once"] #[lang = "fn_once"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_paren_sugar] #[rustc_paren_sugar]
#[rustc_on_unimplemented( #[cfg_attr(not(bootstrap), rustc_on_unimplemented(
on( on(
Args = "()", Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
@ -233,9 +233,9 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
), ),
message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`", message = "expected a `{Trait}` closure, found `{Self}`",
label = "expected an `FnOnce<{Args}>` closure, found `{Self}`" label = "expected an `{Trait}` closure, found `{Self}`"
)] ))]
#[fundamental] // so that regex can rely that `&str: !FnMut` #[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"] #[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait] // FIXME(effects) #[const_trait]

View file

@ -1,5 +1,5 @@
fn main() { fn main() {
let x = Some(1); let x = Some(1);
let y = x.or_else(4); let y = x.or_else(4);
//~^ ERROR expected a `FnOnce<()>` closure, found `{integer}` //~^ ERROR expected a `FnOnce()` closure, found `{integer}`
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnOnce<()>` closure, found `{integer}` error[E0277]: expected a `FnOnce()` closure, found `{integer}`
--> $DIR/closure-expected.rs:3:23 --> $DIR/closure-expected.rs:3:23
| |
LL | let y = x.or_else(4); LL | let y = x.or_else(4);
| ------- ^ expected an `FnOnce<()>` closure, found `{integer}` | ------- ^ expected an `FnOnce()` closure, found `{integer}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

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

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
let number = 2; let number = 2;
Some(true).filter({ //~ ERROR expected a `FnOnce<(&bool,)>` closure, found `bool` Some(true).filter({ //~ ERROR expected a `FnOnce(&bool)` closure, found `bool`
if number % 2 == 0 { if number % 2 == 0 {
number == 0 number == 0
} else { } else {

View file

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

View file

@ -1,6 +1,6 @@
const x: usize =42; const x: usize =42;
fn main() { fn main() {
let p = Some(45).and_then({|x| //~ ERROR expected a `FnOnce<({integer},)>` closure, found `Option<usize>` let p = Some(45).and_then({|x| //~ ERROR expected a `FnOnce({integer})` closure, found `Option<usize>`
1 + 1; 1 + 1;
Some(x * 2) Some(x * 2)
}); });

View file

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

View file

@ -7,5 +7,5 @@ fn main() {
// extern functions are extern "C" fn // extern functions are extern "C" fn
let _x: extern "C" fn() = f; // OK let _x: extern "C" fn() = f; // OK
is_fn(f); is_fn(f);
//~^ ERROR expected a `Fn<()>` closure, found `extern "C" fn() {f}` //~^ ERROR expected a `Fn()` closure, found `extern "C" fn() {f}`
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() {f}` error[E0277]: expected a `Fn()` closure, found `extern "C" fn() {f}`
--> $DIR/extern-wrong-value-type.rs:9:11 --> $DIR/extern-wrong-value-type.rs:9:11
| |
LL | is_fn(f); LL | is_fn(f);
| ----- ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}` | ----- ^ expected an `Fn()` closure, found `extern "C" fn() {f}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -17,5 +17,5 @@ fn main() {
//~| found struct `Box<dyn FnMut() -> isize>` //~| found struct `Box<dyn FnMut() -> isize>`
needs_fn(1); needs_fn(1);
//~^ ERROR expected a `Fn<(isize,)>` closure, found `{integer}` //~^ ERROR expected a `Fn(isize)` closure, found `{integer}`
} }

View file

@ -39,11 +39,11 @@ LL | let _: () = Box::new(|| -> isize { unimplemented!() }) as Box<dyn FnMut
= note: expected unit type `()` = note: expected unit type `()`
found struct `Box<dyn FnMut() -> isize>` found struct `Box<dyn FnMut() -> isize>`
error[E0277]: expected a `Fn<(isize,)>` closure, found `{integer}` error[E0277]: expected a `Fn(isize)` closure, found `{integer}`
--> $DIR/fn-trait-formatting.rs:19:14 --> $DIR/fn-trait-formatting.rs:19:14
| |
LL | needs_fn(1); LL | needs_fn(1);
| -------- ^ expected an `Fn<(isize,)>` closure, found `{integer}` | -------- ^ expected an `Fn(isize)` closure, found `{integer}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -10,7 +10,7 @@ trait Fun {
impl<T> Fun for T { impl<T> Fun for T {
type F<'a> = Self; type F<'a> = Self;
//~^ ERROR expected a `Fn<()>` closure, found `T` //~^ ERROR expected a `Fn()` closure, found `T`
} }
fn main() { fn main() {

View file

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

View file

@ -10,7 +10,7 @@ trait Fun {
impl<T> Fun for T { impl<T> Fun for T {
type F<'a> = Self; type F<'a> = Self;
//~^ ERROR expected a `Fn<()>` closure, found `T` //~^ ERROR expected a `Fn()` closure, found `T`
} }
pub fn main() { pub fn main() {

View file

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

View file

@ -10,7 +10,7 @@ trait Fun {
impl<T> Fun for T { impl<T> Fun for T {
type F<'a> = Self; type F<'a> = Self;
//~^ ERROR expected a `Fn<()>` closure, found `T` //~^ ERROR expected a `Fn()` closure, found `T`
} }
fn main() { fn main() {

View file

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

View file

@ -10,7 +10,7 @@ trait Fun {
impl<T> Fun for T { impl<T> Fun for T {
type F<'a> = Self; type F<'a> = Self;
//~^ ERROR expected a `Fn<()>` closure, found `T` //~^ ERROR expected a `Fn()` closure, found `T`
} }
fn main() { fn main() {

View file

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

View file

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

View file

@ -10,5 +10,5 @@ where
fn main() { fn main() {
ice(); ice();
//[classic]~^ ERROR expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` //[classic]~^ ERROR expected a `Fn(&'w ())` closure, found `fn(&'w ())`
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` error[E0277]: expected a `Fn(<_ as ATC<'a>>::Type)` closure, found `F`
--> $DIR/issue-62529-3.rs:25:14 --> $DIR/issue-62529-3.rs:25:14
| |
LL | call(f, ()); LL | call(f, ());
| ---- ^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` | ---- ^ expected an `Fn(<_ as ATC<'a>>::Type)` closure, found `F`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -35,8 +35,8 @@ impl<'a, T: 'a> Handle<'a, T, UIView<'a, T>, Result<(), io::Error>> for TUIHandl
F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static, F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static,
{ {
real_dispatch(f) real_dispatch(f)
//~^ ERROR expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` //~^ ERROR expected a `FnOnce(&mut UIView<'_, T>)` closure, found `F`
//~| NOTE expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` //~| NOTE expected an `FnOnce(&mut UIView<'_, T>)` closure, found `F`
//~| NOTE expected a closure with arguments //~| NOTE expected a closure with arguments
//~| NOTE required by a bound introduced by this call //~| NOTE required by a bound introduced by this call
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` error[E0277]: expected a `FnOnce(&mut UIView<'_, T>)` closure, found `F`
--> $DIR/issue-100690.rs:37:23 --> $DIR/issue-100690.rs:37:23
| |
LL | real_dispatch(f) LL | real_dispatch(f)
| ------------- ^ expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` | ------------- ^ expected an `FnOnce(&mut UIView<'_, T>)` closure, found `F`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -8,8 +8,8 @@ const fn not_fn_items() {
//~^ ERROR this argument must be a function item //~^ ERROR this argument must be a function item
//~| ERROR this argument must be a function item //~| ERROR this argument must be a function item
const_eval_select((), 42, 0xDEADBEEF); const_eval_select((), 42, 0xDEADBEEF);
//~^ ERROR expected a `FnOnce<()>` closure //~^ ERROR expected a `FnOnce()` closure
//~| ERROR expected a `FnOnce<()>` closure //~| ERROR expected a `FnOnce()` closure
//~| ERROR this argument must be a function item //~| ERROR this argument must be a function item
//~| ERROR this argument must be a function item //~| ERROR this argument must be a function item
} }

View file

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

View file

@ -6,6 +6,6 @@ fn main() {
let ptr: *mut () = core::ptr::null_mut(); let ptr: *mut () = core::ptr::null_mut();
let _: &mut dyn Fn() = unsafe { let _: &mut dyn Fn() = unsafe {
&mut *(ptr as *mut dyn Fn()) &mut *(ptr as *mut dyn Fn())
//~^ ERROR expected a `Fn<()>` closure, found `()` //~^ ERROR expected a `Fn()` closure, found `()`
}; };
} }

View file

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

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnMut<(_, char)>` closure, found `()` error[E0277]: expected a `FnMut(_, char)` closure, found `()`
--> $DIR/issue-23966.rs:2:32 --> $DIR/issue-23966.rs:2:32
| |
LL | "".chars().fold(|_, _| (), ()); LL | "".chars().fold(|_, _| (), ());
| ---- ^^ expected an `FnMut<(_, char)>` closure, found `()` | ---- ^^ expected an `FnMut(_, char)` closure, found `()`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -19,5 +19,5 @@ fn main() {
let g = |(a, _)| a; let g = |(a, _)| a;
let t7 = |env| |a| |b| t7p(f, g)(((env, a), b)); let t7 = |env| |a| |b| t7p(f, g)(((env, a), b));
let t8 = t8n(t7, t7p(f, g)); let t8 = t8n(t7, t7p(f, g));
//~^ ERROR: expected a `Fn<(_,)>` closure, found `impl Fn(((_, _), _))` [E0277] //~^ ERROR: expected a `Fn(_)` closure, found `impl Fn(((_, _), _))` [E0277]
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<(_,)>` closure, found `impl Fn(((_, _), _))` error[E0277]: expected a `Fn(_)` closure, found `impl Fn(((_, _), _))`
--> $DIR/issue-59494.rs:21:22 --> $DIR/issue-59494.rs:21:22
| |
LL | let t8 = t8n(t7, t7p(f, g)); LL | let t8 = t8n(t7, t7p(f, g));
| --- ^^^^^^^^^ expected an `Fn<(_,)>` closure, found `impl Fn(((_, _), _))` | --- ^^^^^^^^^ expected an `Fn(_)` closure, found `impl Fn(((_, _), _))`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -4,14 +4,14 @@
use std::future::Future; use std::future::Future;
async fn wrapper<F>(f: F) async fn wrapper<F>(f: F)
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
where where
F:, F:,
for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
{ {
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
let mut i = 41; let mut i = 41;
&mut i; &mut i;
} }

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:1 --> $DIR/issue-76168-hr-outlives-3.rs:6:1
| |
LL | / async fn wrapper<F>(f: F) LL | / async fn wrapper<F>(f: F)
@ -8,19 +8,19 @@ LL | |
LL | | where LL | | where
LL | | F:, LL | | F:,
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
| |
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:10 --> $DIR/issue-76168-hr-outlives-3.rs:6:10
| |
LL | async fn wrapper<F>(f: F) LL | async fn wrapper<F>(f: F)
| ^^^^^^^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` | ^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
| |
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:13:1 --> $DIR/issue-76168-hr-outlives-3.rs:13:1
| |
LL | / { LL | / {
@ -28,11 +28,11 @@ LL | |
LL | | let mut i = 41; LL | | let mut i = 41;
LL | | &mut i; LL | | &mut i;
LL | | } LL | | }
| |_^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` | |_^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
| |
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:1 --> $DIR/issue-76168-hr-outlives-3.rs:6:1
| |
LL | / async fn wrapper<F>(f: F) LL | / async fn wrapper<F>(f: F)
@ -42,7 +42,7 @@ LL | |
LL | | where LL | | where
LL | | F:, LL | | F:,
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32` | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
| |
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32` = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`

View file

@ -24,9 +24,9 @@ fn main() {
let _ = produces_string().and_then(takes_str_but_too_many_refs); let _ = produces_string().and_then(takes_str_but_too_many_refs);
//~^ ERROR type mismatch in function arguments //~^ ERROR type mismatch in function arguments
let _ = produces_string().and_then(takes_str_but_wrong_abi); let _ = produces_string().and_then(takes_str_but_wrong_abi);
//~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` //~^ ERROR expected a `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
let _ = produces_string().and_then(takes_str_but_unsafe); let _ = produces_string().and_then(takes_str_but_unsafe);
//~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` //~^ ERROR expected a `FnOnce(String)` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}`
let _ = produces_string().and_then(no_args); let _ = produces_string().and_then(no_args);
//~^ ERROR function is expected to take 1 argument, but it takes 0 arguments //~^ ERROR function is expected to take 1 argument, but it takes 0 arguments
let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs);

View file

@ -14,11 +14,11 @@ LL | let _ = produces_string().and_then(takes_str_but_too_many_refs);
note: required by a bound in `Option::<T>::and_then` note: required by a bound in `Option::<T>::and_then`
--> $SRC_DIR/core/src/option.rs:LL:COL --> $SRC_DIR/core/src/option.rs:LL:COL
error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` error[E0277]: expected a `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
--> $DIR/suggest-option-asderef-unfixable.rs:26:40 --> $DIR/suggest-option-asderef-unfixable.rs:26:40
| |
LL | let _ = produces_string().and_then(takes_str_but_wrong_abi); LL | let _ = produces_string().and_then(takes_str_but_wrong_abi);
| -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` | -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -26,7 +26,7 @@ LL | let _ = produces_string().and_then(takes_str_but_wrong_abi);
note: required by a bound in `Option::<T>::and_then` note: required by a bound in `Option::<T>::and_then`
--> $SRC_DIR/core/src/option.rs:LL:COL --> $SRC_DIR/core/src/option.rs:LL:COL
error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` error[E0277]: expected a `FnOnce(String)` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}`
--> $DIR/suggest-option-asderef-unfixable.rs:28:40 --> $DIR/suggest-option-asderef-unfixable.rs:28:40
| |
LL | let _ = produces_string().and_then(takes_str_but_unsafe); LL | let _ = produces_string().and_then(takes_str_but_unsafe);

View file

@ -21,14 +21,14 @@ fn call_once(f: impl FnOnce()) {
} }
fn main() { fn main() {
call(foo); //~ ERROR expected a `Fn<()>` closure, found `fn() {foo}` call(foo); //~ ERROR expected a `Fn()` closure, found `fn() {foo}`
call_mut(foo); //~ ERROR expected a `FnMut<()>` closure, found `fn() {foo}` call_mut(foo); //~ ERROR expected a `FnMut()` closure, found `fn() {foo}`
call_once(foo); //~ ERROR expected a `FnOnce<()>` closure, found `fn() {foo}` call_once(foo); //~ ERROR expected a `FnOnce()` closure, found `fn() {foo}`
call(foo_unsafe); call(foo_unsafe);
//~^ ERROR expected a `Fn<()>` closure, found `unsafe fn() {foo_unsafe}` //~^ ERROR expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}`
call_mut(foo_unsafe); call_mut(foo_unsafe);
//~^ ERROR expected a `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` //~^ ERROR expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}`
call_once(foo_unsafe); call_once(foo_unsafe);
//~^ ERROR expected a `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` //~^ ERROR expected a `FnOnce()` closure, found `unsafe fn() {foo_unsafe}`
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<()>` closure, found `fn() {foo}` error[E0277]: expected a `Fn()` closure, found `fn() {foo}`
--> $DIR/fn-traits.rs:24:10 --> $DIR/fn-traits.rs:24:10
| |
LL | call(foo); LL | call(foo);
| ---- ^^^ expected an `Fn<()>` closure, found `fn() {foo}` | ---- ^^^ expected an `Fn()` closure, found `fn() {foo}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -15,11 +15,11 @@ note: required by a bound in `call`
LL | fn call(f: impl Fn()) { LL | fn call(f: impl Fn()) {
| ^^^^ required by this bound in `call` | ^^^^ required by this bound in `call`
error[E0277]: expected a `FnMut<()>` closure, found `fn() {foo}` error[E0277]: expected a `FnMut()` closure, found `fn() {foo}`
--> $DIR/fn-traits.rs:25:14 --> $DIR/fn-traits.rs:25:14
| |
LL | call_mut(foo); LL | call_mut(foo);
| -------- ^^^ expected an `FnMut<()>` closure, found `fn() {foo}` | -------- ^^^ expected an `FnMut()` closure, found `fn() {foo}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -32,11 +32,11 @@ note: required by a bound in `call_mut`
LL | fn call_mut(f: impl FnMut()) { LL | fn call_mut(f: impl FnMut()) {
| ^^^^^^^ required by this bound in `call_mut` | ^^^^^^^ required by this bound in `call_mut`
error[E0277]: expected a `FnOnce<()>` closure, found `fn() {foo}` error[E0277]: expected a `FnOnce()` closure, found `fn() {foo}`
--> $DIR/fn-traits.rs:26:15 --> $DIR/fn-traits.rs:26:15
| |
LL | call_once(foo); LL | call_once(foo);
| --------- ^^^ expected an `FnOnce<()>` closure, found `fn() {foo}` | --------- ^^^ expected an `FnOnce()` closure, found `fn() {foo}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -49,7 +49,7 @@ note: required by a bound in `call_once`
LL | fn call_once(f: impl FnOnce()) { LL | fn call_once(f: impl FnOnce()) {
| ^^^^^^^^ required by this bound in `call_once` | ^^^^^^^^ required by this bound in `call_once`
error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() {foo_unsafe}` error[E0277]: expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:28:10 --> $DIR/fn-traits.rs:28:10
| |
LL | call(foo_unsafe); LL | call(foo_unsafe);
@ -67,7 +67,7 @@ note: required by a bound in `call`
LL | fn call(f: impl Fn()) { LL | fn call(f: impl Fn()) {
| ^^^^ required by this bound in `call` | ^^^^ required by this bound in `call`
error[E0277]: expected a `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` error[E0277]: expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:30:14 --> $DIR/fn-traits.rs:30:14
| |
LL | call_mut(foo_unsafe); LL | call_mut(foo_unsafe);
@ -85,7 +85,7 @@ note: required by a bound in `call_mut`
LL | fn call_mut(f: impl FnMut()) { LL | fn call_mut(f: impl FnMut()) {
| ^^^^^^^ required by this bound in `call_mut` | ^^^^^^^ required by this bound in `call_mut`
error[E0277]: expected a `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` error[E0277]: expected a `FnOnce()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:32:15 --> $DIR/fn-traits.rs:32:15
| |
LL | call_once(foo_unsafe); LL | call_once(foo_unsafe);

View file

@ -2,12 +2,12 @@
fn foo(x: &str) -> bool { fn foo(x: &str) -> bool {
x.starts_with(&("hi".to_string() + " you")) x.starts_with(&("hi".to_string() + " you"))
//~^ ERROR expected a `FnMut<(char,)>` closure, found `String` //~^ ERROR expected a `FnMut(char)` closure, found `String`
} }
fn foo2(x: &str) -> bool { fn foo2(x: &str) -> bool {
x.starts_with(&"hi".to_string()) x.starts_with(&"hi".to_string())
//~^ ERROR expected a `FnMut<(char,)>` closure, found `String` //~^ ERROR expected a `FnMut(char)` closure, found `String`
} }
fn main() { fn main() {

View file

@ -2,12 +2,12 @@
fn foo(x: &str) -> bool { fn foo(x: &str) -> bool {
x.starts_with("hi".to_string() + " you") x.starts_with("hi".to_string() + " you")
//~^ ERROR expected a `FnMut<(char,)>` closure, found `String` //~^ ERROR expected a `FnMut(char)` closure, found `String`
} }
fn foo2(x: &str) -> bool { fn foo2(x: &str) -> bool {
x.starts_with("hi".to_string()) x.starts_with("hi".to_string())
//~^ ERROR expected a `FnMut<(char,)>` closure, found `String` //~^ ERROR expected a `FnMut(char)` closure, found `String`
} }
fn main() { fn main() {

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `FnMut<(char,)>` closure, found `String` error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-104961.rs:4:19 --> $DIR/issue-104961.rs:4:19
| |
LL | x.starts_with("hi".to_string() + " you") LL | x.starts_with("hi".to_string() + " you")
@ -15,7 +15,7 @@ help: consider borrowing here
LL | x.starts_with(&("hi".to_string() + " you")) LL | x.starts_with(&("hi".to_string() + " you"))
| ++ + | ++ +
error[E0277]: expected a `FnMut<(char,)>` closure, found `String` error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-104961.rs:9:19 --> $DIR/issue-104961.rs:9:19
| |
LL | x.starts_with("hi".to_string()) LL | x.starts_with("hi".to_string())

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `FnMut<(char,)>` closure, found `String` error[E0277]: expected a `FnMut(char)` closure, found `String`
--> $DIR/issue-62843.rs:4:32 --> $DIR/issue-62843.rs:4:32
| |
LL | println!("{:?}", line.find(pattern)); LL | println!("{:?}", line.find(pattern));

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut(u32)` error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut(u32)`
--> $DIR/mismatch-fn-trait.rs:4:10 --> $DIR/mismatch-fn-trait.rs:4:10
| |
LL | take(f) LL | take(f)
| ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut(u32)` | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut(u32)`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -14,11 +14,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {} LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take` | ^^^^^^^^^^ required by this bound in `take`
error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut(i32, i32)` error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut(i32, i32)`
--> $DIR/mismatch-fn-trait.rs:9:10 --> $DIR/mismatch-fn-trait.rs:9:10
| |
LL | take(f) LL | take(f)
| ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut(i32, i32)` | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut(i32, i32)`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -29,11 +29,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {} LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take` | ^^^^^^^^^^ required by this bound in `take`
error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnMut()` error[E0277]: expected a `FnMut(i32)` closure, found `impl FnMut()`
--> $DIR/mismatch-fn-trait.rs:14:10 --> $DIR/mismatch-fn-trait.rs:14:10
| |
LL | take(f) LL | take(f)
| ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnMut()` | ---- ^ expected an `FnMut(i32)` closure, found `impl FnMut()`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -44,11 +44,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {} LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take` | ^^^^^^^^^^ required by this bound in `take`
error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnOnce(i32)` error[E0277]: expected a `FnMut(i32)` closure, found `impl FnOnce(i32)`
--> $DIR/mismatch-fn-trait.rs:19:10 --> $DIR/mismatch-fn-trait.rs:19:10
| |
LL | take(f) LL | take(f)
| ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnOnce(i32)` | ---- ^ expected an `FnMut(i32)` closure, found `impl FnOnce(i32)`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -59,11 +59,11 @@ note: required by a bound in `take`
LL | fn take(_f: impl FnMut(i32)) {} LL | fn take(_f: impl FnMut(i32)) {}
| ^^^^^^^^^^ required by this bound in `take` | ^^^^^^^^^^ required by this bound in `take`
error[E0277]: expected a `FnMut<(i32,)>` closure, found `impl FnOnce(u32)` error[E0277]: expected a `FnMut(i32)` closure, found `impl FnOnce(u32)`
--> $DIR/mismatch-fn-trait.rs:24:10 --> $DIR/mismatch-fn-trait.rs:24:10
| |
LL | take(f) LL | take(f)
| ---- ^ expected an `FnMut<(i32,)>` closure, found `impl FnOnce(u32)` | ---- ^ expected an `FnMut(i32)` closure, found `impl FnOnce(u32)`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -11,5 +11,5 @@ fn f<T: for<'r> X<'r> + ?Sized>() {
fn main() { fn main() {
f::<dyn for<'x> X<'x, F = i32>>(); f::<dyn for<'x> X<'x, F = i32>>();
//~^ expected a `FnOnce<(&i32,)>` closure, found `i32` //~^ expected a `FnOnce(&i32)` closure, found `i32`
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnOnce<(&i32,)>` closure, found `i32` error[E0277]: expected a `FnOnce(&i32)` closure, found `i32`
--> $DIR/check-trait-object-bounds-2.rs:13:9 --> $DIR/check-trait-object-bounds-2.rs:13:9
| |
LL | f::<dyn for<'x> X<'x, F = i32>>(); LL | f::<dyn for<'x> X<'x, F = i32>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&i32,)>` closure, found `i32` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&i32)` closure, found `i32`
| |
= help: the trait `for<'a> FnOnce<(&'a i32,)>` is not implemented for `i32` = help: the trait `for<'a> FnOnce<(&'a i32,)>` is not implemented for `i32`
note: required by a bound in `f` note: required by a bound in `f`

View file

@ -1,7 +1,7 @@
fn strip_lf(s: &str) -> &str { fn strip_lf(s: &str) -> &str {
s.strip_suffix(b'\n').unwrap_or(s) s.strip_suffix(b'\n').unwrap_or(s)
//~^ ERROR expected a `FnMut<(char,)>` closure, found `u8` //~^ ERROR expected a `FnMut(char)` closure, found `u8`
//~| NOTE expected an `FnMut<(char,)>` closure, found `u8` //~| NOTE expected an `FnMut(char)` closure, found `u8`
//~| HELP the trait `FnMut<(char,)>` is not implemented for `u8` //~| HELP the trait `FnMut<(char,)>` is not implemented for `u8`
//~| HELP the following other types implement trait `Pattern<'a>`: //~| HELP the following other types implement trait `Pattern<'a>`:
//~| NOTE required for `u8` to implement `Pattern<'_>` //~| NOTE required for `u8` to implement `Pattern<'_>`

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `FnMut<(char,)>` closure, found `u8` error[E0277]: expected a `FnMut(char)` closure, found `u8`
--> $DIR/assoc-fn-bound-root-obligation.rs:2:7 --> $DIR/assoc-fn-bound-root-obligation.rs:2:7
| |
LL | s.strip_suffix(b'\n').unwrap_or(s) LL | s.strip_suffix(b'\n').unwrap_or(s)
| ^^^^^^^^^^^^ expected an `FnMut<(char,)>` closure, found `u8` | ^^^^^^^^^^^^ expected an `FnMut(char)` closure, found `u8`
| |
= help: the trait `FnMut<(char,)>` is not implemented for `u8` = help: the trait `FnMut<(char,)>` is not implemented for `u8`
= help: the following other types implement trait `Pattern<'a>`: = help: the following other types implement trait `Pattern<'a>`:

View file

@ -18,15 +18,15 @@ fn main() {
require_fn(f); require_fn(f);
require_fn(f as fn() -> i32); require_fn(f as fn() -> i32);
require_fn(f as unsafe fn() -> i32); require_fn(f as unsafe fn() -> i32);
//~^ ERROR: expected a `Fn<()>` closure, found `unsafe fn() -> i32` //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32`
//~| ERROR: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32` //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32`
require_fn(g); require_fn(g);
//~^ ERROR: expected a `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32 {g}`
//~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32` //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32`
require_fn(g as extern "C" fn() -> i32); require_fn(g as extern "C" fn() -> i32);
//~^ ERROR: expected a `Fn<()>` closure, found `extern "C" fn() -> i32` //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32`
//~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32` //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32`
require_fn(h); require_fn(h);
//~^ ERROR: expected a `Fn<()>` closure, found `unsafe fn() -> i32 {h}` //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32 {h}`
//~| ERROR: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32` //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32`
} }

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() -> i32` error[E0277]: expected a `Fn()` closure, found `unsafe fn() -> i32`
--> $DIR/fn-trait.rs:20:16 --> $DIR/fn-trait.rs:20:16
| |
LL | require_fn(f as unsafe fn() -> i32); LL | require_fn(f as unsafe fn() -> i32);
@ -29,11 +29,11 @@ note: required by a bound in `require_fn`
LL | fn require_fn(_: impl Fn() -> i32) {} LL | fn require_fn(_: impl Fn() -> i32) {}
| ^^^ required by this bound in `require_fn` | ^^^ required by this bound in `require_fn`
error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` error[E0277]: expected a `Fn()` closure, found `extern "C" fn() -> i32 {g}`
--> $DIR/fn-trait.rs:23:16 --> $DIR/fn-trait.rs:23:16
| |
LL | require_fn(g); LL | require_fn(g);
| ---------- ^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` | ---------- ^ expected an `Fn()` closure, found `extern "C" fn() -> i32 {g}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -59,11 +59,11 @@ note: required by a bound in `require_fn`
LL | fn require_fn(_: impl Fn() -> i32) {} LL | fn require_fn(_: impl Fn() -> i32) {}
| ^^^ required by this bound in `require_fn` | ^^^ required by this bound in `require_fn`
error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32` error[E0277]: expected a `Fn()` closure, found `extern "C" fn() -> i32`
--> $DIR/fn-trait.rs:26:16 --> $DIR/fn-trait.rs:26:16
| |
LL | require_fn(g as extern "C" fn() -> i32); LL | require_fn(g as extern "C" fn() -> i32);
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32` | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn()` closure, found `extern "C" fn() -> i32`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -89,7 +89,7 @@ note: required by a bound in `require_fn`
LL | fn require_fn(_: impl Fn() -> i32) {} LL | fn require_fn(_: impl Fn() -> i32) {}
| ^^^ required by this bound in `require_fn` | ^^^ required by this bound in `require_fn`
error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() -> i32 {h}` error[E0277]: expected a `Fn()` closure, found `unsafe fn() -> i32 {h}`
--> $DIR/fn-trait.rs:29:16 --> $DIR/fn-trait.rs:29:16
| |
LL | require_fn(h); LL | require_fn(h);

View file

@ -4,7 +4,7 @@ fn get_vowel_count(string: &str) -> usize {
string string
.chars() .chars()
.filter(|c| "aeiou".contains(*c)) .filter(|c| "aeiou".contains(*c))
//~^ ERROR expected a `Fn<(char,)>` closure, found `char` //~^ ERROR expected a `Fn(char)` closure, found `char`
.count() .count()
} }

View file

@ -4,7 +4,7 @@ fn get_vowel_count(string: &str) -> usize {
string string
.chars() .chars()
.filter(|c| "aeiou".contains(c)) .filter(|c| "aeiou".contains(c))
//~^ ERROR expected a `Fn<(char,)>` closure, found `char` //~^ ERROR expected a `Fn(char)` closure, found `char`
.count() .count()
} }

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<(char,)>` closure, found `char` error[E0277]: expected a `Fn(char)` closure, found `char`
--> $DIR/root-obligation.rs:6:38 --> $DIR/root-obligation.rs:6:38
| |
LL | .filter(|c| "aeiou".contains(c)) LL | .filter(|c| "aeiou".contains(c))
| -------- ^ expected an `Fn<(char,)>` closure, found `char` | -------- ^ expected an `Fn(char)` closure, found `char`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -3,11 +3,11 @@
type Closure = impl FnOnce(); type Closure = impl FnOnce();
fn c() -> Closure { fn c() -> Closure {
//~^ ERROR: expected a `FnOnce<()>` closure, found `()` //~^ ERROR: expected a `FnOnce()` closure, found `()`
|| -> Closure { || () } || -> Closure { || () }
//~^ ERROR: mismatched types //~^ ERROR: mismatched types
//~| ERROR: mismatched types //~| ERROR: mismatched types
//~| ERROR: expected a `FnOnce<()>` closure, found `()` //~| ERROR: expected a `FnOnce()` closure, found `()`
} }
fn main() {} fn main() {}

View file

@ -1,17 +1,17 @@
error[E0277]: expected a `FnOnce<()>` closure, found `()` error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:5:11 --> $DIR/issue-63279.rs:5:11
| |
LL | fn c() -> Closure { LL | fn c() -> Closure {
| ^^^^^^^ expected an `FnOnce<()>` closure, found `()` | ^^^^^^^ expected an `FnOnce()` closure, found `()`
| |
= help: the trait `FnOnce<()>` is not implemented for `()` = help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
error[E0277]: expected a `FnOnce<()>` closure, found `()` error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:7:11 --> $DIR/issue-63279.rs:7:11
| |
LL | || -> Closure { || () } LL | || -> Closure { || () }
| ^^^^^^^ expected an `FnOnce<()>` closure, found `()` | ^^^^^^^ expected an `FnOnce()` closure, found `()`
| |
= help: the trait `FnOnce<()>` is not implemented for `()` = help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<(isize,)>` closure, found `S` error[E0277]: expected a `Fn(isize)` closure, found `S`
--> $DIR/unboxed-closures-fnmut-as-fn.rs:27:21 --> $DIR/unboxed-closures-fnmut-as-fn.rs:27:21
| |
LL | let x = call_it(&S, 22); LL | let x = call_it(&S, 22);
| ------- ^^ expected an `Fn<(isize,)>` closure, found `S` | ------- ^^ expected an `Fn(isize)` closure, found `S`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `Fn<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` error[E0277]: expected a `Fn(&isize)` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21 --> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21
| |
LL | let x = call_it(&square, 22); LL | let x = call_it(&square, 22);
@ -14,7 +14,7 @@ note: required by a bound in `call_it`
LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize { LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` | ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it`
error[E0277]: expected a `FnMut<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` error[E0277]: expected a `FnMut(&isize)` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25 --> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25
| |
LL | let y = call_it_mut(&mut square, 22); LL | let y = call_it_mut(&mut square, 22);
@ -30,7 +30,7 @@ note: required by a bound in `call_it_mut`
LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize { LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut`
error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` error[E0277]: expected a `FnOnce(&isize)` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26 --> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26
| |
LL | let z = call_it_once(square, 22); LL | let z = call_it_once(square, 22);

View file

@ -1,8 +1,8 @@
error[E0277]: expected a `Fn<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` error[E0277]: expected a `Fn(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-abi.rs:20:21 --> $DIR/unboxed-closures-wrong-abi.rs:20:21
| |
LL | let x = call_it(&square, 22); LL | let x = call_it(&square, 22);
| ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` | ------- ^^^^^^^ expected an `Fn(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -13,11 +13,11 @@ note: required by a bound in `call_it`
LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize { LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` | ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it`
error[E0277]: expected a `FnMut<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` error[E0277]: expected a `FnMut(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-abi.rs:25:25 --> $DIR/unboxed-closures-wrong-abi.rs:25:25
| |
LL | let y = call_it_mut(&mut square, 22); LL | let y = call_it_mut(&mut square, 22);
| ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` | ----------- ^^^^^^^^^^^ expected an `FnMut(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |
@ -28,11 +28,11 @@ note: required by a bound in `call_it_mut`
LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize { LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut`
error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` error[E0277]: expected a `FnOnce(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-abi.rs:30:26 --> $DIR/unboxed-closures-wrong-abi.rs:30:26
| |
LL | let z = call_it_once(square, 22); LL | let z = call_it_once(square, 22);
| ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` | ------------ ^^^^^^ expected an `FnOnce(&isize)` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}`
| | | |
| required by a bound introduced by this call | required by a bound introduced by this call
| |

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` error[E0277]: expected a `Fn(&isize)` closure, found `unsafe fn(isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:21:21 --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:21:21
| |
LL | let x = call_it(&square, 22); LL | let x = call_it(&square, 22);
@ -14,7 +14,7 @@ note: required by a bound in `call_it`
LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize { LL | fn call_it<F: Fn(&isize) -> isize>(_: &F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` | ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it`
error[E0277]: expected a `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` error[E0277]: expected a `FnMut(&isize)` closure, found `unsafe fn(isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:26:25 --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:26:25
| |
LL | let y = call_it_mut(&mut square, 22); LL | let y = call_it_mut(&mut square, 22);
@ -30,7 +30,7 @@ note: required by a bound in `call_it_mut`
LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize { LL | fn call_it_mut<F: FnMut(&isize) -> isize>(_: &mut F, _: isize) -> isize {
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut`
error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` error[E0277]: expected a `FnOnce(&isize)` closure, found `unsafe fn(isize) -> isize {square}`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:31:26 --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:31:26
| |
LL | let z = call_it_once(square, 22); LL | let z = call_it_once(square, 22);

View file

@ -1,4 +1,4 @@
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `unsafe fn(u8) -> NonZeroAndOneU8 {NonZeroAndOneU8}` error[E0277]: expected a `FnOnce({integer})` closure, found `unsafe fn(u8) -> NonZeroAndOneU8 {NonZeroAndOneU8}`
--> $DIR/initializing-ranged-via-ctor.rs:9:34 --> $DIR/initializing-ranged-via-ctor.rs:9:34
| |
LL | println!("{:?}", Some(1).map(NonZeroAndOneU8).unwrap()); LL | println!("{:?}", Some(1).map(NonZeroAndOneU8).unwrap());