mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-02 21:17:39 +00:00
![]() 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. |
||
---|---|---|
.. | ||
bad-main.rs | ||
bad-main.stderr | ||
dyn-fn-alignment.rs | ||
expr-fn-panic.rs | ||
expr-fn.rs | ||
fn_def_coercion.rs | ||
fn_def_coercion.stderr | ||
fn_def_opaque_coercion_to_fn_ptr.rs | ||
fn_def_opaque_coercion_to_fn_ptr.stderr | ||
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 | ||
fn-pointer-mismatch.rs | ||
fn-pointer-mismatch.stderr | ||
fn-ptr-trait-int-float-infer-var.rs | ||
fn-ptr-trait.rs | ||
fn-recover-return-sign2.rs | ||
fn-recover-return-sign2.stderr | ||
fn-recover-return-sign.fixed | ||
fn-recover-return-sign.rs | ||
fn-recover-return-sign.stderr | ||
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 | ||
implied-bounds-unnorm-associated-type-3.rs | ||
implied-bounds-unnorm-associated-type-4.rs | ||
implied-bounds-unnorm-associated-type-4.stderr | ||
implied-bounds-unnorm-associated-type-5.rs | ||
implied-bounds-unnorm-associated-type-5.stderr | ||
implied-bounds-unnorm-associated-type.rs | ||
implied-bounds-unnorm-associated-type.stderr | ||
issue-1451.rs | ||
issue-1900.rs | ||
issue-1900.stderr | ||
issue-3044.rs | ||
issue-3044.stderr | ||
issue-3099.rs | ||
issue-3099.stderr | ||
issue-3904.rs | ||
issue-39259.rs | ||
issue-39259.stderr | ||
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 | ||
mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs | ||
mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr | ||
nested-function-names-issue-8587.rs | ||
param-mismatch-no-names.rs | ||
param-mismatch-no-names.stderr | ||
signature-error-reporting-under-verbose.rs | ||
signature-error-reporting-under-verbose.stderr | ||
suggest-return-closure.rs | ||
suggest-return-closure.stderr | ||
suggest-return-future.rs | ||
suggest-return-future.stderr |