rust/tests/ui/fn
Esteban Küber 028a920c53 Tweak fn pointer suggestion span
Use a more targeted span when suggesting casting an `fn` item to an `fn` pointer.

```
error[E0308]: cannot coerce functions which must be inlined to function pointers
  --> $DIR/cast.rs:10:33
   |
LL |     let _: fn(isize) -> usize = callee;
   |            ------------------   ^^^^^^ cannot coerce functions which must be inlined to function pointers
   |            |
   |            expected due to this
   |
   = note: expected fn pointer `fn(_) -> _`
                 found fn item `fn(_) -> _ {callee}`
   = note: fn items are distinct from fn pointers
help: consider casting to a fn pointer
   |
LL |     let _: fn(isize) -> usize = callee as fn(isize) -> usize;
   |                                        +++++++++++++++++++++
```
```
error[E0308]: mismatched types
  --> $DIR/fn-pointer-mismatch.rs:42:30
   |
LL |     let d: &fn(u32) -> u32 = foo;
   |            ---------------   ^^^ expected `&fn(u32) -> u32`, found fn item
   |            |
   |            expected due to this
   |
   = note: expected reference `&fn(_) -> _`
                found fn item `fn(_) -> _ {foo}`
help: consider using a reference
   |
LL |     let d: &fn(u32) -> u32 = &foo;
   |                              +
```
Previously we'd point at the whole expression for replacement, instead of marking what was being added.

We could also modify the suggestions for `&(name as fn())`, but for that we require storing more accurate spans than we have now.
2025-02-02 00:46:02 +00:00
..
bad-main.rs
bad-main.stderr
dyn-fn-alignment.rs
expr-fn-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
expr-fn.rs
fn_def_coercion.rs only avoid blaming assignments from argument patterns 2025-01-06 16:12:11 -08:00
fn_def_coercion.stderr only avoid blaming assignments from argument patterns 2025-01-06 16:12:11 -08:00
fn_def_opaque_coercion_to_fn_ptr.rs
fn_def_opaque_coercion_to_fn_ptr.stderr show fnsig's output when there is difference 2024-07-06 23:29:58 +08:00
fn_def_opaque_coercion.rs
fn-bad-block-type.rs
fn-bad-block-type.stderr
fn-closure-mutable-capture.rs
fn-closure-mutable-capture.stderr
fn-compare-mismatch.rs
fn-compare-mismatch.stderr
fn-item-type.rs
fn-item-type.stderr Tweak parameter mismatch explanation to not say unknown 2024-11-25 03:04:07 +00:00
fn-pointer-mismatch.rs
fn-pointer-mismatch.stderr Tweak fn pointer suggestion span 2025-02-02 00:46:02 +00:00
fn-ptr-trait-int-float-infer-var.rs
fn-ptr-trait.rs
fn-recover-return-sign2.rs
fn-recover-return-sign2.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
fn-recover-return-sign.fixed Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
fn-recover-return-sign.rs
fn-recover-return-sign.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
fn-trait-formatting.rs
fn-trait-formatting.stderr
fun-call-variants.rs
implied-bounds-impl-header-projections.rs
implied-bounds-unnorm-associated-type-2.rs
implied-bounds-unnorm-associated-type-2.stderr make outlives constraints from generic arguments less boring 2025-01-06 16:12:11 -08:00
implied-bounds-unnorm-associated-type-3.rs
implied-bounds-unnorm-associated-type-4.rs
implied-bounds-unnorm-associated-type-4.stderr Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck 2024-07-26 14:41:56 -04:00
implied-bounds-unnorm-associated-type-5.rs Enforce supertrait outlives obligations hold when confirming impl 2024-08-05 09:55:14 -04:00
implied-bounds-unnorm-associated-type-5.stderr Enforce supertrait outlives obligations hold when confirming impl 2024-08-05 09:55:14 -04:00
implied-bounds-unnorm-associated-type.rs
implied-bounds-unnorm-associated-type.stderr Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck 2024-07-26 14:41:56 -04:00
issue-1451.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
issue-1900.rs
issue-1900.stderr
issue-3044.rs
issue-3044.stderr Use ordinal number in argument error 2024-07-14 13:50:09 +09:00
issue-3099.rs
issue-3099.stderr
issue-3904.rs
issue-39259.rs Rename HIR TypeBinding to AssocItemConstraint and related cleanup 2024-05-30 22:52:33 +02:00
issue-39259.stderr Auto merge of #125778 - estebank:issue-67100, r=compiler-errors 2024-06-03 08:14:03 +00:00
issue-80179.rs
issue-80179.stderr
keyword-order.rs
keyword-order.stderr
mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed Account for mutable borrow in argument suggestion 2025-01-24 23:34:34 +00:00
mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs Account for mutable borrow in argument suggestion 2025-01-24 23:34:34 +00:00
mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr Account for mutable borrow in argument suggestion 2025-01-24 23:34:34 +00:00
nested-function-names-issue-8587.rs
param-mismatch-no-names.rs Tweak parameter mismatch explanation to not say unknown 2024-11-25 03:04:07 +00:00
param-mismatch-no-names.stderr Tweak parameter mismatch explanation to not say unknown 2024-11-25 03:04:07 +00:00
signature-error-reporting-under-verbose.rs
signature-error-reporting-under-verbose.stderr
suggest-return-closure.rs
suggest-return-closure.stderr More accurate mutability suggestion 2024-07-04 05:36:34 +00:00
suggest-return-future.rs
suggest-return-future.stderr