rust/tests/ui/fn
Matthias Krüger abcf400a28
Rollup merge of #124297 - oli-obk:define_opaque_types13, r=jackh726
Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type

r? `@compiler-errors`

This accepts more code on stable. It is now possible to have match arms return a function item `foo` and a different function item `bar` in another, and that will constrain OpaqueTypeInDefiningScope to have the hidden type ConcreteType and make the type of the match arms a function pointer that matches the signature. So the following function will now compile, but on master it errors with a type mismatch on the second match arm

```rust
fn foo<T>(t: T) -> T {
    t
}

fn bar<T>(t: T) -> T {
    t
}

fn k() -> impl Sized {
    fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F {
        f
    }
    let x = match true {
        true => {
            let f = foo;
            bind(k(), f)
        }
        false => bar::<()>,
    };
    todo!()
}
```

cc https://github.com/rust-lang/rust/issues/116652

This is very similar to https://github.com/rust-lang/rust/pull/123794, and with the same rationale:

> this is for consistency with `-Znext-solver`. the new solver does not have the concept of "non-defining use of opaque" right now and we would like to ideally keep it that way. Moving to `DefineOpaqueTypes::Yes` in more cases removes subtlety from the type system. Right now we have to be careful when relating `Opaque` with another type as the behavior changes depending on whether we later use the `Opaque` or its hidden type directly (even though they are equal), if that later use is with `DefineOpaqueTypes::No`*
2024-05-23 14:09:22 +02:00
..
bad-main.rs
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 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
expr-fn.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +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
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
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 Refactored a few bits: 2024-03-15 13:37:41 +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 recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05: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-sign.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +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
fn-recover-return-sign2.rs
fn-recover-return-sign2.stderr
fn-trait-formatting.rs Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
fn-trait-formatting.stderr Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
fn_def_coercion.rs Add some FnDef LUB coercion tests 2024-04-24 10:05:32 +00:00
fn_def_coercion.stderr Add some FnDef LUB coercion tests 2024-04-24 10:05:32 +00:00
fn_def_opaque_coercion.rs Register hidden types when equating function definitions in coercion 2024-04-24 10:05:33 +00: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 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
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 Show number in error message even for one error 2023-11-24 19:15:52 +01: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
implied-bounds-unnorm-associated-type-4.stderr Account for unops when suggesting cloning 2024-04-11 16:41:41 +00:00
implied-bounds-unnorm-associated-type-5.rs Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
implied-bounds-unnorm-associated-type-5.stderr Account for unops when suggesting cloning 2024-04-11 16:41:41 +00: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 Account for unops when suggesting cloning 2024-04-11 16:41:41 +00:00
issue-1451.rs Move some tests 2024-03-31 14:58:17 -03: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
issue-3044.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01: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 Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-39259.stderr Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-80179.rs
issue-80179.stderr
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
nested-function-names-issue-8587.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +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 Modify find_expr from Span to better account for closures 2024-04-24 22:21:13 +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