rust/compiler
Matthias Krüger 44def58274
Rollup merge of #136412 - estebank:fn-ptr-cast-suggestion, r=jieyouxu
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 12:31:58 +01:00
..
rustc
rustc_abi Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubilee 2025-01-17 04:36:09 +00:00
rustc_arena Add inherent versions of MaybeUninit methods for slices 2025-01-11 23:57:00 -05:00
rustc_ast Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
rustc_ast_ir
rustc_ast_lowering Rename tcx.ensure_with_value() to tcx.ensure_done() 2025-02-01 12:42:39 +11:00
rustc_ast_passes Refactor FnKind variant to hold &Fn 2025-01-28 11:22:25 -08:00
rustc_ast_pretty Refactor FnKind variant to hold &Fn 2025-01-28 11:22:25 -08:00
rustc_attr_data_structures Rename OptimizeAttr::None to Default 2025-01-24 19:34:01 +00:00
rustc_attr_parsing Run clippy --fix for unnecessary_map_or lint 2025-01-19 19:15:00 +00:00
rustc_baked_icu_data
rustc_borrowck Rollup merge of #136368 - estebank:listify, r=fee1-dead 2025-02-02 12:31:57 +01:00
rustc_builtin_macros Make comma separated lists of anything easier to make for errors 2025-01-31 20:36:44 +00:00
rustc_codegen_cranelift Rollup merge of #136279 - Zalathar:ensure-ok, r=oli-obk 2025-02-02 12:31:55 +01:00
rustc_codegen_gcc Auto merge of #136331 - jhpratt:rollup-curo1f4, r=jhpratt 2025-01-31 06:55:04 +00:00
rustc_codegen_llvm Add link attribute for Enzyme's FFI 2025-01-31 21:11:23 -05:00
rustc_codegen_ssa Rollup merge of #136279 - Zalathar:ensure-ok, r=oli-obk 2025-02-02 12:31:55 +01:00
rustc_const_eval Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obk 2025-02-01 16:41:03 +01:00
rustc_data_structures Overhaul to_readable_str. 2025-01-31 16:04:13 +11:00
rustc_driver
rustc_driver_impl Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
rustc_error_codes Auto merge of #133154 - estebank:issue-133137, r=wesleywiser 2025-01-25 11:41:21 +00:00
rustc_error_messages Convert some Into impls into From impls 2024-12-31 01:56:33 +00:00
rustc_errors Rollup merge of #136368 - estebank:listify, r=fee1-dead 2025-02-02 12:31:57 +01:00
rustc_expand Auto merge of #134478 - compiler-errors:attr-span, r=oli-obk 2025-01-22 14:46:41 +00:00
rustc_feature Rework rustc_dump_vtable 2025-01-30 15:30:04 +00:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Insert null checks for pointer dereferences when debug assertions are enabled 2025-01-31 11:13:34 +00:00
rustc_hir_analysis Rollup merge of #136368 - estebank:listify, r=fee1-dead 2025-02-02 12:31:57 +01:00
rustc_hir_pretty Eliminate PatKind::Path 2025-01-29 15:45:13 +00:00
rustc_hir_typeck Rollup merge of #136368 - estebank:listify, r=fee1-dead 2025-02-02 12:31:57 +01:00
rustc_incremental turn hir::ItemKind::Fn into a named-field variant 2025-01-04 11:35:31 +01:00
rustc_index Run clippy --fix for unnecessary_map_or lint 2025-01-19 19:15:00 +00:00
rustc_index_macros update rustc_index_macros feature handling 2024-12-19 20:32:12 +03:00
rustc_infer Auto merge of #135318 - compiler-errors:vtable-fixes, r=lcnr 2025-01-31 04:09:11 +00:00
rustc_interface Rename tcx.ensure_with_value() to tcx.ensure_done() 2025-02-01 12:42:39 +11:00
rustc_lexer
rustc_lint Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
rustc_lint_defs Make comma separated lists of anything easier to make for errors 2025-01-31 20:36:44 +00:00
rustc_llvm Auto merge of #136350 - matthiaskrgr:rollup-6eqfyvh, r=matthiaskrgr 2025-01-31 20:16:46 +00:00
rustc_log Avoid naming variables str 2025-01-07 14:30:02 +02:00
rustc_macros Rename ensure_forwards_result_if_red to return_result_from_ensure_ok 2025-02-01 12:42:41 +11:00
rustc_metadata Rename tcx.ensure_with_value() to tcx.ensure_done() 2025-02-01 12:42:39 +11:00
rustc_middle Rollup merge of #136368 - estebank:listify, r=fee1-dead 2025-02-02 12:31:57 +01:00
rustc_mir_build Rollup merge of #136328 - estebank:long-ty-path, r=jieyouxu,lqd 2025-02-02 12:31:56 +01:00
rustc_mir_dataflow Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
rustc_mir_transform Rollup merge of #136358 - clubby789:opt-none-noinline, r=saethlin 2025-02-02 12:31:57 +01:00
rustc_monomorphize Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
rustc_next_trait_solver introduce ty::Value 2025-01-30 17:47:44 +01:00
rustc_parse Rollup merge of #135882 - hkBst:master, r=estebank 2025-01-30 12:45:27 +01:00
rustc_parse_format use impl Into<String> 2025-01-29 09:48:08 +01:00
rustc_passes Rollup merge of #135840 - vayunbiyani:omit_intrinsic_unused_param_warning, r=oli-obk 2025-02-01 01:19:19 +01:00
rustc_pattern_analysis Get rid of mir::Const::from_ty_const 2025-01-20 04:26:44 +00:00
rustc_privacy Make comma separated lists of anything easier to make for errors 2025-01-31 20:36:44 +00:00
rustc_query_impl don't return an Option from try_find_dep_kind 2025-01-07 21:57:00 +01:00
rustc_query_system Properly note when query stack is being cut off 2025-01-16 19:12:22 +00:00
rustc_resolve Refactor FnKind variant to hold &Fn 2025-01-28 11:22:25 -08:00
rustc_sanitizers check the types in ty::Value to value conversion 2025-01-30 18:13:16 +01:00
rustc_serialize
rustc_session Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhpratt 2025-01-31 09:42:28 +00:00
rustc_smir Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obk 2025-02-01 16:41:03 +01:00
rustc_span Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obk 2025-02-01 16:41:03 +01:00
rustc_symbol_mangling Auto merge of #135318 - compiler-errors:vtable-fixes, r=lcnr 2025-01-31 04:09:11 +00:00
rustc_target Rollup merge of #136194 - taiki-e:bpf-clobber-abi, r=amanieu 2025-01-31 12:28:17 +01:00
rustc_trait_selection Rollup merge of #136412 - estebank:fn-ptr-cast-suggestion, r=jieyouxu 2025-02-02 12:31:58 +01:00
rustc_traits Auto merge of #136011 - compiler-errors:query-norm-vaniquishes-us, r=jackh726 2025-01-29 02:12:12 +00:00
rustc_transmute introduce ty::Value 2025-01-30 17:47:44 +01:00
rustc_ty_utils Rollup merge of #136279 - Zalathar:ensure-ok, r=oli-obk 2025-02-02 12:31:55 +01:00
rustc_type_ir introduce ty::Value 2025-01-30 17:47:44 +01:00
rustc_type_ir_macros
stable_mir Insert null checks for pointer dereferences when debug assertions are enabled 2025-01-31 11:13:34 +00:00