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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-main.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
dyn-fn-alignment.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type 2024-04-23 14:38:17 +00:00
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 Register hidden types when equating function definitions in coercion 2024-04-24 10:05:33 +00:00
fn-bad-block-type.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
fn-bad-block-type.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
fn-closure-mutable-capture.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-closure-mutable-capture.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
fn-compare-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-compare-mismatch.stderr improve fn pointer notes 2023-01-26 05:07:34 +00:00
fn-item-type.rs Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
fn-item-type.stderr Tweak parameter mismatch explanation to not say unknown 2024-11-25 03:04:07 +00:00
fn-pointer-mismatch.rs recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
fn-ptr-trait.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
fn-recover-return-sign2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
fn-trait-formatting.stderr Use parenthetical notation for Fn traits 2024-05-29 22:26:54 +00:00
fun-call-variants.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
implied-bounds-impl-header-projections.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
implied-bounds-unnorm-associated-type-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
implied-bounds-unnorm-associated-type-4.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 Move some tests 2024-03-31 14:58:17 -03:00
issue-1900.stderr Move some tests 2024-03-31 14:58:17 -03:00
issue-3044.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-3044.stderr Use ordinal number in argument error 2024-07-14 13:50:09 +09:00
issue-3099.rs Move tests 2023-05-08 17:58:01 -03:00
issue-3099.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-3904.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80179.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
keyword-order.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
keyword-order.stderr Add explanatory note to 'expected item' error 2023-09-06 09:05:07 +05:30
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
signature-error-reporting-under-verbose.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
suggest-return-closure.rs Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +00:00
suggest-return-closure.stderr More accurate mutability suggestion 2024-07-04 05:36:34 +00:00
suggest-return-future.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
suggest-return-future.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00