From fe5d39701e38aa43afa16036e8dcca1c2eab9784 Mon Sep 17 00:00:00 2001 From: "HTGAzureX1212." <39023054+HTGAzureX1212@users.noreply.github.com> Date: Sun, 21 Jan 2024 20:28:16 +0800 Subject: [PATCH] enhance diagnostic emitted for E0617 in missing cast for variadic arg tidy fix compiler error fix compiler error round 2 tweak fndef pretty print fmt shorten the pretty-print output add a ui test specifically for linked issue 69232 Implement suggestion Co-authored-by: Esteban Kuber fix compiler errors rebless tests --- .../missing_cast_for_variadic_arg.rs | 16 +++- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- tests/ui/asm/x86_64/type-check-2.rs | 2 +- tests/ui/asm/x86_64/type-check-2.stderr | 2 +- .../substs-ppaux.normal.stderr | 8 +- tests/ui/associated-types/substs-ppaux.rs | 16 ++-- .../substs-ppaux.verbose.stderr | 8 +- ...-tracking-unresolved-typeck-results.stderr | 4 +- tests/ui/binop/issue-77910-1.rs | 2 +- tests/ui/binop/issue-77910-1.stderr | 10 +-- tests/ui/binop/issue-77910-2.stderr | 4 +- tests/ui/c-variadic/issue-32201.rs | 6 +- tests/ui/c-variadic/issue-32201.stderr | 15 +++- tests/ui/c-variadic/issue-69232.rs | 12 +++ tests/ui/c-variadic/issue-69232.stderr | 20 +++++ tests/ui/c-variadic/variadic-ffi-1.stderr | 66 +++++++++++++++-- tests/ui/cast/cast-as-bool.rs | 4 +- tests/ui/cast/cast-as-bool.stderr | 4 +- tests/ui/cast/cast-to-bare-fn.stderr | 2 +- .../closure_cap_coerce_many_fail.stderr | 4 +- .../closures/coerce-unsafe-to-closure.stderr | 4 +- .../adt_const_params/const_param_ty_bad.rs | 2 +- .../const_param_ty_bad.stderr | 4 +- .../generic_const_exprs/eval-privacy.stderr | 4 +- tests/ui/error-codes/E0617.rs | 9 ++- tests/ui/error-codes/E0617.stderr | 73 ++++++++++++++++--- tests/ui/expr/if/if-typeck.stderr | 2 +- .../missing_block_in_fn_call.stderr | 2 +- .../ruby_style_closure_parse_error.stderr | 2 +- tests/ui/extern/extern-wrong-value-type.rs | 2 +- .../ui/extern/extern-wrong-value-type.stderr | 8 +- tests/ui/fn/fn-compare-mismatch.stderr | 6 +- tests/ui/fn/fn-pointer-mismatch.stderr | 6 +- .../higher-ranked-lifetime-error.stderr | 4 +- .../trait-bounds/issue-30786.stderr | 8 +- tests/ui/hygiene/impl_items.rs | 2 +- tests/ui/hygiene/impl_items.stderr | 2 +- tests/ui/hygiene/intercrate.rs | 2 +- tests/ui/hygiene/intercrate.stderr | 2 +- tests/ui/inline-const/pat-match-fndef.rs | 2 +- tests/ui/inline-const/pat-match-fndef.stderr | 2 +- tests/ui/issues/issue-21554.stderr | 2 +- tests/ui/issues/issue-24322.stderr | 2 +- tests/ui/issues/issue-35241.stderr | 2 +- tests/ui/issues/issue-59488.rs | 14 ++-- tests/ui/issues/issue-59488.stderr | 42 +++++------ tests/ui/issues/issue-62375.stderr | 6 +- .../issue-66667-function-cmp-cycle.stderr | 18 ++--- ...70724-add_type_neq_err_label-unwrap.stderr | 12 +-- tests/ui/issues/issue-87490.stderr | 2 +- .../lifetime-errors/issue_74400.stderr | 2 +- .../lifetimes/unusual-rib-combinations.stderr | 2 +- tests/ui/lint/issue-106991.stderr | 2 +- tests/ui/lint/ptr_null_checks.stderr | 20 ++--- tests/ui/lint/trivial_casts.rs | 2 +- tests/ui/lint/trivial_casts.stderr | 2 +- tests/ui/match/issue-82392.stdout | 4 +- tests/ui/mismatched_types/cast-rfc0401.stderr | 6 +- .../suggest-option-asderef-unfixable.rs | 4 +- .../suggest-option-asderef-unfixable.stderr | 10 +-- tests/ui/namespace/namespace-mix.stderr | 16 ++-- .../associated-item-privacy-inherent.rs | 6 +- .../associated-item-privacy-inherent.stderr | 6 +- .../privacy/associated-item-privacy-trait.rs | 6 +- .../associated-item-privacy-trait.stderr | 6 +- tests/ui/privacy/private-inferred-type-3.rs | 10 +-- .../ui/privacy/private-inferred-type-3.stderr | 10 +-- tests/ui/privacy/private-inferred-type.rs | 10 +-- tests/ui/privacy/private-inferred-type.stderr | 10 +-- tests/ui/privacy/where-priv-type.stderr | 4 +- .../ui/qualified/qualified-path-params.stderr | 2 +- tests/ui/reify-intrinsic.stderr | 2 +- tests/ui/resolve/privacy-enum-ctor.stderr | 6 +- .../ui/rfcs/rfc-1623-static/rfc1623-2.stderr | 4 +- .../ui/rfcs/rfc-1623-static/rfc1623-3.stderr | 2 +- .../rfc-2396-target_feature-11/fn-traits.rs | 12 +-- .../fn-traits.stderr | 42 +++++------ tests/ui/static/issue-5216.stderr | 4 +- .../ui/static/static-reference-to-fn-1.stderr | 2 +- .../assoc-ct-for-assoc-method.stderr | 8 +- ...rg-where-it-should-have-been-called.stderr | 8 +- tests/ui/suggestions/call-on-missing.stderr | 6 +- .../suggestions/call-on-unimplemented-ctor.rs | 2 +- .../call-on-unimplemented-ctor.stderr | 4 +- ...rg-where-it-should-have-been-called.stderr | 4 +- .../fn-or-tuple-struct-without-args.stderr | 26 +++---- tests/ui/suggestions/issue-107860.stderr | 4 +- tests/ui/suggestions/issue-109854.stderr | 2 +- .../suggest-call-on-pat-mismatch.stderr | 8 +- .../ui/traits/fn-trait-cast-diagnostic.stderr | 8 +- tests/ui/traits/issue-99875.stderr | 4 +- tests/ui/traits/next-solver/fn-trait.rs | 8 +- tests/ui/traits/next-solver/fn-trait.stderr | 18 ++--- tests/ui/traits/unsend-future.stderr | 2 +- .../transmute-from-fn-item-types-error.stderr | 18 ++--- .../type-alias-impl-trait/issue-98604.stderr | 2 +- .../type-alias-impl-trait/issue-98608.stderr | 2 +- tests/ui/typeck/escaping_bound_vars.stderr | 6 +- tests/ui/typeck/issue-107775.stderr | 4 +- tests/ui/typeck/issue-29124.stderr | 8 +- .../typeck/issue-87181/empty-tuple-method.rs | 2 +- .../issue-87181/empty-tuple-method.stderr | 4 +- tests/ui/typeck/issue-87181/enum-variant.rs | 2 +- .../ui/typeck/issue-87181/enum-variant.stderr | 4 +- tests/ui/typeck/issue-87181/tuple-field.rs | 2 +- .../ui/typeck/issue-87181/tuple-field.stderr | 2 +- tests/ui/typeck/issue-87181/tuple-method.rs | 2 +- .../ui/typeck/issue-87181/tuple-method.stderr | 4 +- tests/ui/typeck/issue-96738.stderr | 6 +- tests/ui/typeck/while-type-error.stderr | 2 +- .../unboxed-closures-unsafe-extern-fn.stderr | 12 +-- .../unboxed-closures-wrong-abi.stderr | 18 ++--- ...d-closures-wrong-arg-type-extern-fn.stderr | 12 +-- .../ui/unsafe/initializing-ranged-via-ctor.rs | 2 +- .../initializing-ranged-via-ctor.stderr | 4 +- 115 files changed, 535 insertions(+), 364 deletions(-) create mode 100644 tests/ui/c-variadic/issue-69232.rs create mode 100644 tests/ui/c-variadic/issue-69232.stderr diff --git a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs index 50b4ef623ac7e..b295e3a7a6182 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs @@ -1,5 +1,5 @@ use crate::{errors, structured_errors::StructuredDiagnostic}; -use rustc_errors::{codes::*, DiagnosticBuilder, ErrCode}; +use rustc_errors::{codes::*, Applicability, DiagnosticBuilder, ErrCode}; use rustc_middle::ty::{Ty, TypeVisitableExt}; use rustc_session::Session; use rustc_span::Span; @@ -41,6 +41,20 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx, '_> { err.downgrade_to_delayed_bug(); } + let msg = if self.ty.is_fn() { + err.help("a function item is zero-sized and needs to be casted into a function pointer to be used in FFI") + .note("for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html"); + "cast the value into a function pointer".to_string() + } else { + format!("cast the value to `{}`", self.cast_ty) + }; + err.span_suggestion_verbose( + self.span.shrink_to_hi(), + msg, + format!(" as {}", self.cast_ty), + Applicability::MachineApplicable, + ); + err } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index c0bfd2380ade0..465474bd2d0f7 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -663,7 +663,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!(print_def_path(def_id, args)); } else { let sig = self.tcx().fn_sig(def_id).instantiate(self.tcx(), args); - p!(print(sig), " {{", print_value_path(def_id, args), "}}"); + p!("{{fn item ", print_value_path(def_id, args), ": ", print(sig), "}}"); } } ty::FnPtr(ref bare_fn) => p!(print(bare_fn)), diff --git a/tests/ui/asm/x86_64/type-check-2.rs b/tests/ui/asm/x86_64/type-check-2.rs index 80b29ec870fc1..fd49f8a4c02ea 100644 --- a/tests/ui/asm/x86_64/type-check-2.rs +++ b/tests/ui/asm/x86_64/type-check-2.rs @@ -64,7 +64,7 @@ fn main() { let mut r = &mut 0; asm!("{}", in(reg) f); asm!("{}", inout(reg) f); - //~^ ERROR cannot use value of type `fn() {main}` for inline assembly + //~^ ERROR cannot use value of type `{fn item main: fn()}` for inline assembly asm!("{}", in(reg) r); asm!("{}", inout(reg) r); //~^ ERROR cannot use value of type `&mut i32` for inline assembly diff --git a/tests/ui/asm/x86_64/type-check-2.stderr b/tests/ui/asm/x86_64/type-check-2.stderr index 4f3d5100af056..fc7521e6f1a85 100644 --- a/tests/ui/asm/x86_64/type-check-2.stderr +++ b/tests/ui/asm/x86_64/type-check-2.stderr @@ -63,7 +63,7 @@ LL | asm!("{}", in(reg) [1, 2, 3]); | = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly -error: cannot use value of type `fn() {main}` for inline assembly +error: cannot use value of type `{fn item main: fn()}` for inline assembly --> $DIR/type-check-2.rs:66:31 | LL | asm!("{}", inout(reg) f); diff --git a/tests/ui/associated-types/substs-ppaux.normal.stderr b/tests/ui/associated-types/substs-ppaux.normal.stderr index 93118616f02c7..6d902b5b8e36d 100644 --- a/tests/ui/associated-types/substs-ppaux.normal.stderr +++ b/tests/ui/associated-types/substs-ppaux.normal.stderr @@ -10,7 +10,7 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::<'static, char>}` + found fn item `{fn item >::bar::<'static, char>: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); @@ -28,7 +28,7 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::<'static, char>}` + found fn item `{fn item >::bar::<'static, char>: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); @@ -46,7 +46,7 @@ LL | let x: () = >::baz; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::baz}` + found fn item `{fn item >::baz: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::baz(); @@ -64,7 +64,7 @@ LL | let x: () = foo::<'static>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {foo::<'static>}` + found fn item `{fn item foo::<'static>: fn()}` help: use parentheses to call this function | LL | let x: () = foo::<'static>(); diff --git a/tests/ui/associated-types/substs-ppaux.rs b/tests/ui/associated-types/substs-ppaux.rs index db6e7a4cf051f..44c5a76f3d187 100644 --- a/tests/ui/associated-types/substs-ppaux.rs +++ b/tests/ui/associated-types/substs-ppaux.rs @@ -16,35 +16,35 @@ fn foo<'z>() where &'z (): Sized { let x: () = >::bar::<'static, char>; //[verbose]~^ ERROR mismatched types //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::bar::}` + //[verbose]~| found fn item `{fn item >::bar::: fn()}` //[normal]~^^^^ ERROR mismatched types //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::bar::<'static, char>}` + //[normal]~| found fn item `{fn item >::bar::<'static, char>: fn()}` let x: () = >::bar::<'static, char>; //[verbose]~^ ERROR mismatched types //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::bar::}` + //[verbose]~| found fn item `{fn item >::bar::: fn()}` //[normal]~^^^^ ERROR mismatched types //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::bar::<'static, char>}` + //[normal]~| found fn item `{fn item >::bar::<'static, char>: fn()}` let x: () = >::baz; //[verbose]~^ ERROR mismatched types //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::baz}` + //[verbose]~| found fn item `{fn item >::baz: fn()}` //[normal]~^^^^ ERROR mismatched types //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::baz}` + //[normal]~| found fn item `{fn item >::baz: fn()}` let x: () = foo::<'static>; //[verbose]~^ ERROR mismatched types //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {foo::}` + //[verbose]~| found fn item `{fn item foo::: fn()}` //[normal]~^^^^ ERROR mismatched types //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {foo::<'static>}` + //[normal]~| found fn item `{fn item foo::<'static>: fn()}` >::bar; //[verbose]~^ ERROR the size for values of type diff --git a/tests/ui/associated-types/substs-ppaux.verbose.stderr b/tests/ui/associated-types/substs-ppaux.verbose.stderr index 13d3156fb8018..caa0ba73928b3 100644 --- a/tests/ui/associated-types/substs-ppaux.verbose.stderr +++ b/tests/ui/associated-types/substs-ppaux.verbose.stderr @@ -10,7 +10,7 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::}` + found fn item `{fn item >::bar::: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); @@ -28,7 +28,7 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::}` + found fn item `{fn item >::bar::: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); @@ -46,7 +46,7 @@ LL | let x: () = >::baz; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::baz}` + found fn item `{fn item >::baz: fn()}` help: use parentheses to call this associated function | LL | let x: () = >::baz(); @@ -64,7 +64,7 @@ LL | let x: () = foo::<'static>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {foo::}` + found fn item `{fn item foo::: fn()}` help: use parentheses to call this function | LL | let x: () = foo::<'static>(); diff --git a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr index 0d3ee8a93776b..4ee258de11f0a 100644 --- a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr +++ b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr @@ -8,7 +8,7 @@ LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrde LL | | }); | |______^ implementation of `FnOnce` is not general enough | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: `{fn item std::future::ready::<&'0 ()>: fn(&'0 ()) -> std::future::Ready<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `FnOnce` is not general enough @@ -21,7 +21,7 @@ LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrde LL | | }); | |______^ implementation of `FnOnce` is not general enough | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: `{fn item std::future::ready::<&'0 ()>: fn(&'0 ()) -> std::future::Ready<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&(),)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/binop/issue-77910-1.rs b/tests/ui/binop/issue-77910-1.rs index 95bbd6a60ec86..e98be33a0ef27 100644 --- a/tests/ui/binop/issue-77910-1.rs +++ b/tests/ui/binop/issue-77910-1.rs @@ -7,5 +7,5 @@ fn main() { // we shouldn't ice with the bound var here. assert_eq!(foo, y); //~^ ERROR binary operation `==` cannot be applied to type - //~| ERROR `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug` + //~| ERROR `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` doesn't implement `Debug` } diff --git a/tests/ui/binop/issue-77910-1.stderr b/tests/ui/binop/issue-77910-1.stderr index 263a35d982911..4fa42f6dc98c1 100644 --- a/tests/ui/binop/issue-77910-1.stderr +++ b/tests/ui/binop/issue-77910-1.stderr @@ -1,24 +1,24 @@ -error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` --> $DIR/issue-77910-1.rs:8:5 | LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ | | - | for<'a> fn(&'a i32) -> &'a i32 {foo} + | {fn item foo: for<'a> fn(&'a i32) -> &'a i32} | _ | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug` +error[E0277]: `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` doesn't implement `Debug` --> $DIR/issue-77910-1.rs:8:5 | LL | fn foo(s: &i32) -> &i32 { | --- consider calling this function ... LL | assert_eq!(foo, y); - | ^^^^^^^^^^^^^^^^^^ `for<'a> fn(&'a i32) -> &'a i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^ `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` + = help: the trait `Debug` is not implemented for fn item `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` = help: use parentheses to call this function: `foo(/* &i32 */)` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/binop/issue-77910-2.stderr b/tests/ui/binop/issue-77910-2.stderr index e58ae0fad9b4d..38aa6c50378c7 100644 --- a/tests/ui/binop/issue-77910-2.stderr +++ b/tests/ui/binop/issue-77910-2.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item foo: for<'a> fn(&'a i32) -> &'a i32}` --> $DIR/issue-77910-2.rs:7:12 | LL | if foo == y {} | --- ^^ - _ | | - | for<'a> fn(&'a i32) -> &'a i32 {foo} + | {fn item foo: for<'a> fn(&'a i32) -> &'a i32} | help: use parentheses to call this function | diff --git a/tests/ui/c-variadic/issue-32201.rs b/tests/ui/c-variadic/issue-32201.rs index f27bb1c2eb5b6..044925d4566d4 100644 --- a/tests/ui/c-variadic/issue-32201.rs +++ b/tests/ui/c-variadic/issue-32201.rs @@ -7,7 +7,9 @@ fn bar(_: *const u8) {} fn main() { unsafe { foo(0, bar); - //~^ ERROR can't pass `fn(*const u8) {bar}` to variadic function - //~| HELP cast the value to `fn(*const u8)` + //~^ ERROR can't pass `{fn item bar: fn(*const u8)}` to variadic function + //~| HELP a function item is zero-sized and needs to be casted into a function pointer to be used in FFI + //~| HELP cast the value into a function pointer + //~| HELP cast the value to `fn(*const u8) } } diff --git a/tests/ui/c-variadic/issue-32201.stderr b/tests/ui/c-variadic/issue-32201.stderr index 352db9f62f6d8..d902491e6e34e 100644 --- a/tests/ui/c-variadic/issue-32201.stderr +++ b/tests/ui/c-variadic/issue-32201.stderr @@ -1,8 +1,19 @@ -error[E0617]: can't pass `fn(*const u8) {bar}` to variadic function +error[E0617]: can't pass `{fn item bar: fn(*const u8)}` to variadic function --> $DIR/issue-32201.rs:9:16 | LL | foo(0, bar); - | ^^^ help: cast the value to `fn(*const u8)`: `bar as fn(*const u8)` + | ^^^ + | + = help: a function item is zero-sized and needs to be casted into a function pointer to be used in FFI + = note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html +help: cast the value to `fn(*const u8)` + | +LL | foo(0, bar as fn(*const u8)); + | ~~~~~~~~~~~~~~~~~~~~ +help: cast the value into a function pointer + | +LL | foo(0, bar as fn(*const u8)); + | ++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/c-variadic/issue-69232.rs b/tests/ui/c-variadic/issue-69232.rs new file mode 100644 index 0000000000000..cbc954ddfb391 --- /dev/null +++ b/tests/ui/c-variadic/issue-69232.rs @@ -0,0 +1,12 @@ +extern "C" { + fn foo(x: usize, ...); +} + +fn test() -> u8 { + 127 +} + +fn main() { + foo(1, test); + //~^ ERROR can't pass `{fn item test: fn() -> u8}` to variadic function +} diff --git a/tests/ui/c-variadic/issue-69232.stderr b/tests/ui/c-variadic/issue-69232.stderr new file mode 100644 index 0000000000000..4c34e58bc1793 --- /dev/null +++ b/tests/ui/c-variadic/issue-69232.stderr @@ -0,0 +1,20 @@ +error[E0617]: can't pass `{fn item test: fn() -> u8}` to variadic function + --> $DIR/issue-69232.rs:10:12 + | +LL | foo(1, test); + | ^^^^ + | + = help: a function item is zero-sized and needs to be casted into a function pointer to be used in FFI + = note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html +help: cast the value to `fn() -> u8` + | +LL | foo(1, test as fn() -> u8); + | ~~~~~~~~~~~~~~~~~~ +help: cast the value into a function pointer + | +LL | foo(1, test as fn() -> u8); + | +++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0617`. diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index 4beea83d8a528..82c4871e26519 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -62,37 +62,91 @@ error[E0617]: can't pass `f32` to variadic function --> $DIR/variadic-ffi-1.rs:28:19 | LL | foo(1, 2, 3f32); - | ^^^^ help: cast the value to `c_double`: `3f32 as c_double` + | ^^^^ + | +help: cast the value to `c_double` + | +LL | foo(1, 2, 3f32 as c_double); + | ~~~~~~~~~~~~~~~~ +help: cast the value to `c_double` + | +LL | foo(1, 2, 3f32 as c_double); + | +++++++++++ error[E0617]: can't pass `bool` to variadic function --> $DIR/variadic-ffi-1.rs:29:19 | LL | foo(1, 2, true); - | ^^^^ help: cast the value to `c_int`: `true as c_int` + | ^^^^ + | +help: cast the value to `c_int` + | +LL | foo(1, 2, true as c_int); + | ~~~~~~~~~~~~~ +help: cast the value to `c_int` + | +LL | foo(1, 2, true as c_int); + | ++++++++ error[E0617]: can't pass `i8` to variadic function --> $DIR/variadic-ffi-1.rs:30:19 | LL | foo(1, 2, 1i8); - | ^^^ help: cast the value to `c_int`: `1i8 as c_int` + | ^^^ + | +help: cast the value to `c_int` + | +LL | foo(1, 2, 1i8 as c_int); + | ~~~~~~~~~~~~ +help: cast the value to `c_int` + | +LL | foo(1, 2, 1i8 as c_int); + | ++++++++ error[E0617]: can't pass `u8` to variadic function --> $DIR/variadic-ffi-1.rs:31:19 | LL | foo(1, 2, 1u8); - | ^^^ help: cast the value to `c_uint`: `1u8 as c_uint` + | ^^^ + | +help: cast the value to `c_uint` + | +LL | foo(1, 2, 1u8 as c_uint); + | ~~~~~~~~~~~~~ +help: cast the value to `c_uint` + | +LL | foo(1, 2, 1u8 as c_uint); + | +++++++++ error[E0617]: can't pass `i16` to variadic function --> $DIR/variadic-ffi-1.rs:32:19 | LL | foo(1, 2, 1i16); - | ^^^^ help: cast the value to `c_int`: `1i16 as c_int` + | ^^^^ + | +help: cast the value to `c_int` + | +LL | foo(1, 2, 1i16 as c_int); + | ~~~~~~~~~~~~~ +help: cast the value to `c_int` + | +LL | foo(1, 2, 1i16 as c_int); + | ++++++++ error[E0617]: can't pass `u16` to variadic function --> $DIR/variadic-ffi-1.rs:33:19 | LL | foo(1, 2, 1u16); - | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint` + | ^^^^ + | +help: cast the value to `c_uint` + | +LL | foo(1, 2, 1u16 as c_uint); + | ~~~~~~~~~~~~~~ +help: cast the value to `c_uint` + | +LL | foo(1, 2, 1u16 as c_uint); + | +++++++++ error: aborting due to 11 previous errors diff --git a/tests/ui/cast/cast-as-bool.rs b/tests/ui/cast/cast-as-bool.rs index 511a02718fe21..312b5617f4eea 100644 --- a/tests/ui/cast/cast-as-bool.rs +++ b/tests/ui/cast/cast-as-bool.rs @@ -30,9 +30,9 @@ fn main() { unsafe fn owo() {} // fn item to bool - let _ = uwu as bool; //~ ERROR cannot cast `fn(u8) -> String {uwu}` as `bool` + let _ = uwu as bool; //~ ERROR cannot cast `{fn item uwu: fn(u8) -> String}` as `bool` // unsafe fn item - let _ = owo as bool; //~ ERROR cannot cast `unsafe fn() {owo}` as `bool` + let _ = owo as bool; //~ ERROR cannot cast `{fn item owo: unsafe fn()}` as `bool` // fn ptr to bool let _ = uwu as fn(u8) -> String as bool; //~ ERROR cannot cast `fn(u8) -> String` as `bool` diff --git a/tests/ui/cast/cast-as-bool.stderr b/tests/ui/cast/cast-as-bool.stderr index 4ff56a95e49a3..2a5d3107d631e 100644 --- a/tests/ui/cast/cast-as-bool.stderr +++ b/tests/ui/cast/cast-as-bool.stderr @@ -48,13 +48,13 @@ error[E0054]: cannot cast `IntEnum` as `bool` LL | let _ = IntEnum::One as bool; | ^^^^^^^^^^^^^^^^^^^^ unsupported cast -error[E0054]: cannot cast `fn(u8) -> String {uwu}` as `bool` +error[E0054]: cannot cast `{fn item uwu: fn(u8) -> String}` as `bool` --> $DIR/cast-as-bool.rs:33:13 | LL | let _ = uwu as bool; | ^^^^^^^^^^^ unsupported cast -error[E0054]: cannot cast `unsafe fn() {owo}` as `bool` +error[E0054]: cannot cast `{fn item owo: unsafe fn()}` as `bool` --> $DIR/cast-as-bool.rs:35:13 | LL | let _ = owo as bool; diff --git a/tests/ui/cast/cast-to-bare-fn.stderr b/tests/ui/cast/cast-to-bare-fn.stderr index d97b0c5f8aadc..9651be864ef41 100644 --- a/tests/ui/cast/cast-to-bare-fn.stderr +++ b/tests/ui/cast/cast-to-bare-fn.stderr @@ -1,4 +1,4 @@ -error[E0605]: non-primitive cast: `fn(isize) {foo}` as `extern "C" fn() -> isize` +error[E0605]: non-primitive cast: `{fn item foo: fn(isize)}` as `extern "C" fn() -> isize` --> $DIR/cast-to-bare-fn.rs:5:13 | LL | let x = foo as extern "C" fn() -> isize; diff --git a/tests/ui/closures/closure_cap_coerce_many_fail.stderr b/tests/ui/closures/closure_cap_coerce_many_fail.stderr index 958439e7dd061..763603281562b 100644 --- a/tests/ui/closures/closure_cap_coerce_many_fail.stderr +++ b/tests/ui/closures/closure_cap_coerce_many_fail.stderr @@ -4,14 +4,14 @@ error[E0308]: `match` arms have incompatible types LL | let _ = match "+" { | _____________- LL | | "+" => add, - | | --- this is found to be of type `fn(i32, i32) -> i32 {add}` + | | --- this is found to be of type `{fn item add: fn(i32, i32) -> i32}` LL | | "-" => |a, b| (a - b + cap) as i32, | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn item, found closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected fn item `fn(i32, i32) -> i32 {add}` + = note: expected fn item `{fn item add: fn(i32, i32) -> i32}` found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22}` error[E0308]: `match` arms have incompatible types diff --git a/tests/ui/closures/coerce-unsafe-to-closure.stderr b/tests/ui/closures/coerce-unsafe-to-closure.stderr index 4841ff32e7011..85b3c9d50156a 100644 --- a/tests/ui/closures/coerce-unsafe-to-closure.stderr +++ b/tests/ui/closures/coerce-unsafe-to-closure.stderr @@ -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 `{fn item transmute::<_, _>: unsafe extern "rust-intrinsic" fn(_) -> _}` --> $DIR/coerce-unsafe-to-closure.rs:2:44 | LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); @@ -6,7 +6,7 @@ LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); | | | required by a bound introduced by this call | - = help: the trait `FnOnce<(&str,)>` is not implemented for fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + = help: the trait `FnOnce<(&str,)>` is not implemented for fn item `{fn item transmute::<_, _>: unsafe extern "rust-intrinsic" fn(_) -> _}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs index c4d2d02ba7034..f4ab9e4725c03 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs @@ -4,7 +4,7 @@ fn check(_: impl std::marker::ConstParamTy) {} fn main() { - check(main); //~ error: `fn() {main}` can't be used as a const parameter type + check(main); //~ error: `{fn item main: fn()}` can't be used as a const parameter type check(|| {}); //~ error: `{closure@$DIR/const_param_ty_bad.rs:8:11: 8:13}` can't be used as a const parameter type check(main as fn()); //~ error: `fn()` can't be used as a const parameter type check(&mut ()); //~ error: `&mut ()` can't be used as a const parameter type diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr index d96491f4f20ea..d6bd83386fdf3 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -1,8 +1,8 @@ -error[E0277]: `fn() {main}` can't be used as a const parameter type +error[E0277]: `{fn item main: fn()}` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:7:11 | LL | check(main); - | ----- ^^^^ the trait `ConstParamTy` is not implemented for fn item `fn() {main}` + | ----- ^^^^ the trait `ConstParamTy` is not implemented for fn item `{fn item main: fn()}` | | | required by a bound introduced by this call | diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr index 043fa34d605ab..997037127dbfe 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr @@ -1,11 +1,11 @@ -error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface +error[E0446]: private type `{fn item my_const_fn: fn(u8) -> u8}` in public interface --> $DIR/eval-privacy.rs:16:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type ... LL | const fn my_const_fn(val: u8) -> u8 { - | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private + | ----------------------------------- `{fn item my_const_fn: fn(u8) -> u8}` declared as private error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0617.rs b/tests/ui/error-codes/E0617.rs index b71ba0ed88b9f..580277c1ea6f0 100644 --- a/tests/ui/error-codes/E0617.rs +++ b/tests/ui/error-codes/E0617.rs @@ -7,20 +7,27 @@ fn main() { printf(::std::ptr::null(), 0f32); //~^ ERROR can't pass `f32` to variadic function //~| HELP cast the value to `c_double` + //~| HELP cast the value to `c_double` printf(::std::ptr::null(), 0i8); //~^ ERROR can't pass `i8` to variadic function //~| HELP cast the value to `c_int` + //~| HELP cast the value to `c_int` printf(::std::ptr::null(), 0i16); //~^ ERROR can't pass `i16` to variadic function //~| HELP cast the value to `c_int` + //~| HELP cast the value to `c_int` printf(::std::ptr::null(), 0u8); //~^ ERROR can't pass `u8` to variadic function //~| HELP cast the value to `c_uint` + //~| HELP cast the value to `c_uint` printf(::std::ptr::null(), 0u16); //~^ ERROR can't pass `u16` to variadic function //~| HELP cast the value to `c_uint` + //~| HELP cast the value to `c_uint` printf(::std::ptr::null(), printf); - //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function + //~^ ERROR can't pass `{fn item printf: unsafe extern "C" fn(*const i8, ...)}` to variadic function + //~| HELP a function item is zero-sized and needs to be casted into a function pointer to be used in FFI + //~| HELP cast the value into a function pointer //~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)` } } diff --git a/tests/ui/error-codes/E0617.stderr b/tests/ui/error-codes/E0617.stderr index ea91ad0829230..5f5ea7a05d9ef 100644 --- a/tests/ui/error-codes/E0617.stderr +++ b/tests/ui/error-codes/E0617.stderr @@ -2,42 +2,93 @@ error[E0617]: can't pass `f32` to variadic function --> $DIR/E0617.rs:7:36 | LL | printf(::std::ptr::null(), 0f32); - | ^^^^ help: cast the value to `c_double`: `0f32 as c_double` + | ^^^^ + | +help: cast the value to `c_double` + | +LL | printf(::std::ptr::null(), 0f32 as c_double); + | ~~~~~~~~~~~~~~~~ +help: cast the value to `c_double` + | +LL | printf(::std::ptr::null(), 0f32 as c_double); + | +++++++++++ error[E0617]: can't pass `i8` to variadic function - --> $DIR/E0617.rs:10:36 + --> $DIR/E0617.rs:11:36 | LL | printf(::std::ptr::null(), 0i8); - | ^^^ help: cast the value to `c_int`: `0i8 as c_int` + | ^^^ + | +help: cast the value to `c_int` + | +LL | printf(::std::ptr::null(), 0i8 as c_int); + | ~~~~~~~~~~~~ +help: cast the value to `c_int` + | +LL | printf(::std::ptr::null(), 0i8 as c_int); + | ++++++++ error[E0617]: can't pass `i16` to variadic function - --> $DIR/E0617.rs:13:36 + --> $DIR/E0617.rs:15:36 | LL | printf(::std::ptr::null(), 0i16); - | ^^^^ help: cast the value to `c_int`: `0i16 as c_int` + | ^^^^ + | +help: cast the value to `c_int` + | +LL | printf(::std::ptr::null(), 0i16 as c_int); + | ~~~~~~~~~~~~~ +help: cast the value to `c_int` + | +LL | printf(::std::ptr::null(), 0i16 as c_int); + | ++++++++ error[E0617]: can't pass `u8` to variadic function - --> $DIR/E0617.rs:16:36 + --> $DIR/E0617.rs:19:36 | LL | printf(::std::ptr::null(), 0u8); - | ^^^ help: cast the value to `c_uint`: `0u8 as c_uint` + | ^^^ + | +help: cast the value to `c_uint` + | +LL | printf(::std::ptr::null(), 0u8 as c_uint); + | ~~~~~~~~~~~~~ +help: cast the value to `c_uint` + | +LL | printf(::std::ptr::null(), 0u8 as c_uint); + | +++++++++ error[E0617]: can't pass `u16` to variadic function - --> $DIR/E0617.rs:19:36 + --> $DIR/E0617.rs:23:36 | LL | printf(::std::ptr::null(), 0u16); - | ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint` + | ^^^^ + | +help: cast the value to `c_uint` + | +LL | printf(::std::ptr::null(), 0u16 as c_uint); + | ~~~~~~~~~~~~~~ +help: cast the value to `c_uint` + | +LL | printf(::std::ptr::null(), 0u16 as c_uint); + | +++++++++ -error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function - --> $DIR/E0617.rs:22:36 +error[E0617]: can't pass `{fn item printf: unsafe extern "C" fn(*const i8, ...)}` to variadic function + --> $DIR/E0617.rs:27:36 | LL | printf(::std::ptr::null(), printf); | ^^^^^^ | + = help: a function item is zero-sized and needs to be casted into a function pointer to be used in FFI + = note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html help: cast the value to `unsafe extern "C" fn(*const i8, ...)` | LL | printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +help: cast the value into a function pointer + | +LL | printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...)); + | +++++++++++++++++++++++++++++++++++++++ error: aborting due to 6 previous errors diff --git a/tests/ui/expr/if/if-typeck.stderr b/tests/ui/expr/if/if-typeck.stderr index 1be43a20105fa..9e724ace23989 100644 --- a/tests/ui/expr/if/if-typeck.stderr +++ b/tests/ui/expr/if/if-typeck.stderr @@ -5,7 +5,7 @@ LL | if f { } | ^ expected `bool`, found fn item | = note: expected type `bool` - found fn item `fn() {f}` + found fn item `{fn item f: fn()}` error: aborting due to 1 previous error diff --git a/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr index fbb7e0e4df55d..de36473d08add 100644 --- a/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr +++ b/tests/ui/expr/malformed_closure/missing_block_in_fn_call.stderr @@ -27,7 +27,7 @@ LL | fn foo() {} | -------- function `foo` defined here | = note: expected unit type `()` - found fn item `fn() {foo}` + found fn item `{fn item foo: fn()}` help: use parentheses to call this function | LL | let _: () = foo(); diff --git a/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr index 5fc48d73b14d8..0982c069db823 100644 --- a/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr +++ b/tests/ui/expr/malformed_closure/ruby_style_closure_parse_error.stderr @@ -25,7 +25,7 @@ LL | fn foo() {} | -------- function `foo` defined here | = note: expected unit type `()` - found fn item `fn() {foo}` + found fn item `{fn item foo: fn()}` help: use parentheses to call this function | LL | let _: () = foo(); diff --git a/tests/ui/extern/extern-wrong-value-type.rs b/tests/ui/extern/extern-wrong-value-type.rs index 56c6cf1dfaba7..6c40320ceee0e 100644 --- a/tests/ui/extern/extern-wrong-value-type.rs +++ b/tests/ui/extern/extern-wrong-value-type.rs @@ -7,5 +7,5 @@ fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK is_fn(f); - //~^ ERROR expected a `Fn()` closure, found `extern "C" fn() {f}` + //~^ ERROR expected a `Fn()` closure, found `{fn item f: extern "C" fn()}` } diff --git a/tests/ui/extern/extern-wrong-value-type.stderr b/tests/ui/extern/extern-wrong-value-type.stderr index 1c08aa1717f4b..17a792d841da6 100644 --- a/tests/ui/extern/extern-wrong-value-type.stderr +++ b/tests/ui/extern/extern-wrong-value-type.stderr @@ -1,13 +1,13 @@ -error[E0277]: expected a `Fn()` closure, found `extern "C" fn() {f}` +error[E0277]: expected a `Fn()` closure, found `{fn item f: extern "C" fn()}` --> $DIR/extern-wrong-value-type.rs:9:11 | LL | is_fn(f); - | ----- ^ expected an `Fn()` closure, found `extern "C" fn() {f}` + | ----- ^ expected an `Fn()` closure, found `{fn item f: extern "C" fn()}` | | | required by a bound introduced by this call | - = help: the trait `Fn<()>` is not implemented for fn item `extern "C" fn() {f}` - = note: wrap the `extern "C" fn() {f}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `Fn<()>` is not implemented for fn item `{fn item f: extern "C" fn()}` + = note: wrap the `{fn item f: extern "C" fn()}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `is_fn` --> $DIR/extern-wrong-value-type.rs:4:28 | diff --git a/tests/ui/fn/fn-compare-mismatch.stderr b/tests/ui/fn/fn-compare-mismatch.stderr index b4e71e75fdb9a..1e3e600da0a3c 100644 --- a/tests/ui/fn/fn-compare-mismatch.stderr +++ b/tests/ui/fn/fn-compare-mismatch.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `==` cannot be applied to type `fn() {f}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item f: fn()}` --> $DIR/fn-compare-mismatch.rs:4:15 | LL | let x = f == g; - | - ^^ - fn() {g} + | - ^^ - {fn item g: fn()} | | - | fn() {f} + | {fn item f: fn()} | help: use parentheses to call these | diff --git a/tests/ui/fn/fn-pointer-mismatch.stderr b/tests/ui/fn/fn-pointer-mismatch.stderr index 9cda11639d0f5..10099eed66934 100644 --- a/tests/ui/fn/fn-pointer-mismatch.stderr +++ b/tests/ui/fn/fn-pointer-mismatch.stderr @@ -2,7 +2,7 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/fn-pointer-mismatch.rs:11:43 | LL | let g = if n % 2 == 0 { &foo } else { &bar }; - | ---- ^^^^ expected `&fn(u32) -> u32 {foo}`, found `&fn(u32) -> u32 {bar}` + | ---- ^^^^ expected `&{fn item foo: fn(u32) -> u32}`, found `&{fn item bar: fn(u32) -> u32}` | | | expected because of this | @@ -43,7 +43,7 @@ error[E0308]: mismatched types --> $DIR/fn-pointer-mismatch.rs:36:29 | LL | let c: fn(u32) -> u32 = &foo; - | -------------- ^^^^ expected fn pointer, found `&fn(u32) -> u32 {foo}` + | -------------- ^^^^ expected fn pointer, found `&{fn item foo: fn(u32) -> u32}` | | | expected due to this | @@ -73,7 +73,7 @@ error[E0308]: mismatched types --> $DIR/fn-pointer-mismatch.rs:48:30 | LL | let e: &fn(u32) -> u32 = &foo; - | --------------- ^^^^ expected `&fn(u32) -> u32`, found `&fn(u32) -> u32 {foo}` + | --------------- ^^^^ expected `&fn(u32) -> u32`, found `&{fn item foo: fn(u32) -> u32}` | | | expected due to this | diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index c25e731d9627c..2baa32d182835 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types LL | assert_all::<_, &String>(id); | ^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected trait `for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` - found trait `for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` + = note: expected trait `for<'a> <{fn item id: for<'a> fn(&'a String) -> &'a String} as FnMut<(&'a String,)>>` + found trait `for<'a> <{fn item id: for<'a> fn(&'a String) -> &'a String} as FnMut<(&'a String,)>>` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr index 699a4ecc42bb9..6c334962550bd 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr @@ -22,7 +22,7 @@ note: `StreamExt` defines an item `filterx`, perhaps you need to implement it LL | pub trait StreamExt | ^^^^^^^^^^^^^^^^^^^ -error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, {closure@issue-30786.rs:131:30}>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter: fn(&u64) -> &u64}>, {closure@issue-30786.rs:131:30}>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:132:24 | LL | pub struct Filter { @@ -32,9 +32,9 @@ LL | let count = filter.countx(); | ^^^^^^ method cannot be called due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` - `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` - `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` + `&'a mut &Filter: for<'a> fn(&'a u64) -> &'a u64}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` + `&'a mut &mut Filter: for<'a> fn(&'a u64) -> &'a u64}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` + `&'a mut Filter: for<'a> fn(&'a u64) -> &'a u64}>, {closure@$DIR/issue-30786.rs:131:30: 131:37}>: Stream` --> $DIR/issue-30786.rs:98:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} diff --git a/tests/ui/hygiene/impl_items.rs b/tests/ui/hygiene/impl_items.rs index 51088e3693d73..d4aa62336303a 100644 --- a/tests/ui/hygiene/impl_items.rs +++ b/tests/ui/hygiene/impl_items.rs @@ -7,7 +7,7 @@ mod foo { } pub macro m() { - let _: () = S.f(); //~ ERROR type `for<'a> fn(&'a foo::S) {foo::S::f}` is private + let _: () = S.f(); //~ ERROR type `{fn item foo::S::f: for<'a> fn(&'a foo::S)}` is private } } diff --git a/tests/ui/hygiene/impl_items.stderr b/tests/ui/hygiene/impl_items.stderr index 35f2750403de4..c65d33aa64082 100644 --- a/tests/ui/hygiene/impl_items.stderr +++ b/tests/ui/hygiene/impl_items.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a foo::S) {foo::S::f}` is private +error: type `{fn item foo::S::f: for<'a> fn(&'a foo::S)}` is private --> $DIR/impl_items.rs:10:23 | LL | let _: () = S.f(); diff --git a/tests/ui/hygiene/intercrate.rs b/tests/ui/hygiene/intercrate.rs index 2de62f6aff77f..a17fab8c2170d 100644 --- a/tests/ui/hygiene/intercrate.rs +++ b/tests/ui/hygiene/intercrate.rs @@ -6,5 +6,5 @@ extern crate intercrate; fn main() { assert_eq!(intercrate::foo::m!(), 1); - //~^ ERROR type `fn() -> u32 {foo::bar::f}` is private + //~^ ERROR type `{fn item foo::bar::f: fn() -> u32}` is private } diff --git a/tests/ui/hygiene/intercrate.stderr b/tests/ui/hygiene/intercrate.stderr index 230ad052db3ee..7ff85bccc7dbb 100644 --- a/tests/ui/hygiene/intercrate.stderr +++ b/tests/ui/hygiene/intercrate.stderr @@ -1,4 +1,4 @@ -error: type `fn() -> u32 {foo::bar::f}` is private +error: type `{fn item foo::bar::f: fn() -> u32}` is private --> $DIR/intercrate.rs:8:16 | LL | assert_eq!(intercrate::foo::m!(), 1); diff --git a/tests/ui/inline-const/pat-match-fndef.rs b/tests/ui/inline-const/pat-match-fndef.rs index 013a4a6756102..8bc89d02c3e3b 100644 --- a/tests/ui/inline-const/pat-match-fndef.rs +++ b/tests/ui/inline-const/pat-match-fndef.rs @@ -6,7 +6,7 @@ fn main() { let x = []; match x[123] { const { uwu } => {} - //~^ ERROR `fn() {uwu}` cannot be used in patterns + //~^ ERROR `{fn item uwu: fn()}` cannot be used in patterns _ => {} } } diff --git a/tests/ui/inline-const/pat-match-fndef.stderr b/tests/ui/inline-const/pat-match-fndef.stderr index b189ec51ade38..b84b8445567cf 100644 --- a/tests/ui/inline-const/pat-match-fndef.stderr +++ b/tests/ui/inline-const/pat-match-fndef.stderr @@ -1,4 +1,4 @@ -error: `fn() {uwu}` cannot be used in patterns +error: `{fn item uwu: fn()}` cannot be used in patterns --> $DIR/pat-match-fndef.rs:8:9 | LL | const { uwu } => {} diff --git a/tests/ui/issues/issue-21554.stderr b/tests/ui/issues/issue-21554.stderr index b1b59af6ec2b2..81a621acab6f4 100644 --- a/tests/ui/issues/issue-21554.stderr +++ b/tests/ui/issues/issue-21554.stderr @@ -1,4 +1,4 @@ -error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid +error[E0606]: casting `{fn item Inches: fn(i32) -> Inches}` as `f32` is invalid --> $DIR/issue-21554.rs:4:5 | LL | Inches as f32; diff --git a/tests/ui/issues/issue-24322.stderr b/tests/ui/issues/issue-24322.stderr index d078069addcfb..7ee3929aa53d2 100644 --- a/tests/ui/issues/issue-24322.stderr +++ b/tests/ui/issues/issue-24322.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-24322.rs:8:29 | LL | let x: &fn(&B) -> u32 = &B::func; - | -------------- ^^^^^^^^ expected `&fn(&B) -> u32`, found `&fn(&B) -> u32 {B::func}` + | -------------- ^^^^^^^^ expected `&fn(&B) -> u32`, found `&{fn item B::func: fn(&B) -> u32}` | | | expected due to this | diff --git a/tests/ui/issues/issue-35241.stderr b/tests/ui/issues/issue-35241.stderr index 6f6602793fdb7..5d39250fcc274 100644 --- a/tests/ui/issues/issue-35241.stderr +++ b/tests/ui/issues/issue-35241.stderr @@ -10,7 +10,7 @@ LL | fn test() -> Foo { Foo } | expected `Foo` because of return type | = note: expected struct `Foo` - found struct constructor `fn(u32) -> Foo {Foo}` + found struct constructor `{fn item Foo: fn(u32) -> Foo}` help: use parentheses to construct this tuple struct | LL | fn test() -> Foo { Foo(/* u32 */) } diff --git a/tests/ui/issues/issue-59488.rs b/tests/ui/issues/issue-59488.rs index 384501e3e5dfd..e091aa174ab7a 100644 --- a/tests/ui/issues/issue-59488.rs +++ b/tests/ui/issues/issue-59488.rs @@ -12,23 +12,23 @@ enum Foo { fn main() { foo > 12; - //~^ ERROR binary operation `>` cannot be applied to type `fn() -> i32 {foo}` [E0369] + //~^ ERROR binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` [E0369] //~| ERROR mismatched types [E0308] bar > 13; - //~^ ERROR binary operation `>` cannot be applied to type `fn(i64) -> i64 {bar}` [E0369] + //~^ ERROR binary operation `>` cannot be applied to type `{fn item bar: fn(i64) -> i64}` [E0369] //~| ERROR mismatched types [E0308] foo > foo; - //~^ ERROR binary operation `>` cannot be applied to type `fn() -> i32 {foo}` [E0369] + //~^ ERROR binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` [E0369] foo > bar; - //~^ ERROR binary operation `>` cannot be applied to type `fn() -> i32 {foo}` [E0369] + //~^ ERROR binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` [E0369] //~| ERROR mismatched types [E0308] let i = Foo::Bar; assert_eq!(Foo::Bar, i); - //~^ ERROR binary operation `==` cannot be applied to type `fn(usize) -> Foo {Foo::Bar}` [E0369] - //~| ERROR `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` [E0277] - //~| ERROR `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` [E0277] + //~^ ERROR binary operation `==` cannot be applied to type `{fn item Foo::Bar: fn(usize) -> Foo}` [E0369] + //~| ERROR `{fn item Foo::Bar: fn(usize) -> Foo}` doesn't implement `Debug` [E0277] + //~| ERROR `{fn item Foo::Bar: fn(usize) -> Foo}` doesn't implement `Debug` [E0277] } diff --git a/tests/ui/issues/issue-59488.stderr b/tests/ui/issues/issue-59488.stderr index ac8862716c070..74868ca1164f6 100644 --- a/tests/ui/issues/issue-59488.stderr +++ b/tests/ui/issues/issue-59488.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` +error[E0369]: binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` --> $DIR/issue-59488.rs:14:9 | LL | foo > 12; | --- ^ -- {integer} | | - | fn() -> i32 {foo} + | {fn item foo: fn() -> i32} | help: use parentheses to call this function | @@ -17,16 +17,16 @@ error[E0308]: mismatched types LL | foo > 12; | ^^ expected fn item, found `i32` | - = note: expected fn item `fn() -> i32 {foo}` + = note: expected fn item `{fn item foo: fn() -> i32}` found type `i32` -error[E0369]: binary operation `>` cannot be applied to type `fn(i64) -> i64 {bar}` +error[E0369]: binary operation `>` cannot be applied to type `{fn item bar: fn(i64) -> i64}` --> $DIR/issue-59488.rs:18:9 | LL | bar > 13; | --- ^ -- {integer} | | - | fn(i64) -> i64 {bar} + | {fn item bar: fn(i64) -> i64} | help: use parentheses to call this function | @@ -39,29 +39,29 @@ error[E0308]: mismatched types LL | bar > 13; | ^^ expected fn item, found `i64` | - = note: expected fn item `fn(i64) -> i64 {bar}` + = note: expected fn item `{fn item bar: fn(i64) -> i64}` found type `i64` -error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` +error[E0369]: binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` --> $DIR/issue-59488.rs:22:9 | LL | foo > foo; - | --- ^ --- fn() -> i32 {foo} + | --- ^ --- {fn item foo: fn() -> i32} | | - | fn() -> i32 {foo} + | {fn item foo: fn() -> i32} | help: use parentheses to call these | LL | foo() > foo(); | ++ ++ -error[E0369]: binary operation `>` cannot be applied to type `fn() -> i32 {foo}` +error[E0369]: binary operation `>` cannot be applied to type `{fn item foo: fn() -> i32}` --> $DIR/issue-59488.rs:25:9 | LL | foo > bar; - | --- ^ --- fn(i64) -> i64 {bar} + | --- ^ --- {fn item bar: fn(i64) -> i64} | | - | fn() -> i32 {foo} + | {fn item foo: fn() -> i32} error[E0308]: mismatched types --> $DIR/issue-59488.rs:25:11 @@ -72,33 +72,33 @@ LL | foo > bar; = note: expected fn item `fn() -> i32 {foo}` found fn item `fn(i64) -> i64 {bar}` -error[E0369]: binary operation `==` cannot be applied to type `fn(usize) -> Foo {Foo::Bar}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item Foo::Bar: fn(usize) -> Foo}` --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ | | - | fn(usize) -> Foo {Foo::Bar} - | fn(usize) -> Foo {Foo::Bar} + | {fn item Foo::Bar: fn(usize) -> Foo} + | {fn item Foo::Bar: fn(usize) -> Foo} | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` +error[E0277]: `{fn item Foo::Bar: fn(usize) -> Foo}` doesn't implement `Debug` --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); - | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^^^^ `{fn item Foo::Bar: fn(usize) -> Foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` + = help: the trait `Debug` is not implemented for fn item `{fn item Foo::Bar: fn(usize) -> Foo}` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` +error[E0277]: `{fn item Foo::Bar: fn(usize) -> Foo}` doesn't implement `Debug` --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); - | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^^^^ `{fn item Foo::Bar: fn(usize) -> Foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` + = help: the trait `Debug` is not implemented for fn item `{fn item Foo::Bar: fn(usize) -> Foo}` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/issues/issue-62375.stderr b/tests/ui/issues/issue-62375.stderr index faca94a03f018..20c24ccc21312 100644 --- a/tests/ui/issues/issue-62375.stderr +++ b/tests/ui/issues/issue-62375.stderr @@ -2,15 +2,15 @@ error[E0369]: binary operation `==` cannot be applied to type `A` --> $DIR/issue-62375.rs:7:7 | LL | a == A::Value; - | - ^^ -------- fn(()) -> A {A::Value} + | - ^^ -------- {fn item A::Value: fn(()) -> A} | | | A | -note: an implementation of `PartialEq A {A::Value}>` might be missing for `A` +note: an implementation of `PartialEq<{fn item A::Value: fn(()) -> A}>` might be missing for `A` --> $DIR/issue-62375.rs:1:1 | LL | enum A { - | ^^^^^^ must implement `PartialEq A {A::Value}>` + | ^^^^^^ must implement `PartialEq<{fn item A::Value: fn(()) -> A}>` help: use parentheses to construct this tuple variant | LL | a == A::Value(/* () */); diff --git a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr index cec8117702a9b..64de1592ebe17 100644 --- a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr +++ b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `==` cannot be applied to type `fn() {second}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item second: fn()}` --> $DIR/issue-66667-function-cmp-cycle.rs:2:12 | LL | second == 1 | ------ ^^ - {integer} | | - | fn() {second} + | {fn item second: fn()} error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:2:15 @@ -12,7 +12,7 @@ error[E0308]: mismatched types LL | second == 1 | ^ expected fn item, found integer | - = note: expected fn item `fn() {second}` + = note: expected fn item `{fn item second: fn()}` found type `{integer}` error[E0308]: mismatched types @@ -23,13 +23,13 @@ LL | fn first() { LL | second == 1 | ^^^^^^^^^^^ expected `()`, found `bool` -error[E0369]: binary operation `==` cannot be applied to type `fn() {first}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item first: fn()}` --> $DIR/issue-66667-function-cmp-cycle.rs:8:11 | LL | first == 1 | ----- ^^ - {integer} | | - | fn() {first} + | {fn item first: fn()} error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:8:14 @@ -37,7 +37,7 @@ error[E0308]: mismatched types LL | first == 1 | ^ expected fn item, found integer | - = note: expected fn item `fn() {first}` + = note: expected fn item `{fn item first: fn()}` found type `{integer}` error[E0308]: mismatched types @@ -48,13 +48,13 @@ LL | fn second() { LL | first == 1 | ^^^^^^^^^^ expected `()`, found `bool` -error[E0369]: binary operation `==` cannot be applied to type `fn() {bar}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item bar: fn()}` --> $DIR/issue-66667-function-cmp-cycle.rs:14:9 | LL | bar == 1 | --- ^^ - {integer} | | - | fn() {bar} + | {fn item bar: fn()} error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:14:12 @@ -62,7 +62,7 @@ error[E0308]: mismatched types LL | bar == 1 | ^ expected fn item, found integer | - = note: expected fn item `fn() {bar}` + = note: expected fn item `{fn item bar: fn()}` found type `{integer}` error[E0308]: mismatched types diff --git a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index b30bcfb776c8c..09ce1fc3210e1 100644 --- a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `==` cannot be applied to type `fn() -> i32 {a}` +error[E0369]: binary operation `==` cannot be applied to type `{fn item a: fn() -> i32}` --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5 | LL | assert_eq!(a, 0); | ^^^^^^^^^^^^^^^^ | | - | fn() -> i32 {a} + | {fn item a: fn() -> i32} | {integer} | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -15,20 +15,20 @@ error[E0308]: mismatched types LL | assert_eq!(a, 0); | ^^^^^^^^^^^^^^^^ expected fn item, found integer | - = note: expected fn item `fn() -> i32 {a}` + = note: expected fn item `{fn item a: fn() -> i32}` found type `{integer}` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug` +error[E0277]: `{fn item a: fn() -> i32}` doesn't implement `Debug` --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5 | LL | fn a() -> i32 { | - consider calling this function ... LL | assert_eq!(a, 0); - | ^^^^^^^^^^^^^^^^ `fn() -> i32 {a}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^ `{fn item a: fn() -> i32}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for fn item `fn() -> i32 {a}` + = help: the trait `Debug` is not implemented for fn item `{fn item a: fn() -> i32}` = help: use parentheses to call this function: `a()` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-87490.stderr b/tests/ui/issues/issue-87490.stderr index 5a4ec55833bea..9d6f787ddaea3 100644 --- a/tests/ui/issues/issue-87490.stderr +++ b/tests/ui/issues/issue-87490.stderr @@ -7,7 +7,7 @@ LL | String::new | ^^^^^^^^^^^ expected `usize`, found fn item | = note: expected type `usize` - found fn item `fn() -> String {String::new}` + found fn item `{fn item String::new: fn() -> String}` error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr index beb838d2ff832..c5ebc7a546be6 100644 --- a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -62,7 +62,7 @@ error: implementation of `FnOnce` is not general enough LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: `{fn item identity::<&'2 T>: fn(&'2 T) -> &'2 T}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` error: aborting due to 5 previous errors diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index e3b70232ef86c..6f95e0673ba29 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -47,7 +47,7 @@ LL | fn a() -> [u8; foo::()] { | ^^^^^^^ expected `usize`, found fn item | = note: expected type `usize` - found fn item `fn() {foo}` + found fn item `{fn item foo: fn()}` error: `S<'_>` is forbidden as the type of a const generic parameter --> $DIR/unusual-rib-combinations.rs:24:15 diff --git a/tests/ui/lint/issue-106991.stderr b/tests/ui/lint/issue-106991.stderr index 4704e9ef8355f..4f4025b17976f 100644 --- a/tests/ui/lint/issue-106991.stderr +++ b/tests/ui/lint/issue-106991.stderr @@ -4,7 +4,7 @@ error[E0271]: expected `foo` to be a fn item that returns `i32`, but it returns LL | fn bar() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `i32` | - = note: required for `Map>, for<'a> fn(&'a mut Vec) {foo}>` to implement `Iterator` + = note: required for `Map>, {fn item foo: for<'a> fn(&'a mut Vec)}>` to implement `Iterator` error: aborting due to 1 previous error diff --git a/tests/ui/lint/ptr_null_checks.stderr b/tests/ui/lint/ptr_null_checks.stderr index 70a27790c5b3e..8f3f615878584 100644 --- a/tests/ui/lint/ptr_null_checks.stderr +++ b/tests/ui/lint/ptr_null_checks.stderr @@ -4,7 +4,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *mut ()).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value = note: `#[warn(useless_ptr_null_checks)]` on by default @@ -15,7 +15,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *const u8).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -25,7 +25,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *const ()) == std::ptr::null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -35,7 +35,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -45,7 +45,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *const ()) == (0 as *const ()) {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -55,7 +55,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if <*const _>::is_null(fn_ptr as *const ()) {} | ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -65,7 +65,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -75,7 +75,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -85,7 +85,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {} | ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `fn() {main}` + | expression has type `{fn item main: fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value @@ -105,7 +105,7 @@ warning: function pointers are not nullable, so checking them for null will alwa LL | if (c_fn as *const fn()).is_null() {} | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | expression has type `extern "C" fn() {c_fn}` + | expression has type `{fn item c_fn: extern "C" fn()}` | = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value diff --git a/tests/ui/lint/trivial_casts.rs b/tests/ui/lint/trivial_casts.rs index 0a8b9de1de3af..fe7c22c25469a 100644 --- a/tests/ui/lint/trivial_casts.rs +++ b/tests/ui/lint/trivial_casts.rs @@ -67,7 +67,7 @@ pub fn main() { // functions fn baz(_x: i32) {} - let _ = &baz as &dyn Fn(i32); //~ERROR `&fn(i32) {baz}` as `&dyn Fn(i32)` + let _ = &baz as &dyn Fn(i32); //~ERROR trivial cast: `&{fn item baz: fn(i32)}` as `&dyn Fn(i32)` let _: &dyn Fn(i32) = &baz; let x = |_x: i32| {}; let _ = &x as &dyn Fn(i32); //~ERROR trivial cast diff --git a/tests/ui/lint/trivial_casts.stderr b/tests/ui/lint/trivial_casts.stderr index 5e2115574585b..35a12fa8ac777 100644 --- a/tests/ui/lint/trivial_casts.stderr +++ b/tests/ui/lint/trivial_casts.stderr @@ -120,7 +120,7 @@ LL | let _ = x as Box; | = help: cast can be replaced by coercion; this might require a temporary variable -error: trivial cast: `&fn(i32) {baz}` as `&dyn Fn(i32)` +error: trivial cast: `&{fn item baz: fn(i32)}` as `&dyn Fn(i32)` --> $DIR/trivial_casts.rs:70:13 | LL | let _ = &baz as &dyn Fn(i32); diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout index ffe730743241d..8caad36b24ba7 100644 --- a/tests/ui/match/issue-82392.stdout +++ b/tests/ui/match/issue-82392.stdout @@ -11,6 +11,6 @@ fn main() ({ ({ } as ()) else if (let Some(a) = ((Some as - fn(i32) -> Option {Option::::Some})((3 as i32)) as - Option) as bool) ({ } as ()) as ()) + {fn item Option::::Some: fn(i32) -> Option})((3 as + i32)) as Option) as bool) ({ } as ()) as ()) } as ()) diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/mismatched_types/cast-rfc0401.stderr index 142a52aef13d0..56ceb6330a9d1 100644 --- a/tests/ui/mismatched_types/cast-rfc0401.stderr +++ b/tests/ui/mismatched_types/cast-rfc0401.stderr @@ -14,7 +14,7 @@ LL | u as *const str | = note: vtable kinds may not match -error[E0609]: no field `f` on type `fn() {main}` +error[E0609]: no field `f` on type `{fn item main: fn()}` --> $DIR/cast-rfc0401.rs:65:18 | LL | let _ = main.f as *const u32; @@ -62,7 +62,7 @@ error[E0606]: casting `*const u8` as `f32` is invalid LL | let _ = v as f32; | ^^^^^^^^ -error[E0606]: casting `fn() {main}` as `f64` is invalid +error[E0606]: casting `{fn item main: fn()}` as `f64` is invalid --> $DIR/cast-rfc0401.rs:36:13 | LL | let _ = main as f64; @@ -176,7 +176,7 @@ error[E0606]: casting `&dyn Foo` as `*mut str` is invalid LL | let _ = foo as *mut str; | ^^^^^^^^^^^^^^^ -error[E0606]: casting `fn() {main}` as `*mut str` is invalid +error[E0606]: casting `{fn item main: fn()}` as `*mut str` is invalid --> $DIR/cast-rfc0401.rs:56:13 | LL | let _ = main as *mut str; diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs index 42adff43a58f2..c196148bb0a41 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs @@ -24,9 +24,9 @@ fn main() { let _ = produces_string().and_then(takes_str_but_too_many_refs); //~^ ERROR type mismatch in function arguments 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 `{fn item takes_str_but_wrong_abi: for<'a> extern "C" fn(&'a str) -> Option<()>}` 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 `{fn item takes_str_but_unsafe: for<'a> unsafe fn(&'a str) -> Option<()>}` let _ = produces_string().and_then(no_args); //~^ ERROR function is expected to take 1 argument, but it takes 0 arguments let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr index 1ac057a5f382f..7d92cbcc34f39 100644 --- a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr @@ -18,19 +18,19 @@ help: consider wrapping the function in a closure LL | let _ = produces_string().and_then(|arg0: String| takes_str_but_too_many_refs(/* &&str */)); | ++++++++++++++ +++++++++++++ -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 `{fn item takes_str_but_wrong_abi: for<'a> extern "C" fn(&'a str) -> Option<()>}` --> $DIR/suggest-option-asderef-unfixable.rs:26:40 | 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 `{fn item takes_str_but_wrong_abi: for<'a> extern "C" fn(&'a str) -> Option<()>}` | | | required by a bound introduced by this call | - = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `{fn item takes_str_but_wrong_abi: for<'a> extern "C" fn(&'a str) -> Option<()>}` note: required by a bound in `Option::::and_then` --> $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 `{fn item takes_str_but_unsafe: for<'a> unsafe fn(&'a str) -> Option<()>}` --> $DIR/suggest-option-asderef-unfixable.rs:28:40 | LL | let _ = produces_string().and_then(takes_str_but_unsafe); @@ -38,7 +38,7 @@ LL | let _ = produces_string().and_then(takes_str_but_unsafe); | | | required by a bound introduced by this call | - = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `{fn item takes_str_but_unsafe: for<'a> unsafe fn(&'a str) -> Option<()>}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `Option::::and_then` --> $SRC_DIR/core/src/option.rs:LL:COL diff --git a/tests/ui/namespace/namespace-mix.stderr b/tests/ui/namespace/namespace-mix.stderr index 4eff08ead42ce..36ad25bafc955 100644 --- a/tests/ui/namespace/namespace-mix.stderr +++ b/tests/ui/namespace/namespace-mix.stderr @@ -239,11 +239,11 @@ note: required by a bound in `check` LL | fn check(_: T) {} | ^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `fn() -> c::TS {c::TS}: Impossible` is not satisfied +error[E0277]: the trait bound `{fn item c::TS: fn() -> c::TS}: Impossible` is not satisfied --> $DIR/namespace-mix.rs:56:11 | LL | check(m3::TS); - | ----- ^^^^^^ the trait `Impossible` is not implemented for fn item `fn() -> c::TS {c::TS}` + | ----- ^^^^^^ the trait `Impossible` is not implemented for fn item `{fn item c::TS: fn() -> c::TS}` | | | required by a bound introduced by this call | @@ -315,11 +315,11 @@ note: required by a bound in `check` LL | fn check(_: T) {} | ^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}: Impossible` is not satisfied +error[E0277]: the trait bound `{fn item namespace_mix::c::TS: fn() -> namespace_mix::c::TS}: Impossible` is not satisfied --> $DIR/namespace-mix.rs:62:11 | LL | check(xm3::TS); - | ----- ^^^^^^^ the trait `Impossible` is not implemented for fn item `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}` + | ----- ^^^^^^^ the trait `Impossible` is not implemented for fn item `{fn item namespace_mix::c::TS: fn() -> namespace_mix::c::TS}` | | | required by a bound introduced by this call | @@ -657,11 +657,11 @@ note: required by a bound in `check` LL | fn check(_: T) {} | ^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `fn() -> c::E {c::E::TV}: Impossible` is not satisfied +error[E0277]: the trait bound `{fn item c::E::TV: fn() -> c::E}: Impossible` is not satisfied --> $DIR/namespace-mix.rs:122:11 | LL | check(m9::TV); - | ----- ^^^^^^ the trait `Impossible` is not implemented for fn item `fn() -> c::E {c::E::TV}` + | ----- ^^^^^^ the trait `Impossible` is not implemented for fn item `{fn item c::E::TV: fn() -> c::E}` | | | required by a bound introduced by this call | @@ -733,11 +733,11 @@ note: required by a bound in `check` LL | fn check(_: T) {} | ^^^^^^^^^^ required by this bound in `check` -error[E0277]: the trait bound `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}: Impossible` is not satisfied +error[E0277]: the trait bound `{fn item namespace_mix::xm7::TV: fn() -> namespace_mix::c::E}: Impossible` is not satisfied --> $DIR/namespace-mix.rs:128:11 | LL | check(xm9::TV); - | ----- ^^^^^^^ the trait `Impossible` is not implemented for fn item `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}` + | ----- ^^^^^^^ the trait `Impossible` is not implemented for fn item `{fn item namespace_mix::xm7::TV: fn() -> namespace_mix::c::E}` | | | required by a bound introduced by this call | diff --git a/tests/ui/privacy/associated-item-privacy-inherent.rs b/tests/ui/privacy/associated-item-privacy-inherent.rs index 81703ae106766..9aab356c958f4 100644 --- a/tests/ui/privacy/associated-item-privacy-inherent.rs +++ b/tests/ui/privacy/associated-item-privacy-inherent.rs @@ -11,11 +11,11 @@ mod priv_nominal { pub macro mac() { let value = Pub::method; - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private value; - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private Pub.method(); - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private Pub::CONST; //~^ ERROR associated constant `CONST` is private // let _: Pub::AssocTy; diff --git a/tests/ui/privacy/associated-item-privacy-inherent.stderr b/tests/ui/privacy/associated-item-privacy-inherent.stderr index f4d4ee459204d..d2424492e6c69 100644 --- a/tests/ui/privacy/associated-item-privacy-inherent.stderr +++ b/tests/ui/privacy/associated-item-privacy-inherent.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private --> $DIR/associated-item-privacy-inherent.rs:13:21 | LL | let value = Pub::method; @@ -9,7 +9,7 @@ LL | priv_nominal::mac!(); | = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private --> $DIR/associated-item-privacy-inherent.rs:15:9 | LL | value; @@ -20,7 +20,7 @@ LL | priv_nominal::mac!(); | = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `{fn item priv_nominal::Pub::method: for<'a> fn(&'a priv_nominal::Pub)}` is private --> $DIR/associated-item-privacy-inherent.rs:17:13 | LL | Pub.method(); diff --git a/tests/ui/privacy/associated-item-privacy-trait.rs b/tests/ui/privacy/associated-item-privacy-trait.rs index f038ae9e261df..ffcc10377d020 100644 --- a/tests/ui/privacy/associated-item-privacy-trait.rs +++ b/tests/ui/privacy/associated-item-privacy-trait.rs @@ -13,11 +13,11 @@ mod priv_trait { pub macro mac() { let value = ::method; - //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + //~^ ERROR type `{fn item ::method: for<'a> fn(&'a priv_trait::Pub)}` is private value; - //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + //~^ ERROR type `{fn item ::method: for<'a> fn(&'a priv_trait::Pub)}` is private Pub.method(); - //~^ ERROR type `for<'a> fn(&'a Self) {::method}` is private + //~^ ERROR type `{fn item ::method: for<'a> fn(&'a Self)}` is private ::CONST; //~^ ERROR associated constant `PrivTr::CONST` is private let _: ::AssocTy; diff --git a/tests/ui/privacy/associated-item-privacy-trait.stderr b/tests/ui/privacy/associated-item-privacy-trait.stderr index 4e9dfa4a83519..50ae8b966a128 100644 --- a/tests/ui/privacy/associated-item-privacy-trait.stderr +++ b/tests/ui/privacy/associated-item-privacy-trait.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private +error: type `{fn item ::method: for<'a> fn(&'a priv_trait::Pub)}` is private --> $DIR/associated-item-privacy-trait.rs:15:21 | LL | let value = ::method; @@ -9,7 +9,7 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private +error: type `{fn item ::method: for<'a> fn(&'a priv_trait::Pub)}` is private --> $DIR/associated-item-privacy-trait.rs:17:9 | LL | value; @@ -20,7 +20,7 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Self) {::method}` is private +error: type `{fn item ::method: for<'a> fn(&'a Self)}` is private --> $DIR/associated-item-privacy-trait.rs:19:13 | LL | Pub.method(); diff --git a/tests/ui/privacy/private-inferred-type-3.rs b/tests/ui/privacy/private-inferred-type-3.rs index cdbdcf60b2c54..093ca37955fc8 100644 --- a/tests/ui/privacy/private-inferred-type-3.rs +++ b/tests/ui/privacy/private-inferred-type-3.rs @@ -1,12 +1,12 @@ // aux-build:private-inferred-type.rs -// error-pattern:type `fn() {ext::priv_fn}` is private +// error-pattern:type `{fn item ext::priv_fn: fn()}` is private // error-pattern:static `ext::PRIV_STATIC` is private // error-pattern:type `ext::PrivEnum` is private -// error-pattern:type `fn() {::method}` is private -// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private -// error-pattern:type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private -// error-pattern:type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private +// error-pattern:type `{fn item ::method: fn()}` is private +// error-pattern:type `{fn item ::method: fn()}` is private +// error-pattern:type `{fn item ext::PrivTupleStruct: fn(u8) -> ext::PrivTupleStruct}` is private +// error-pattern:type `{fn item Pub::::priv_method: for<'a> fn(&'a Pub)}` is private #![feature(decl_macro)] diff --git a/tests/ui/privacy/private-inferred-type-3.stderr b/tests/ui/privacy/private-inferred-type-3.stderr index 42faeb4bf341d..ed2dd247b881f 100644 --- a/tests/ui/privacy/private-inferred-type-3.stderr +++ b/tests/ui/privacy/private-inferred-type-3.stderr @@ -1,4 +1,4 @@ -error: type `fn() {ext::priv_fn}` is private +error: type `{fn item ext::priv_fn: fn()}` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); @@ -22,7 +22,7 @@ LL | ext::m!(); | = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn() {::method}` is private +error: type `{fn item ::method: fn()}` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); @@ -30,7 +30,7 @@ LL | ext::m!(); | = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private +error: type `{fn item ext::PrivTupleStruct: fn(u8) -> ext::PrivTupleStruct}` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); @@ -38,7 +38,7 @@ LL | ext::m!(); | = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private +error: type `{fn item PubTupleStruct: fn(u8) -> PubTupleStruct}` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); @@ -46,7 +46,7 @@ LL | ext::m!(); | = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private +error: type `{fn item Pub::::priv_method: for<'a> fn(&'a Pub)}` is private --> $DIR/private-inferred-type-3.rs:16:5 | LL | ext::m!(); diff --git a/tests/ui/privacy/private-inferred-type.rs b/tests/ui/privacy/private-inferred-type.rs index 8c07226fe0e4d..41c477d4e7dbd 100644 --- a/tests/ui/privacy/private-inferred-type.rs +++ b/tests/ui/privacy/private-inferred-type.rs @@ -36,18 +36,18 @@ mod m { impl TraitWithAssocTy for Priv { type AssocTy = u8; } pub macro m() { - priv_fn; //~ ERROR type `fn() {priv_fn}` is private + priv_fn; //~ ERROR type `{fn item priv_fn: fn()}` is private PRIV_STATIC; // OK, not cross-crate PrivEnum::Variant; //~ ERROR type `PrivEnum` is private PubEnum::Variant; // OK - ::method; //~ ERROR type `fn() {::method}` is private + ::method; //~ ERROR type `{fn item ::method: fn()}` is private ::method; // OK PrivTupleStruct; - //~^ ERROR type `fn(u8) -> PrivTupleStruct {PrivTupleStruct}` is private + //~^ ERROR type `{fn item PrivTupleStruct: fn(u8) -> PrivTupleStruct}` is private PubTupleStruct; - //~^ ERROR type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private + //~^ ERROR type `{fn item PubTupleStruct: fn(u8) -> PubTupleStruct}` is private Pub(0u8).priv_method(); - //~^ ERROR type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private + //~^ ERROR type `{fn item Pub::::priv_method: for<'a> fn(&'a Pub)}` is private } trait Trait {} diff --git a/tests/ui/privacy/private-inferred-type.stderr b/tests/ui/privacy/private-inferred-type.stderr index fc3f9ab62bfa9..36e0ab7e7613a 100644 --- a/tests/ui/privacy/private-inferred-type.stderr +++ b/tests/ui/privacy/private-inferred-type.stderr @@ -106,7 +106,7 @@ error: type `S2` is private LL | adjust::S1.method_s3(); | ^^^^^^^^^^ private type -error: type `fn() {priv_fn}` is private +error: type `{fn item priv_fn: fn()}` is private --> $DIR/private-inferred-type.rs:39:9 | LL | priv_fn; @@ -128,7 +128,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn() {::method}` is private +error: type `{fn item ::method: fn()}` is private --> $DIR/private-inferred-type.rs:43:9 | LL | ::method; @@ -139,7 +139,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn(u8) -> PrivTupleStruct {PrivTupleStruct}` is private +error: type `{fn item PrivTupleStruct: fn(u8) -> PrivTupleStruct}` is private --> $DIR/private-inferred-type.rs:45:9 | LL | PrivTupleStruct; @@ -150,7 +150,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private +error: type `{fn item PubTupleStruct: fn(u8) -> PubTupleStruct}` is private --> $DIR/private-inferred-type.rs:47:9 | LL | PubTupleStruct; @@ -161,7 +161,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private +error: type `{fn item Pub::::priv_method: for<'a> fn(&'a Pub)}` is private --> $DIR/private-inferred-type.rs:49:18 | LL | Pub(0u8).priv_method(); diff --git a/tests/ui/privacy/where-priv-type.stderr b/tests/ui/privacy/where-priv-type.stderr index 126330b14a63f..d9be01d5a37fd 100644 --- a/tests/ui/privacy/where-priv-type.stderr +++ b/tests/ui/privacy/where-priv-type.stderr @@ -68,14 +68,14 @@ note: but type `PrivTy` is only usable at visibility `pub(crate)` LL | struct PrivTy; | ^^^^^^^^^^^^^ -error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface +error[E0446]: private type `{fn item my_const_fn: fn(u8) -> u8}` in public interface --> $DIR/where-priv-type.rs:75:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type ... LL | const fn my_const_fn(val: u8) -> u8 { - | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private + | ----------------------------------- `{fn item my_const_fn: fn(u8) -> u8}` declared as private error: aborting due to 1 previous error; 5 warnings emitted diff --git a/tests/ui/qualified/qualified-path-params.stderr b/tests/ui/qualified/qualified-path-params.stderr index a49ed6c8f607a..c4a87755f4e77 100644 --- a/tests/ui/qualified/qualified-path-params.stderr +++ b/tests/ui/qualified/qualified-path-params.stderr @@ -8,7 +8,7 @@ error[E0029]: only `char` and numeric types are allowed in range patterns --> $DIR/qualified-path-params.rs:22:15 | LL | 0 ..= ::A::f:: => {} - | - ^^^^^^^^^^^^^^^^^^^^^ this is of type `fn() {S::f::}` but it should be `char` or numeric + | - ^^^^^^^^^^^^^^^^^^^^^ this is of type `{fn item S::f::: fn()}` but it should be `char` or numeric | | | this is of type `{integer}` diff --git a/tests/ui/reify-intrinsic.stderr b/tests/ui/reify-intrinsic.stderr index 310b6c224e0e7..b5b3b9e075c93 100644 --- a/tests/ui/reify-intrinsic.stderr +++ b/tests/ui/reify-intrinsic.stderr @@ -9,7 +9,7 @@ LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::tr = note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize` found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` -error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid +error[E0606]: casting `{fn item transmute::<_, _>: unsafe extern "rust-intrinsic" fn(_) -> _}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid --> $DIR/reify-intrinsic.rs:11:13 | LL | let _ = std::mem::transmute as unsafe extern "rust-intrinsic" fn(isize) -> usize; diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr index b10eded015f8c..db7adcaa84410 100644 --- a/tests/ui/resolve/privacy-enum-ctor.stderr +++ b/tests/ui/resolve/privacy-enum-ctor.stderr @@ -276,7 +276,7 @@ LL | let _: Z = Z::Fn; | expected due to this | = note: expected enum `Z` - found enum constructor `fn(u8) -> Z {Z::Fn}` + found enum constructor `{fn item Z::Fn: fn(u8) -> Z}` help: use parentheses to construct this tuple variant | LL | let _: Z = Z::Fn(/* u8 */); @@ -317,7 +317,7 @@ LL | let _: E = m::E::Fn; | expected due to this | = note: expected enum `E` - found enum constructor `fn(u8) -> E {E::Fn}` + found enum constructor `{fn item E::Fn: fn(u8) -> E}` help: use parentheses to construct this tuple variant | LL | let _: E = m::E::Fn(/* u8 */); @@ -358,7 +358,7 @@ LL | let _: E = E::Fn; | expected due to this | = note: expected enum `E` - found enum constructor `fn(u8) -> E {E::Fn}` + found enum constructor `{fn item E::Fn: fn(u8) -> E}` help: use parentheses to construct this tuple variant | LL | let _: E = E::Fn(/* u8 */); diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr index 52c700c326e30..3bf90a7ba67b7 100644 --- a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr @@ -23,7 +23,7 @@ error: implementation of `FnOnce` is not general enough LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... + = note: `{fn item id::<&'2 Foo<'_>>: fn(&'2 Foo<'_>) -> &'2 Foo<'_>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough @@ -32,7 +32,7 @@ error: implementation of `FnOnce` is not general enough LL | f: &id, | ^^^ implementation of `FnOnce` is not general enough | - = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... + = note: `{fn item id::<&Foo<'2>>: fn(&Foo<'2>) -> &Foo<'2>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&Foo<'2>,)>`, for some specific lifetime `'2` error: aborting due to 4 previous errors diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr index 77fc3f0412ebf..dab92e7c73f73 100644 --- a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr @@ -23,7 +23,7 @@ help: consider making the type lifetime-generic with a new `'a` lifetime LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ -error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` +error[E0605]: non-primitive cast: `{fn item non_elidable: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` --> $DIR/rfc1623-3.rs:10:6 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs index 1374ad935a388..9cb9ea7c2fa35 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs @@ -21,14 +21,14 @@ fn call_once(f: impl FnOnce()) { } fn main() { - call(foo); //~ ERROR expected a `Fn()` 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(foo); //~ ERROR expected a `Fn()` closure, found `{fn item foo: fn()}` + call_mut(foo); //~ expected a `FnMut()` closure, found `{fn item foo: fn()}` + call_once(foo); //~ expected a `FnOnce()` closure, found `{fn item foo: fn()}` call(foo_unsafe); - //~^ ERROR expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}` + //~^ expected a `Fn()` closure, found `{fn item foo_unsafe: unsafe fn()} call_mut(foo_unsafe); - //~^ ERROR expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}` + //~^ ERROR expected a `FnMut()` closure, found `{fn item foo_unsafe: unsafe fn()}` call_once(foo_unsafe); - //~^ ERROR expected a `FnOnce()` closure, found `unsafe fn() {foo_unsafe}` + //~^ ERROR expected a `FnOnce()` closure, found `{fn item foo_unsafe: unsafe fn()}` } diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr index 100f2048269dc..afb3134db1837 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr @@ -1,13 +1,13 @@ -error[E0277]: expected a `Fn()` closure, found `fn() {foo}` +error[E0277]: expected a `Fn()` closure, found `{fn item foo: fn()}` --> $DIR/fn-traits.rs:24:10 | LL | call(foo); - | ---- ^^^ expected an `Fn()` closure, found `fn() {foo}` + | ---- ^^^ expected an `Fn()` closure, found `{fn item foo: fn()}` | | | required by a bound introduced by this call | - = help: the trait `Fn<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `Fn<()>` is not implemented for fn item `{fn item foo: fn()}` + = note: wrap the `{fn item foo: fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call` --> $DIR/fn-traits.rs:11:17 @@ -15,16 +15,16 @@ note: required by a bound in `call` LL | fn call(f: impl Fn()) { | ^^^^ required by this bound in `call` -error[E0277]: expected a `FnMut()` closure, found `fn() {foo}` +error[E0277]: expected a `FnMut()` closure, found `{fn item foo: fn()}` --> $DIR/fn-traits.rs:25:14 | LL | call_mut(foo); - | -------- ^^^ expected an `FnMut()` closure, found `fn() {foo}` + | -------- ^^^ expected an `FnMut()` closure, found `{fn item foo: fn()}` | | | required by a bound introduced by this call | - = help: the trait `FnMut<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `FnMut<()>` is not implemented for fn item `{fn item foo: fn()}` + = note: wrap the `{fn item foo: fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_mut` --> $DIR/fn-traits.rs:15:21 @@ -32,16 +32,16 @@ note: required by a bound in `call_mut` LL | fn call_mut(f: impl FnMut()) { | ^^^^^^^ required by this bound in `call_mut` -error[E0277]: expected a `FnOnce()` closure, found `fn() {foo}` +error[E0277]: expected a `FnOnce()` closure, found `{fn item foo: fn()}` --> $DIR/fn-traits.rs:26:15 | LL | call_once(foo); - | --------- ^^^ expected an `FnOnce()` closure, found `fn() {foo}` + | --------- ^^^ expected an `FnOnce()` closure, found `{fn item foo: fn()}` | | | required by a bound introduced by this call | - = help: the trait `FnOnce<()>` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `FnOnce<()>` is not implemented for fn item `{fn item foo: fn()}` + = note: wrap the `{fn item foo: fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_once` --> $DIR/fn-traits.rs:19:22 @@ -49,7 +49,7 @@ note: required by a bound in `call_once` LL | fn call_once(f: impl FnOnce()) { | ^^^^^^^^ 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 `{fn item foo_unsafe: unsafe fn()}` --> $DIR/fn-traits.rs:28:10 | LL | call(foo_unsafe); @@ -57,9 +57,9 @@ LL | call(foo_unsafe); | | | required by a bound introduced by this call | - = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = help: the trait `Fn<()>` is not implemented for fn item `{fn item foo_unsafe: unsafe fn()}` = note: unsafe function cannot be called generically without an unsafe block - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` + = note: wrap the `{fn item foo_unsafe: unsafe fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call` --> $DIR/fn-traits.rs:11:17 @@ -67,7 +67,7 @@ note: required by a bound in `call` LL | fn call(f: impl Fn()) { | ^^^^ required by this bound in `call` -error[E0277]: expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}` +error[E0277]: expected a `FnMut()` closure, found `{fn item foo_unsafe: unsafe fn()}` --> $DIR/fn-traits.rs:30:14 | LL | call_mut(foo_unsafe); @@ -75,9 +75,9 @@ LL | call_mut(foo_unsafe); | | | required by a bound introduced by this call | - = help: the trait `FnMut<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = help: the trait `FnMut<()>` is not implemented for fn item `{fn item foo_unsafe: unsafe fn()}` = note: unsafe function cannot be called generically without an unsafe block - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` + = note: wrap the `{fn item foo_unsafe: unsafe fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_mut` --> $DIR/fn-traits.rs:15:21 @@ -85,7 +85,7 @@ note: required by a bound in `call_mut` LL | fn call_mut(f: impl FnMut()) { | ^^^^^^^ 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 `{fn item foo_unsafe: unsafe fn()}` --> $DIR/fn-traits.rs:32:15 | LL | call_once(foo_unsafe); @@ -93,9 +93,9 @@ LL | call_once(foo_unsafe); | | | required by a bound introduced by this call | - = help: the trait `FnOnce<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = help: the trait `FnOnce<()>` is not implemented for fn item `{fn item foo_unsafe: unsafe fn()}` = note: unsafe function cannot be called generically without an unsafe block - = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` + = note: wrap the `{fn item foo_unsafe: unsafe fn()}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_once` --> $DIR/fn-traits.rs:19:22 diff --git a/tests/ui/static/issue-5216.stderr b/tests/ui/static/issue-5216.stderr index 99c8b1aa131a7..8dedb4d374da7 100644 --- a/tests/ui/static/issue-5216.stderr +++ b/tests/ui/static/issue-5216.stderr @@ -7,7 +7,7 @@ LL | pub static C: S = S(f); | arguments to this struct are incorrect | = note: expected struct `Box<(dyn FnMut() + Sync + 'static)>` - found fn item `fn() {f}` + found fn item `{fn item f: fn()}` note: tuple struct defined here --> $DIR/issue-5216.rs:2:8 | @@ -21,7 +21,7 @@ LL | pub static D: T = g; | ^ expected `Box`, found fn item | = note: expected struct `Box<(dyn FnMut() + Sync + 'static)>` - found fn item `fn() {g}` + found fn item `{fn item g: fn()}` error: aborting due to 2 previous errors diff --git a/tests/ui/static/static-reference-to-fn-1.stderr b/tests/ui/static/static-reference-to-fn-1.stderr index 6bf64974ef59b..ef582becc9eeb 100644 --- a/tests/ui/static/static-reference-to-fn-1.stderr +++ b/tests/ui/static/static-reference-to-fn-1.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/static-reference-to-fn-1.rs:17:15 | LL | func: &foo, - | ^^^^ expected `&fn() -> Option`, found `&fn() -> Option {foo}` + | ^^^^ expected `&fn() -> Option`, found `&{fn item foo: fn() -> Option<...>}` | = note: expected reference `&fn() -> Option<_>` found reference `&fn() -> Option<_> {foo}` diff --git a/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr b/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr index 211cb1584ad7b..5493ddcc61772 100644 --- a/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr +++ b/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr @@ -7,7 +7,7 @@ LL | let x: i32 = MyS::foo; | expected due to this | = note: expected type `i32` - found fn item `fn() -> MyS {MyS::foo}` + found fn item `{fn item MyS::foo: fn() -> MyS}` help: try referring to the associated const `FOO` instead | LL | let x: i32 = MyS::FOO; @@ -22,19 +22,19 @@ LL | let z: i32 = i32::max; | expected due to this | = note: expected type `i32` - found fn item `fn(i32, i32) -> i32 {::max}` + found fn item `{fn item ::max: fn(i32, i32) -> i32}` help: try referring to the associated const `MAX` instead | LL | let z: i32 = i32::MAX; | ~~~ -error[E0369]: cannot subtract `{integer}` from `fn(i32, i32) -> i32 {::max}` +error[E0369]: cannot subtract `{integer}` from `{fn item ::max: fn(i32, i32) -> i32}` --> $DIR/assoc-ct-for-assoc-method.rs:22:27 | LL | let y: i32 = i32::max - 42; | -------- ^ -- {integer} | | - | fn(i32, i32) -> i32 {::max} + | {fn item ::max: fn(i32, i32) -> i32} | help: use parentheses to call this method | diff --git a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index dc4ec5d3ee28b..4e138612024a0 100644 --- a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -1,13 +1,13 @@ -error[E0277]: `fn() -> impl Future {foo}` is not a future +error[E0277]: `{fn item foo: fn() -> impl Future}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:10:9 | LL | bar(foo); - | --- ^^^ `fn() -> impl Future {foo}` is not a future + | --- ^^^ `{fn item foo: fn() -> impl Future}` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for fn item `fn() -> impl Future {foo}` - = note: fn() -> impl Future {foo} must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for fn item `{fn item foo: fn() -> impl Future}` + = note: {fn item foo: fn() -> impl Future} must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `bar` --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16 | diff --git a/tests/ui/suggestions/call-on-missing.stderr b/tests/ui/suggestions/call-on-missing.stderr index 1bab075dc9c1c..0c6a512dda5ff 100644 --- a/tests/ui/suggestions/call-on-missing.stderr +++ b/tests/ui/suggestions/call-on-missing.stderr @@ -1,15 +1,15 @@ -error[E0599]: no method named `bar` found for fn item `fn() -> Foo {foo}` in the current scope +error[E0599]: no method named `bar` found for fn item `{fn item foo: fn() -> Foo}` in the current scope --> $DIR/call-on-missing.rs:12:9 | LL | foo.bar(); - | ^^^ method not found in `fn() -> Foo {foo}` + | ^^^ method not found in `{fn item foo: fn() -> Foo}` | help: use parentheses to call this function | LL | foo().bar(); | ++ -error[E0609]: no field `i` on type `fn() -> Foo {foo}` +error[E0609]: no field `i` on type `{fn item foo: fn() -> Foo}` --> $DIR/call-on-missing.rs:16:9 | LL | foo.i; diff --git a/tests/ui/suggestions/call-on-unimplemented-ctor.rs b/tests/ui/suggestions/call-on-unimplemented-ctor.rs index 5f811044eb349..bfef396acdf59 100644 --- a/tests/ui/suggestions/call-on-unimplemented-ctor.rs +++ b/tests/ui/suggestions/call-on-unimplemented-ctor.rs @@ -1,7 +1,7 @@ fn main() { insert_resource(Marker); insert_resource(Time); - //~^ ERROR the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied + //~^ ERROR the trait bound `{fn item Time: fn(u32) -> Time}: Resource` is not satisfied //~| HELP use parentheses to construct this tuple struct } diff --git a/tests/ui/suggestions/call-on-unimplemented-ctor.stderr b/tests/ui/suggestions/call-on-unimplemented-ctor.stderr index 4124a0061726f..bff0fd0580a9c 100644 --- a/tests/ui/suggestions/call-on-unimplemented-ctor.stderr +++ b/tests/ui/suggestions/call-on-unimplemented-ctor.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `fn(u32) -> Time {Time}: Resource` is not satisfied +error[E0277]: the trait bound `{fn item Time: fn(u32) -> Time}: Resource` is not satisfied --> $DIR/call-on-unimplemented-ctor.rs:3:21 | LL | insert_resource(Time); - | --------------- ^^^^ the trait `Resource` is not implemented for fn item `fn(u32) -> Time {Time}` + | --------------- ^^^^ the trait `Resource` is not implemented for fn item `{fn item Time: fn(u32) -> Time}` | | | required by a bound introduced by this call | diff --git a/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 75a3ae1a83e2f..0e0d783b32197 100644 --- a/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `fn() -> impl T {foo}: T` is not satisfied +error[E0277]: the trait bound `{fn item foo: fn() -> impl T}: T` is not satisfied --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:17:9 | LL | bar(foo); - | --- ^^^ the trait `T` is not implemented for fn item `fn() -> impl T {foo}` + | --- ^^^ the trait `T` is not implemented for fn item `{fn item foo: fn() -> impl T}` | | | required by a bound introduced by this call | diff --git a/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 40bb87c8a4066..03e36524c8233 100644 --- a/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -10,7 +10,7 @@ LL | let _: usize = foo; | expected due to this | = note: expected type `usize` - found fn item `fn(usize, usize) -> usize {foo}` + found fn item `{fn item foo: fn(usize, usize) -> usize}` help: use parentheses to call this function | LL | let _: usize = foo(/* usize */, /* usize */); @@ -28,7 +28,7 @@ LL | let _: S = S; | expected due to this | = note: expected struct `S` - found struct constructor `fn(usize, usize) -> S {S}` + found struct constructor `{fn item S: fn(usize, usize) -> S}` help: use parentheses to construct this tuple struct | LL | let _: S = S(/* usize */, /* usize */); @@ -46,7 +46,7 @@ LL | let _: usize = bar; | expected due to this | = note: expected type `usize` - found fn item `fn() -> usize {bar}` + found fn item `{fn item bar: fn() -> usize}` help: use parentheses to call this function | LL | let _: usize = bar(); @@ -64,7 +64,7 @@ LL | let _: V = V; | expected due to this | = note: expected struct `V` - found struct constructor `fn() -> V {V}` + found struct constructor `{fn item V: fn() -> V}` help: use parentheses to construct this tuple struct | LL | let _: V = V(); @@ -82,7 +82,7 @@ LL | let _: usize = T::baz; | expected due to this | = note: expected type `usize` - found fn item `fn(usize, usize) -> usize {<_ as T>::baz}` + found fn item `{fn item <_ as T>::baz: fn(usize, usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = T::baz(/* usize */, /* usize */); @@ -100,7 +100,7 @@ LL | let _: usize = T::bat; | expected due to this | = note: expected type `usize` - found fn item `fn(usize) -> usize {<_ as T>::bat}` + found fn item `{fn item <_ as T>::bat: fn(usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = T::bat(/* usize */); @@ -118,7 +118,7 @@ LL | let _: E = E::A; | expected due to this | = note: expected enum `E` - found enum constructor `fn(usize) -> E {E::A}` + found enum constructor `{fn item E::A: fn(usize) -> E}` help: use parentheses to construct this tuple variant | LL | let _: E = E::A(/* usize */); @@ -142,7 +142,7 @@ LL | let _: usize = X::baz; | expected due to this | = note: expected type `usize` - found fn item `fn(usize, usize) -> usize {::baz}` + found fn item `{fn item ::baz: fn(usize, usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = X::baz(/* usize */, /* usize */); @@ -160,7 +160,7 @@ LL | let _: usize = X::bat; | expected due to this | = note: expected type `usize` - found fn item `fn(usize) -> usize {::bat}` + found fn item `{fn item ::bat: fn(usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = X::bat(/* usize */); @@ -178,7 +178,7 @@ LL | let _: usize = X::bax; | expected due to this | = note: expected type `usize` - found fn item `fn(usize) -> usize {::bax}` + found fn item `{fn item ::bax: fn(usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = X::bax(/* usize */); @@ -196,7 +196,7 @@ LL | let _: usize = X::bach; | expected due to this | = note: expected type `usize` - found fn item `fn(usize) -> usize {::bach}` + found fn item `{fn item ::bach: fn(usize) -> usize}` help: use parentheses to call this associated function | LL | let _: usize = X::bach(/* usize */); @@ -214,7 +214,7 @@ LL | let _: usize = X::ban; | expected due to this | = note: expected type `usize` - found fn item `for<'a> fn(&'a X) -> usize {::ban}` + found fn item `{fn item ::ban: for<'a> fn(&'a X) -> usize}` help: use parentheses to call this method | LL | let _: usize = X::ban(/* &X */); @@ -232,7 +232,7 @@ LL | let _: usize = X::bal; | expected due to this | = note: expected type `usize` - found fn item `for<'a> fn(&'a X) -> usize {::bal}` + found fn item `{fn item ::bal: for<'a> fn(&'a X) -> usize}` help: use parentheses to call this method | LL | let _: usize = X::bal(/* &X */); diff --git a/tests/ui/suggestions/issue-107860.stderr b/tests/ui/suggestions/issue-107860.stderr index 4be495da46b1f..10c3f8d9f306f 100644 --- a/tests/ui/suggestions/issue-107860.stderr +++ b/tests/ui/suggestions/issue-107860.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/issue-107860.rs:3:36 | LL | async fn str(T: &str) -> &str { &str } - | ^^^^ expected `&str`, found `&fn(&str) -> ... {str::<...>}` + | ^^^^ expected `&str`, found `&{fn item str::<_>: fn(...) -> ...}` | = note: expected reference `&str` - found reference `&for<'a> fn(&'a str) -> impl Future {str::<_>}` + found reference `&{fn item str::<_>: for<'a> fn(&'a str) -> impl Future}` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-109854.stderr b/tests/ui/suggestions/issue-109854.stderr index 52444cd4c45a9..62b6277873e8c 100644 --- a/tests/ui/suggestions/issue-109854.stderr +++ b/tests/ui/suggestions/issue-109854.stderr @@ -17,7 +17,7 @@ note: expected `usize`, found fn item LL | generate_setter, | ^^^^^^^^^^^^^^^ = note: expected type `usize` - found fn item `fn() {generate_setter}` + found fn item `{fn item generate_setter: fn()}` note: associated function defined here --> $SRC_DIR/alloc/src/string.rs:LL:COL help: remove the extra arguments diff --git a/tests/ui/suggestions/suggest-call-on-pat-mismatch.stderr b/tests/ui/suggestions/suggest-call-on-pat-mismatch.stderr index 7338312bab651..f29c257b30d04 100644 --- a/tests/ui/suggestions/suggest-call-on-pat-mismatch.stderr +++ b/tests/ui/suggestions/suggest-call-on-pat-mismatch.stderr @@ -2,11 +2,11 @@ error[E0308]: mismatched types --> $DIR/suggest-call-on-pat-mismatch.rs:7:12 | LL | if let E::One(var1, var2) = var { - | ^^^^^^^^^^^^^^^^^^ --- this expression has type `fn(i32, i32) -> E {E::One}` + | ^^^^^^^^^^^^^^^^^^ --- this expression has type `{fn item E::One: fn(i32, i32) -> E}` | | | expected enum constructor, found `E` | - = note: expected enum constructor `fn(i32, i32) -> E {E::One}` + = note: expected enum constructor `{fn item E::One: fn(i32, i32) -> E}` found enum `E` help: use parentheses to construct this tuple variant | @@ -17,11 +17,11 @@ error[E0308]: mismatched types --> $DIR/suggest-call-on-pat-mismatch.rs:13:9 | LL | let Some(x) = Some; - | ^^^^^^^ ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}` + | ^^^^^^^ ---- this expression has type `{fn item Option::<_>::Some: fn(_) -> Option<_>}` | | | expected enum constructor, found `Option<_>` | - = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}` + = note: expected enum constructor `{fn item Option::<_>::Some: fn(_) -> Option<_>}` found enum `Option<_>` help: use parentheses to construct this tuple variant | diff --git a/tests/ui/traits/fn-trait-cast-diagnostic.stderr b/tests/ui/traits/fn-trait-cast-diagnostic.stderr index 6851dcdd504d1..db56255eba69a 100644 --- a/tests/ui/traits/fn-trait-cast-diagnostic.stderr +++ b/tests/ui/traits/fn-trait-cast-diagnostic.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `fn() -> bool {example}: Foo` is not satisfied +error[E0277]: the trait bound `{fn item example: fn() -> bool}: Foo` is not satisfied --> $DIR/fn-trait-cast-diagnostic.rs:21:15 | LL | do_on_foo(example); - | --------- ^^^^^^^ the trait `Foo` is not implemented for fn item `fn() -> bool {example}` + | --------- ^^^^^^^ the trait `Foo` is not implemented for fn item `{fn item example: fn() -> bool}` | | | required by a bound introduced by this call | @@ -20,11 +20,11 @@ help: the trait `Foo` is implemented for fn pointer `fn() -> bool`, try casting LL | do_on_foo(example as fn() -> bool); | +++++++++++++++ -error[E0277]: the trait bound `fn() -> bool {example}: NoOtherFoo` is not satisfied +error[E0277]: the trait bound `{fn item example: fn() -> bool}: NoOtherFoo` is not satisfied --> $DIR/fn-trait-cast-diagnostic.rs:24:22 | LL | do_on_single_foo(example); - | ---------------- ^^^^^^^ the trait `NoOtherFoo` is not implemented for fn item `fn() -> bool {example}` + | ---------------- ^^^^^^^ the trait `NoOtherFoo` is not implemented for fn item `{fn item example: fn() -> bool}` | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/issue-99875.stderr b/tests/ui/traits/issue-99875.stderr index 29e87571561d8..35d5aa1c0f363 100644 --- a/tests/ui/traits/issue-99875.stderr +++ b/tests/ui/traits/issue-99875.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `fn(Argument) -> Return {function}: Trait` is not satisfied +error[E0277]: the trait bound `{fn item function: fn(Argument) -> Return}: Trait` is not satisfied --> $DIR/issue-99875.rs:12:11 | LL | takes(function); - | ----- ^^^^^^^^ the trait `Trait` is not implemented for fn item `fn(Argument) -> Return {function}` + | ----- ^^^^^^^^ the trait `Trait` is not implemented for fn item `{fn item function: fn(Argument) -> Return}` | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/next-solver/fn-trait.rs b/tests/ui/traits/next-solver/fn-trait.rs index 1e3d8a21c7ccf..a15aba6a19710 100644 --- a/tests/ui/traits/next-solver/fn-trait.rs +++ b/tests/ui/traits/next-solver/fn-trait.rs @@ -21,12 +21,12 @@ fn main() { //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32` //~| ERROR: type mismatch resolving ` i32 as FnOnce<()>>::Output == i32` require_fn(g); - //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32 {g}` - //~| ERROR: type mismatch resolving ` i32 {g} as FnOnce<()>>::Output == i32` + //~^ ERROR: expected a `Fn()` closure, found `{fn item g: extern "C" fn() -> i32}` + //~| ERROR: type mismatch resolving `<{fn item g: extern "C" fn() -> i32} as FnOnce<()>>::Output == i32` require_fn(g as extern "C" fn() -> i32); //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32` //~| ERROR: type mismatch resolving ` i32 as FnOnce<()>>::Output == i32` require_fn(h); - //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32 {h}` - //~| ERROR: type mismatch resolving ` i32 {h} as FnOnce<()>>::Output == i32` + //~^ ERROR: expected a `Fn()` closure, found `{fn item h: unsafe fn() -> i32}` + //~| ERROR: type mismatch resolving `<{fn item h: unsafe fn() -> i32} as FnOnce<()>>::Output == i32` } diff --git a/tests/ui/traits/next-solver/fn-trait.stderr b/tests/ui/traits/next-solver/fn-trait.stderr index e33487235e663..f66ddfb442c3e 100644 --- a/tests/ui/traits/next-solver/fn-trait.stderr +++ b/tests/ui/traits/next-solver/fn-trait.stderr @@ -29,23 +29,23 @@ note: required by a bound in `require_fn` LL | fn require_fn(_: impl Fn() -> i32) {} | ^^^ 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 `{fn item g: extern "C" fn() -> i32}` --> $DIR/fn-trait.rs:23:16 | LL | require_fn(g); - | ---------- ^ expected an `Fn()` closure, found `extern "C" fn() -> i32 {g}` + | ---------- ^ expected an `Fn()` closure, found `{fn item g: extern "C" fn() -> i32}` | | | required by a bound introduced by this call | - = help: the trait `Fn<()>` is not implemented for fn item `extern "C" fn() -> i32 {g}` - = note: wrap the `extern "C" fn() -> i32 {g}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `Fn<()>` is not implemented for fn item `{fn item g: extern "C" fn() -> i32}` + = note: wrap the `{fn item g: extern "C" fn() -> i32}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `require_fn` --> $DIR/fn-trait.rs:3:23 | LL | fn require_fn(_: impl Fn() -> i32) {} | ^^^^^^^^^^^ required by this bound in `require_fn` -error[E0271]: type mismatch resolving ` i32 {g} as FnOnce<()>>::Output == i32` +error[E0271]: type mismatch resolving `<{fn item g: extern "C" fn() -> i32} as FnOnce<()>>::Output == i32` --> $DIR/fn-trait.rs:23:16 | LL | require_fn(g); @@ -89,7 +89,7 @@ note: required by a bound in `require_fn` LL | fn require_fn(_: impl Fn() -> i32) {} | ^^^ 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 `{fn item h: unsafe fn() -> i32}` --> $DIR/fn-trait.rs:29:16 | LL | require_fn(h); @@ -97,16 +97,16 @@ LL | require_fn(h); | | | required by a bound introduced by this call | - = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() -> i32 {h}` + = help: the trait `Fn<()>` is not implemented for fn item `{fn item h: unsafe fn() -> i32}` = note: unsafe function cannot be called generically without an unsafe block - = note: wrap the `unsafe fn() -> i32 {h}` in a closure with no arguments: `|| { /* code */ }` + = note: wrap the `{fn item h: unsafe fn() -> i32}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `require_fn` --> $DIR/fn-trait.rs:3:23 | LL | fn require_fn(_: impl Fn() -> i32) {} | ^^^^^^^^^^^ required by this bound in `require_fn` -error[E0271]: type mismatch resolving ` i32 {h} as FnOnce<()>>::Output == i32` +error[E0271]: type mismatch resolving `<{fn item h: unsafe fn() -> i32} as FnOnce<()>>::Output == i32` --> $DIR/fn-trait.rs:29:16 | LL | require_fn(h); diff --git a/tests/ui/traits/unsend-future.stderr b/tests/ui/traits/unsend-future.stderr index 4462208cb4956..2b08f2c3c46bd 100644 --- a/tests/ui/traits/unsend-future.stderr +++ b/tests/ui/traits/unsend-future.stderr @@ -4,7 +4,7 @@ error: future cannot be sent between threads safely LL | require_handler(handler) | ^^^^^^^ future returned by `handler` is not `Send` | - = help: within `impl Future`, the trait `Send` is not implemented for `*const i32`, which is required by `fn() -> impl Future {handler}: Handler` + = help: within `impl Future`, the trait `Send` is not implemented for `*const i32`, which is required by `{fn item handler: fn() -> impl Future}: Handler` note: future is not `Send` as this value is used across an await --> $DIR/unsend-future.rs:15:14 | diff --git a/tests/ui/transmute/transmute-from-fn-item-types-error.stderr b/tests/ui/transmute/transmute-from-fn-item-types-error.stderr index aefe3fb8e25fd..797e2e98b8326 100644 --- a/tests/ui/transmute/transmute-from-fn-item-types-error.stderr +++ b/tests/ui/transmute/transmute-from-fn-item-types-error.stderr @@ -4,7 +4,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | let i = mem::transmute(bar); | ^^^^^^^^^^^^^^ | - = note: source type: `unsafe fn() {bar}` (0 bits) + = note: source type: `{fn item bar: unsafe fn()}` (0 bits) = note: target type: `i8` (8 bits) error[E0591]: can't transmute zero-sized type @@ -13,7 +13,7 @@ error[E0591]: can't transmute zero-sized type LL | let p = mem::transmute(foo); | ^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: source type: {fn item foo: unsafe fn() -> (i8, *const (), Option)} = note: target type: *const () = help: cast with `as` to a pointer instead @@ -23,7 +23,7 @@ error[E0591]: can't transmute zero-sized type LL | let of = mem::transmute(main); | ^^^^^^^^^^^^^^ | - = note: source type: fn() {main} + = note: source type: {fn item main: fn()} = note: target type: Option = help: cast with `as` to a pointer instead @@ -33,7 +33,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | mem::transmute::<_, u8>(main); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: `fn() {main}` (0 bits) + = note: source type: `{fn item main: fn()}` (0 bits) = note: target type: `u8` (8 bits) error[E0591]: can't transmute zero-sized type @@ -42,7 +42,7 @@ error[E0591]: can't transmute zero-sized type LL | mem::transmute::<_, *mut ()>(foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: source type: {fn item foo: unsafe fn() -> (i8, *const (), Option)} = note: target type: *mut () = help: cast with `as` to a pointer instead @@ -52,7 +52,7 @@ error[E0591]: can't transmute zero-sized type LL | mem::transmute::<_, fn()>(bar); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() {bar} + = note: source type: {fn item bar: unsafe fn()} = note: target type: fn() = help: cast with `as` to a pointer instead @@ -62,7 +62,7 @@ error[E0591]: can't transmute zero-sized type LL | mem::transmute::<_, *mut ()>(Some(foo)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: source type: {fn item foo: unsafe fn() -> (i8, *const (), Option)} = note: target type: *mut () = help: cast with `as` to a pointer instead @@ -72,7 +72,7 @@ error[E0591]: can't transmute zero-sized type LL | mem::transmute::<_, fn()>(Some(bar)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() {bar} + = note: source type: {fn item bar: unsafe fn()} = note: target type: fn() = help: cast with `as` to a pointer instead @@ -82,7 +82,7 @@ error[E0591]: can't transmute zero-sized type LL | mem::transmute::<_, Option>(Some(baz)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: source type: unsafe fn() {baz} + = note: source type: {fn item baz: unsafe fn()} = note: target type: Option = help: cast with `as` to a pointer instead diff --git a/tests/ui/type-alias-impl-trait/issue-98604.stderr b/tests/ui/type-alias-impl-trait/issue-98604.stderr index 2390b72535625..086491e42a6e4 100644 --- a/tests/ui/type-alias-impl-trait/issue-98604.stderr +++ b/tests/ui/type-alias-impl-trait/issue-98604.stderr @@ -4,7 +4,7 @@ error[E0271]: expected `test` to be a fn item that returns `Pin>>`, found future | - = note: required for the cast from `Box impl Future {test}>` to `Box<(dyn Fn() -> Pin + 'static)>> + 'static)>` + = note: required for the cast from `Box<{fn item test: fn() -> impl Future}>` to `Box<(dyn Fn() -> Pin + 'static)>> + 'static)>` error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/issue-98608.stderr b/tests/ui/type-alias-impl-trait/issue-98608.stderr index d5c56636f66e4..02ce68d5ec447 100644 --- a/tests/ui/type-alias-impl-trait/issue-98608.stderr +++ b/tests/ui/type-alias-impl-trait/issue-98608.stderr @@ -9,7 +9,7 @@ LL | let b: Box Box> = Box::new(hi); | = note: expected struct `Box` found opaque type `impl Sized` - = note: required for the cast from `Box impl Sized {hi}>` to `Box Box>` + = note: required for the cast from `Box<{fn item hi: fn() -> impl Sized}>` to `Box Box>` error: aborting due to 1 previous error diff --git a/tests/ui/typeck/escaping_bound_vars.stderr b/tests/ui/typeck/escaping_bound_vars.stderr index 8c7dcdb7f1618..0d8992b872153 100644 --- a/tests/ui/typeck/escaping_bound_vars.stderr +++ b/tests/ui/typeck/escaping_bound_vars.stderr @@ -24,13 +24,13 @@ help: this trait has no implementations, consider adding one LL | trait Elide { | ^^^^^^^^^^^^^^ -error[E0277]: cannot add `fn() {<() as Elide<(&(),)>>::call}` to `{integer}` +error[E0277]: cannot add `{fn item <() as Elide<(&(),)>>::call: fn()}` to `{integer}` --> $DIR/escaping_bound_vars.rs:11:18 | LL | (): Test<{ 1 + (<() as Elide(&())>::call) }>, - | ^ no implementation for `{integer} + fn() {<() as Elide<(&(),)>>::call}` + | ^ no implementation for `{integer} + {fn item <() as Elide<(&(),)>>::call: fn()}` | - = help: the trait `Add>::call}>` is not implemented for `{integer}` + = help: the trait `Add<{fn item <() as Elide<(&(),)>>::call: fn()}>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: > diff --git a/tests/ui/typeck/issue-107775.stderr b/tests/ui/typeck/issue-107775.stderr index 180b0183a3f2d..cf5563fb85fcc 100644 --- a/tests/ui/typeck/issue-107775.stderr +++ b/tests/ui/typeck/issue-107775.stderr @@ -2,9 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-107775.rs:35:16 | LL | map.insert(1, Struct::do_something); - | --- -------------------- this argument has type `fn(u8) -> Pin + Send>> {::do_something::<'_>}`... + | --- -------------------- this argument has type `{fn item ::do_something::<'_>: fn(u8) -> Pin + Send>>}`... | | - | ... which causes `map` to have type `HashMap<{integer}, fn(u8) -> Pin + Send>> {::do_something::<'_>}>` + | ... which causes `map` to have type `HashMap<{integer}, {fn item ::do_something::<'_>: fn(u8) -> Pin + Send>>}>` LL | Self { map } | ^^^ expected `HashMap Pin<...>>`, found `HashMap<{integer}, ...>` | diff --git a/tests/ui/typeck/issue-29124.stderr b/tests/ui/typeck/issue-29124.stderr index a837a7d2d62d1..ad3a4e5187287 100644 --- a/tests/ui/typeck/issue-29124.stderr +++ b/tests/ui/typeck/issue-29124.stderr @@ -1,14 +1,14 @@ -error[E0599]: no method named `x` found for fn item `fn() -> Ret {Obj::func}` in the current scope +error[E0599]: no method named `x` found for fn item `{fn item Obj::func: fn() -> Ret}` in the current scope --> $DIR/issue-29124.rs:15:15 | LL | Obj::func.x(); - | ^ method not found in `fn() -> Ret {Obj::func}` + | ^ method not found in `{fn item Obj::func: fn() -> Ret}` -error[E0599]: no method named `x` found for fn item `fn() -> Ret {func}` in the current scope +error[E0599]: no method named `x` found for fn item `{fn item func: fn() -> Ret}` in the current scope --> $DIR/issue-29124.rs:17:10 | LL | func.x(); - | ^ method not found in `fn() -> Ret {func}` + | ^ method not found in `{fn item func: fn() -> Ret}` error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/issue-87181/empty-tuple-method.rs b/tests/ui/typeck/issue-87181/empty-tuple-method.rs index 96b3f8dab8da7..03bb838693f5f 100644 --- a/tests/ui/typeck/issue-87181/empty-tuple-method.rs +++ b/tests/ui/typeck/issue-87181/empty-tuple-method.rs @@ -10,5 +10,5 @@ impl Foo { fn main() { let thing = Bar { bar: Foo }; thing.bar.foo(); - //~^ ERROR no method named `foo` found for struct constructor `fn() -> Foo {Foo}` in the current scope [E0599] + //~^ ERROR no method named `foo` found for struct constructor `{fn item Foo: fn() -> Foo}` in the current scope [E0599] } diff --git a/tests/ui/typeck/issue-87181/empty-tuple-method.stderr b/tests/ui/typeck/issue-87181/empty-tuple-method.stderr index a34ed08376a21..8fbd53d5878f3 100644 --- a/tests/ui/typeck/issue-87181/empty-tuple-method.stderr +++ b/tests/ui/typeck/issue-87181/empty-tuple-method.stderr @@ -1,8 +1,8 @@ -error[E0599]: no method named `foo` found for struct constructor `fn() -> Foo {Foo}` in the current scope +error[E0599]: no method named `foo` found for struct constructor `{fn item Foo: fn() -> Foo}` in the current scope --> $DIR/empty-tuple-method.rs:12:15 | LL | thing.bar.foo(); - | ^^^ method not found in `fn() -> Foo {Foo}` + | ^^^ method not found in `{fn item Foo: fn() -> Foo}` | help: use parentheses to construct this tuple struct | diff --git a/tests/ui/typeck/issue-87181/enum-variant.rs b/tests/ui/typeck/issue-87181/enum-variant.rs index ed01656ce72a3..828642a806492 100644 --- a/tests/ui/typeck/issue-87181/enum-variant.rs +++ b/tests/ui/typeck/issue-87181/enum-variant.rs @@ -12,5 +12,5 @@ impl Foo { fn main() { let thing = Bar { bar: Foo::Tup }; thing.bar.foo(); - //~^ ERROR no method named `foo` found for enum constructor `fn() -> Foo {Foo::Tup}` in the current scope [E0599] + //~^ ERROR no method named `foo` found for enum constructor `{fn item Foo::Tup: fn() -> Foo}` in the current scope [E0599] } diff --git a/tests/ui/typeck/issue-87181/enum-variant.stderr b/tests/ui/typeck/issue-87181/enum-variant.stderr index 800369b517655..f8a4ea333ee40 100644 --- a/tests/ui/typeck/issue-87181/enum-variant.stderr +++ b/tests/ui/typeck/issue-87181/enum-variant.stderr @@ -1,8 +1,8 @@ -error[E0599]: no method named `foo` found for enum constructor `fn() -> Foo {Foo::Tup}` in the current scope +error[E0599]: no method named `foo` found for enum constructor `{fn item Foo::Tup: fn() -> Foo}` in the current scope --> $DIR/enum-variant.rs:14:15 | LL | thing.bar.foo(); - | ^^^ method not found in `fn() -> Foo {Foo::Tup}` + | ^^^ method not found in `{fn item Foo::Tup: fn() -> Foo}` | help: use parentheses to construct this tuple variant | diff --git a/tests/ui/typeck/issue-87181/tuple-field.rs b/tests/ui/typeck/issue-87181/tuple-field.rs index 00e3b460ecf32..7741bfc41be81 100644 --- a/tests/ui/typeck/issue-87181/tuple-field.rs +++ b/tests/ui/typeck/issue-87181/tuple-field.rs @@ -10,5 +10,5 @@ impl Foo { fn main() { let thing = Bar { bar: Foo }; thing.bar.0; - //~^ ERROR no field `0` on type `fn(char, u16) -> Foo {Foo}` [E0609] + //~^ ERROR no field `0` on type `{fn item Foo: fn(char, u16) -> Foo}` [E0609] } diff --git a/tests/ui/typeck/issue-87181/tuple-field.stderr b/tests/ui/typeck/issue-87181/tuple-field.stderr index e4b5a155e49f9..715e1d5ae24e0 100644 --- a/tests/ui/typeck/issue-87181/tuple-field.stderr +++ b/tests/ui/typeck/issue-87181/tuple-field.stderr @@ -1,4 +1,4 @@ -error[E0609]: no field `0` on type `fn(char, u16) -> Foo {Foo}` +error[E0609]: no field `0` on type `{fn item Foo: fn(char, u16) -> Foo}` --> $DIR/tuple-field.rs:12:15 | LL | thing.bar.0; diff --git a/tests/ui/typeck/issue-87181/tuple-method.rs b/tests/ui/typeck/issue-87181/tuple-method.rs index 6310984438c69..5c9ad1538e13f 100644 --- a/tests/ui/typeck/issue-87181/tuple-method.rs +++ b/tests/ui/typeck/issue-87181/tuple-method.rs @@ -10,5 +10,5 @@ impl Foo { fn main() { let thing = Bar { bar: Foo }; thing.bar.foo(); - //~^ ERROR no method named `foo` found for struct constructor `fn(u8, i32) -> Foo {Foo}` in the current scope [E0599] + //~^ ERROR no method named `foo` found for struct constructor `{fn item Foo: fn(u8, i32) -> Foo}` in the current scope [E0599] } diff --git a/tests/ui/typeck/issue-87181/tuple-method.stderr b/tests/ui/typeck/issue-87181/tuple-method.stderr index 87145d9bbd634..b64f0b43cea48 100644 --- a/tests/ui/typeck/issue-87181/tuple-method.stderr +++ b/tests/ui/typeck/issue-87181/tuple-method.stderr @@ -1,8 +1,8 @@ -error[E0599]: no method named `foo` found for struct constructor `fn(u8, i32) -> Foo {Foo}` in the current scope +error[E0599]: no method named `foo` found for struct constructor `{fn item Foo: fn(u8, i32) -> Foo}` in the current scope --> $DIR/tuple-method.rs:12:15 | LL | thing.bar.foo(); - | ^^^ method not found in `fn(u8, i32) -> Foo {Foo}` + | ^^^ method not found in `{fn item Foo: fn(u8, i32) -> Foo}` error: aborting due to 1 previous error diff --git a/tests/ui/typeck/issue-96738.stderr b/tests/ui/typeck/issue-96738.stderr index 2bc8453dda74d..1a2564733d87a 100644 --- a/tests/ui/typeck/issue-96738.stderr +++ b/tests/ui/typeck/issue-96738.stderr @@ -1,10 +1,10 @@ -error[E0599]: no method named `nonexistent_method` found for enum constructor `fn(_) -> Option<_> {Option::<_>::Some}` in the current scope +error[E0599]: no method named `nonexistent_method` found for enum constructor `{fn item Option::<_>::Some: fn(_) -> Option<_>}` in the current scope --> $DIR/issue-96738.rs:2:10 | LL | Some.nonexistent_method(); - | ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}` + | ^^^^^^^^^^^^^^^^^^ method not found in `{fn item Option::<_>::Some: fn(_) -> Option<_>}` -error[E0609]: no field `nonexistent_field` on type `fn(_) -> Option<_> {Option::<_>::Some}` +error[E0609]: no field `nonexistent_field` on type `{fn item Option::<_>::Some: fn(_) -> Option<_>}` --> $DIR/issue-96738.rs:3:10 | LL | Some.nonexistent_field; diff --git a/tests/ui/typeck/while-type-error.stderr b/tests/ui/typeck/while-type-error.stderr index b67ec561531fe..a4b524d197308 100644 --- a/tests/ui/typeck/while-type-error.stderr +++ b/tests/ui/typeck/while-type-error.stderr @@ -5,7 +5,7 @@ LL | fn main() { while main { } } | ^^^^ expected `bool`, found fn item | = note: expected type `bool` - found fn item `fn() {main}` + found fn item `{fn item main: fn()}` error: aborting due to 1 previous error diff --git a/tests/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr b/tests/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr index d836af2b01495..b12a0f30424cd 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr @@ -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 `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21 | LL | let x = call_it(&square, 22); @@ -6,7 +6,7 @@ LL | let x = call_it(&square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:9:15 @@ -14,7 +14,7 @@ note: required by a bound in `call_it` LL | fn call_it isize>(_: &F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25 | LL | let y = call_it_mut(&mut square, 22); @@ -22,7 +22,7 @@ LL | let y = call_it_mut(&mut square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_mut` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:19 @@ -30,7 +30,7 @@ note: required by a bound in `call_it_mut` LL | fn call_it_mut isize>(_: &mut F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26 | LL | let z = call_it_once(square, 22); @@ -38,7 +38,7 @@ LL | let z = call_it_once(square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> unsafe fn(&'a isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_once` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:15:20 diff --git a/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr b/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr index c0dcf83a5bb06..8b34bd4a0a763 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr @@ -1,42 +1,42 @@ -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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-wrong-abi.rs:20:21 | 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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` note: required by a bound in `call_it` --> $DIR/unboxed-closures-wrong-abi.rs:9:15 | LL | fn call_it isize>(_: &F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-wrong-abi.rs:25:25 | 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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` note: required by a bound in `call_it_mut` --> $DIR/unboxed-closures-wrong-abi.rs:12:19 | LL | fn call_it_mut isize>(_: &mut F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` --> $DIR/unboxed-closures-wrong-abi.rs:30:26 | 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 `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `{fn item square: for<'a> extern "C" fn(&'a isize) -> isize}` note: required by a bound in `call_it_once` --> $DIR/unboxed-closures-wrong-abi.rs:15:20 | diff --git a/tests/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr b/tests/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr index d261c38f50c29..4ce7736a0ceb0 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr @@ -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 `{fn item square: unsafe fn(isize) -> isize}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:21:21 | LL | let x = call_it(&square, 22); @@ -6,7 +6,7 @@ LL | let x = call_it(&square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `unsafe fn(isize) -> isize {square}` + = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `{fn item square: unsafe fn(isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:10:15 @@ -14,7 +14,7 @@ note: required by a bound in `call_it` LL | fn call_it isize>(_: &F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: unsafe fn(isize) -> isize}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:26:25 | LL | let y = call_it_mut(&mut square, 22); @@ -22,7 +22,7 @@ LL | let y = call_it_mut(&mut square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `unsafe fn(isize) -> isize {square}` + = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `{fn item square: unsafe fn(isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_mut` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:19 @@ -30,7 +30,7 @@ note: required by a bound in `call_it_mut` LL | fn call_it_mut isize>(_: &mut F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^ 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 `{fn item square: unsafe fn(isize) -> isize}` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:31:26 | LL | let z = call_it_once(square, 22); @@ -38,7 +38,7 @@ LL | let z = call_it_once(square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `unsafe fn(isize) -> isize {square}` + = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `{fn item square: unsafe fn(isize) -> isize}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_once` --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:16:20 diff --git a/tests/ui/unsafe/initializing-ranged-via-ctor.rs b/tests/ui/unsafe/initializing-ranged-via-ctor.rs index ca44fa7e4e756..67c911bcf5799 100644 --- a/tests/ui/unsafe/initializing-ranged-via-ctor.rs +++ b/tests/ui/unsafe/initializing-ranged-via-ctor.rs @@ -7,5 +7,5 @@ struct NonZeroAndOneU8(u8); fn main() { println!("{:?}", Some(1).map(NonZeroAndOneU8).unwrap()); - //~^ ERROR found `unsafe fn(u8) -> NonZeroAndOneU8 {NonZeroAndOneU8}` + //~^ ERROR expected a `FnOnce({integer})` closure, found `{fn item NonZeroAndOneU8: unsafe fn(u8) -> NonZeroAndOneU8}` } diff --git a/tests/ui/unsafe/initializing-ranged-via-ctor.stderr b/tests/ui/unsafe/initializing-ranged-via-ctor.stderr index 56b112867cf04..6fe5a21552dda 100644 --- a/tests/ui/unsafe/initializing-ranged-via-ctor.stderr +++ b/tests/ui/unsafe/initializing-ranged-via-ctor.stderr @@ -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 `{fn item NonZeroAndOneU8: unsafe fn(u8) -> NonZeroAndOneU8}` --> $DIR/initializing-ranged-via-ctor.rs:9:34 | LL | println!("{:?}", Some(1).map(NonZeroAndOneU8).unwrap()); @@ -6,7 +6,7 @@ LL | println!("{:?}", Some(1).map(NonZeroAndOneU8).unwrap()); | | | required by a bound introduced by this call | - = help: the trait `FnOnce<({integer},)>` is not implemented for fn item `unsafe fn(u8) -> NonZeroAndOneU8 {NonZeroAndOneU8}` + = help: the trait `FnOnce<({integer},)>` is not implemented for fn item `{fn item NonZeroAndOneU8: unsafe fn(u8) -> NonZeroAndOneU8}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL