From 5ae8e238169586d8af4bb61b980c2bd4bfb71b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 6 Jan 2023 20:15:10 +0000 Subject: [PATCH] Mention fn coercion rules (needs to be expanded) --- .../rustc_infer/src/infer/error_reporting/mod.rs | 12 ++++++++++++ .../src/infer/error_reporting/note_and_explain.rs | 7 +++++++ compiler/rustc_middle/src/ty/error.rs | 2 +- .../argument-suggestions/two-mismatch-notes.stderr | 1 + .../associated-types/associated-types-eq-hr.stderr | 8 ++++---- tests/ui/associated-types/issue-87261.rs | 6 +++--- tests/ui/associated-types/issue-87261.stderr | 6 +++--- tests/ui/c-variadic/variadic-ffi-1.stderr | 2 ++ tests/ui/fn/fn-pointer-mismatch.stderr | 1 + .../ui/fn/signature-error-reporting-under-verbose.rs | 1 + .../signature-error-reporting-under-verbose.stderr | 1 + .../collections-project-default.stderr | 1 + .../issue-79422.extended.stderr | 4 ++-- .../issue-62203-hrtb-ice.stderr | 4 ++-- tests/ui/impl-trait/equality2.stderr | 2 ++ tests/ui/issues/issue-10764.stderr | 1 + tests/ui/issues/issue-39970.rs | 2 +- tests/ui/issues/issue-39970.stderr | 4 ++-- tests/ui/mismatched_types/normalize-fn-sig.stderr | 1 + ...region-lifetime-bounds-on-fns-where-clause.stderr | 1 + ...ltiple-lifetime-bounds-on-fns-where-clause.stderr | 1 + .../regions-fn-subtyping-return-static-fail.stderr | 1 + .../ui/regions/regions-lifetime-bounds-on-fns.stderr | 1 + tests/ui/reify-intrinsic.stderr | 1 + .../rfc-2396-target_feature-11/fn-ptr.mir.stderr | 1 + .../rfc-2396-target_feature-11/fn-ptr.thir.stderr | 1 + tests/ui/static/static-reference-to-fn-1.stderr | 1 + 27 files changed, 56 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 8ebcd3d54aa..554a70265d4 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1865,6 +1865,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.check_and_note_conflicting_crates(diag, terr); self.note_and_explain_type_err(diag, terr, cause, span, cause.body_id.to_def_id()); + if let Some(exp_found) = exp_found + && let exp_found = TypeError::Sorts(exp_found) + && exp_found != terr + { + self.note_and_explain_type_err( + diag, + exp_found, + cause, + span, + cause.body_id.to_def_id(), + ); + } if let Some(ValuePairs::PolyTraitRefs(exp_found)) = values && let ty::Closure(def_id, _) = exp_found.expected.skip_binder().self_ty().kind() diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index e18cfb93bed..39b3c98f0a5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -218,6 +218,13 @@ impl Trait for X { ); } } + (ty::FnPtr(_), ty::FnDef(def, _)) + if let hir::def::DefKind::Fn = tcx.def_kind(def) => { + diag.note( + "when the arguments and return types match, functions can be coerced \ + to function pointers", + ); + } _ => {} } debug!( diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 6229c0072f2..d188199773a 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -28,7 +28,7 @@ impl ExpectedFound { } // Data structures used in type unification -#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift)] +#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, Lift, PartialEq, Eq)] #[rustc_pass_by_value] pub enum TypeError<'tcx> { Mismatch, diff --git a/tests/ui/argument-suggestions/two-mismatch-notes.stderr b/tests/ui/argument-suggestions/two-mismatch-notes.stderr index 70cc60255c7..38cf23ddc38 100644 --- a/tests/ui/argument-suggestions/two-mismatch-notes.stderr +++ b/tests/ui/argument-suggestions/two-mismatch-notes.stderr @@ -11,6 +11,7 @@ LL | foo(f, w); | ^ = note: expected fn pointer `fn(i32)` found fn item `fn(u32) {f}` + = note: when the arguments and return types match, functions can be coerced to function pointers note: expected `Wrapper`, found `Wrapper` --> $DIR/two-mismatch-notes.rs:10:12 | diff --git a/tests/ui/associated-types/associated-types-eq-hr.stderr b/tests/ui/associated-types/associated-types-eq-hr.stderr index 6cff403b318..99db0c1bf3b 100644 --- a/tests/ui/associated-types/associated-types-eq-hr.stderr +++ b/tests/ui/associated-types/associated-types-eq-hr.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `for<'x> >::A == &'x isize` +error[E0271]: type mismatch resolving `>::A == &isize` --> $DIR/associated-types-eq-hr.rs:87:11 | LL | foo::(); - | ^^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x isize` + | ^^^^^^^^^^ type mismatch resolving `>::A == &isize` | note: expected this to be `&isize` --> $DIR/associated-types-eq-hr.rs:26:14 @@ -20,11 +20,11 @@ LL | where LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` -error[E0271]: type mismatch resolving `for<'x> >::A == &'x usize` +error[E0271]: type mismatch resolving `>::A == &usize` --> $DIR/associated-types-eq-hr.rs:91:11 | LL | bar::(); - | ^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x usize` + | ^^^^^^^^^ type mismatch resolving `>::A == &usize` | note: expected this to be `&usize` --> $DIR/associated-types-eq-hr.rs:14:14 diff --git a/tests/ui/associated-types/issue-87261.rs b/tests/ui/associated-types/issue-87261.rs index e8548d402fa..384561f8ccd 100644 --- a/tests/ui/associated-types/issue-87261.rs +++ b/tests/ui/associated-types/issue-87261.rs @@ -77,10 +77,10 @@ where fn main() { accepts_trait(returns_opaque()); - //~^ ERROR type mismatch resolving `::Associated == ()` + //~^ ERROR type mismatch resolving `::Associated == ()` accepts_trait(returns_opaque_derived()); - //~^ ERROR type mismatch resolving `::Associated == ()` + //~^ ERROR type mismatch resolving `::Associated == ()` accepts_trait(returns_opaque_foo()); //~^ ERROR type mismatch resolving `::Associated == ()` @@ -89,7 +89,7 @@ fn main() { //~^ ERROR type mismatch resolving `::Associated == ()` accepts_generic_trait(returns_opaque_generic()); - //~^ ERROR type mismatch resolving ` + 'static as GenericTrait<()>>::Associated == ()` + //~^ ERROR type mismatch resolving ` as GenericTrait<()>>::Associated == ()` accepts_generic_trait(returns_opaque_generic_foo()); //~^ ERROR type mismatch resolving ` + Foo as GenericTrait<()>>::Associated == ()` diff --git a/tests/ui/associated-types/issue-87261.stderr b/tests/ui/associated-types/issue-87261.stderr index 2cce6b94702..f5c6d82471a 100644 --- a/tests/ui/associated-types/issue-87261.stderr +++ b/tests/ui/associated-types/issue-87261.stderr @@ -132,7 +132,7 @@ note: required by a bound in `accepts_generic_trait` LL | fn accepts_generic_trait>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait` -error[E0271]: type mismatch resolving `::Associated == ()` +error[E0271]: type mismatch resolving `::Associated == ()` --> $DIR/issue-87261.rs:79:19 | LL | fn returns_opaque() -> impl Trait + 'static { @@ -155,7 +155,7 @@ help: consider constraining the associated type ` LL | fn returns_opaque() -> impl Trait + 'static { | +++++++++++++++++ -error[E0271]: type mismatch resolving `::Associated == ()` +error[E0271]: type mismatch resolving `::Associated == ()` --> $DIR/issue-87261.rs:82:19 | LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static { @@ -222,7 +222,7 @@ note: required by a bound in `accepts_trait` LL | fn accepts_trait>(_: T) {} | ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait` -error[E0271]: type mismatch resolving ` + 'static as GenericTrait<()>>::Associated == ()` +error[E0271]: type mismatch resolving ` as GenericTrait<()>>::Associated == ()` --> $DIR/issue-87261.rs:91:27 | LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static { diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index 4beea83d8a5..c7899338197 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -46,6 +46,7 @@ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; | = note: expected fn pointer `unsafe extern "C" fn(_, _)` found fn item `unsafe extern "C" fn(_, _, ...) {foo}` + = note: when the arguments and return types match, functions can be coerced to function pointers error[E0308]: mismatched types --> $DIR/variadic-ffi-1.rs:26:54 @@ -57,6 +58,7 @@ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | = note: expected fn pointer `extern "C" fn(_, _, ...)` found fn item `extern "C" fn(_, _) {bar}` + = note: when the arguments and return types match, functions can be coerced to function pointers error[E0617]: can't pass `f32` to variadic function --> $DIR/variadic-ffi-1.rs:28:19 diff --git a/tests/ui/fn/fn-pointer-mismatch.stderr b/tests/ui/fn/fn-pointer-mismatch.stderr index 74f79f6df5a..bed59d4af6d 100644 --- a/tests/ui/fn/fn-pointer-mismatch.stderr +++ b/tests/ui/fn/fn-pointer-mismatch.stderr @@ -78,6 +78,7 @@ LL | let e: &fn(u32) -> u32 = &foo; = note: expected reference `&fn(u32) -> u32` found reference `&fn(u32) -> u32 {foo}` = note: fn items are distinct from fn pointers + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to 6 previous errors diff --git a/tests/ui/fn/signature-error-reporting-under-verbose.rs b/tests/ui/fn/signature-error-reporting-under-verbose.rs index d00cbd8a0f2..12ff113c913 100644 --- a/tests/ui/fn/signature-error-reporting-under-verbose.rs +++ b/tests/ui/fn/signature-error-reporting-under-verbose.rs @@ -12,4 +12,5 @@ fn main() { //~| NOTE expected fn pointer, found fn item //~| NOTE expected fn pointer `fn(i32, u32)` //~| NOTE arguments to this function are incorrect + //~| NOTE when the arguments and return types match, functions can be coerced to function pointers } diff --git a/tests/ui/fn/signature-error-reporting-under-verbose.stderr b/tests/ui/fn/signature-error-reporting-under-verbose.stderr index 067ee824d5d..f4498db7259 100644 --- a/tests/ui/fn/signature-error-reporting-under-verbose.stderr +++ b/tests/ui/fn/signature-error-reporting-under-verbose.stderr @@ -8,6 +8,7 @@ LL | needs_ptr(foo); | = note: expected fn pointer `fn(i32, u32)` found fn item `fn(i32, i32) {foo}` + = note: when the arguments and return types match, functions can be coerced to function pointers note: function defined here --> $DIR/signature-error-reporting-under-verbose.rs:5:4 | diff --git a/tests/ui/generic-associated-types/collections-project-default.stderr b/tests/ui/generic-associated-types/collections-project-default.stderr index 5701017dc34..9aa0b239e47 100644 --- a/tests/ui/generic-associated-types/collections-project-default.stderr +++ b/tests/ui/generic-associated-types/collections-project-default.stderr @@ -9,6 +9,7 @@ LL | res | = note: expected associated type `>::Sibling` found associated type `<>::Family as CollectionFamily>::Member` + = note: an associated type was expected, but a different one was found error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/issue-79422.extended.stderr b/tests/ui/generic-associated-types/issue-79422.extended.stderr index d79de0ca627..04184fce921 100644 --- a/tests/ui/generic-associated-types/issue-79422.extended.stderr +++ b/tests/ui/generic-associated-types/issue-79422.extended.stderr @@ -14,11 +14,11 @@ help: add missing lifetime argument LL | as Box = dyn RefCont<'_, u8>>>; | ++++ -error[E0271]: type mismatch resolving ` as MapLike>::VRefCont<'_> == (dyn RefCont<'_, u8> + 'static)` +error[E0271]: type mismatch resolving ` as MapLike>::VRefCont<'_> == dyn RefCont<'_, u8>` --> $DIR/issue-79422.rs:44:13 | LL | let m = Box::new(std::collections::BTreeMap::::new()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving ` as MapLike>::VRefCont<'_> == (dyn RefCont<'_, u8> + 'static)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving ` as MapLike>::VRefCont<'_> == dyn RefCont<'_, u8>` | note: expected this to be `(dyn RefCont<'_, u8> + 'static)` --> $DIR/issue-79422.rs:28:25 diff --git a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr b/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr index 01d48ab59af..86198c3f7fd 100644 --- a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr +++ b/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` +error[E0271]: type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` --> $DIR/issue-62203-hrtb-ice.rs:39:9 | LL | let v = Unit2.m( @@ -10,7 +10,7 @@ LL | | f: |x| { ... | LL | | }, LL | | }, - | |_________^ type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` + | |_________^ type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` | note: expected this to be `<_ as Ty<'_>>::V` --> $DIR/issue-62203-hrtb-ice.rs:21:14 diff --git a/tests/ui/impl-trait/equality2.stderr b/tests/ui/impl-trait/equality2.stderr index e399a61023d..52f25d2458c 100644 --- a/tests/ui/impl-trait/equality2.stderr +++ b/tests/ui/impl-trait/equality2.stderr @@ -54,6 +54,7 @@ LL | x = (x.1, | = note: expected opaque type `impl Foo` (`u32`) found opaque type `impl Foo` (`i32`) + = note: distinct uses of `impl Trait` result in different opaque types error[E0308]: mismatched types --> $DIR/equality2.rs:41:10 @@ -69,6 +70,7 @@ LL | x.0); | = note: expected opaque type `impl Foo` (`i32`) found opaque type `impl Foo` (`u32`) + = note: distinct uses of `impl Trait` result in different opaque types error: aborting due to 4 previous errors; 1 warning emitted diff --git a/tests/ui/issues/issue-10764.stderr b/tests/ui/issues/issue-10764.stderr index 4d8a85a1397..fcb45affe2c 100644 --- a/tests/ui/issues/issue-10764.stderr +++ b/tests/ui/issues/issue-10764.stderr @@ -8,6 +8,7 @@ LL | fn main() { f(bar) } | = note: expected fn pointer `fn()` found fn item `extern "C" fn() {bar}` + = note: when the arguments and return types match, functions can be coerced to function pointers note: function defined here --> $DIR/issue-10764.rs:1:4 | diff --git a/tests/ui/issues/issue-39970.rs b/tests/ui/issues/issue-39970.rs index f51e3b522e1..40d3ae30a87 100644 --- a/tests/ui/issues/issue-39970.rs +++ b/tests/ui/issues/issue-39970.rs @@ -17,5 +17,5 @@ impl Visit for () where fn main() { <() as Visit>::visit(); - //~^ ERROR type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` + //~^ ERROR type mismatch resolving `<() as Array<'a>>::Element == ()` } diff --git a/tests/ui/issues/issue-39970.stderr b/tests/ui/issues/issue-39970.stderr index 0cabdf7f234..8344b88c3be 100644 --- a/tests/ui/issues/issue-39970.stderr +++ b/tests/ui/issues/issue-39970.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` +error[E0271]: type mismatch resolving `<() as Array<'a>>::Element == ()` --> $DIR/issue-39970.rs:19:5 | LL | <() as Visit>::visit(); - | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` + | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array<'a>>::Element == ()` | note: expected this to be `()` --> $DIR/issue-39970.rs:10:20 diff --git a/tests/ui/mismatched_types/normalize-fn-sig.stderr b/tests/ui/mismatched_types/normalize-fn-sig.stderr index 252e56387ba..e3a0646550c 100644 --- a/tests/ui/mismatched_types/normalize-fn-sig.stderr +++ b/tests/ui/mismatched_types/normalize-fn-sig.stderr @@ -8,6 +8,7 @@ LL | needs_i32_ref_fn(foo::<()>); | = note: expected fn pointer `fn(&'static i32, i32)` found fn item `fn(i32, &'static i32) {foo::<()>}` + = note: when the arguments and return types match, functions can be coerced to function pointers note: function defined here --> $DIR/normalize-fn-sig.rs:11:4 | diff --git a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr index 3b62c7b61c1..bb5bc6f66a5 100644 --- a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr @@ -6,6 +6,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error diff --git a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr index 8a18a234b5c..dbe9e9b1a2e 100644 --- a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -6,6 +6,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | = note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)` found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}` + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error diff --git a/tests/ui/regions/regions-fn-subtyping-return-static-fail.stderr b/tests/ui/regions/regions-fn-subtyping-return-static-fail.stderr index 8d82ff958ff..766a3d0337c 100644 --- a/tests/ui/regions/regions-fn-subtyping-return-static-fail.stderr +++ b/tests/ui/regions/regions-fn-subtyping-return-static-fail.stderr @@ -8,6 +8,7 @@ LL | want_G(baz); | = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` found fn item `for<'a> fn(&'a S) -> &'a S {baz}` + = note: when the arguments and return types match, functions can be coerced to function pointers note: function defined here --> $DIR/regions-fn-subtyping-return-static-fail.rs:20:4 | diff --git a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr index 17a9019436a..df0fd069edc 100644 --- a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr @@ -6,6 +6,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error diff --git a/tests/ui/reify-intrinsic.stderr b/tests/ui/reify-intrinsic.stderr index 310b6c224e0..9f9034a30c7 100644 --- a/tests/ui/reify-intrinsic.stderr +++ b/tests/ui/reify-intrinsic.stderr @@ -8,6 +8,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::<_, _>}` + = note: when the arguments and return types match, functions can be coerced to function pointers error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid --> $DIR/reify-intrinsic.rs:11:13 diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr index 07f6dc906c6..36561ab91ee 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.mir.stderr @@ -15,6 +15,7 @@ LL | let foo: fn() = foo; found fn item `fn() {foo}` = note: fn items are distinct from fn pointers = note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr index 07f6dc906c6..36561ab91ee 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr @@ -15,6 +15,7 @@ LL | let foo: fn() = foo; found fn item `fn() {foo}` = note: fn items are distinct from fn pointers = note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error diff --git a/tests/ui/static/static-reference-to-fn-1.stderr b/tests/ui/static/static-reference-to-fn-1.stderr index ea4c7b41995..a75c7438cb7 100644 --- a/tests/ui/static/static-reference-to-fn-1.stderr +++ b/tests/ui/static/static-reference-to-fn-1.stderr @@ -10,6 +10,7 @@ LL | func: &foo, = note: expected reference `&fn() -> Option` found reference `&fn() -> Option {foo}` = note: fn items are distinct from fn pointers + = note: when the arguments and return types match, functions can be coerced to function pointers error: aborting due to previous error