mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
abcf400a28
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`* |
||
---|---|---|
.. | ||
bad-main.rs | ||
bad-main.stderr | ||
dyn-fn-alignment.rs | ||
expr-fn-panic.rs | ||
expr-fn.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-sign.fixed | ||
fn-recover-return-sign.rs | ||
fn-recover-return-sign.stderr | ||
fn-recover-return-sign2.rs | ||
fn-recover-return-sign2.stderr | ||
fn-trait-formatting.rs | ||
fn-trait-formatting.stderr | ||
fn_def_coercion.rs | ||
fn_def_coercion.stderr | ||
fn_def_opaque_coercion.rs | ||
fn_def_opaque_coercion_to_fn_ptr.rs | ||
fn_def_opaque_coercion_to_fn_ptr.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 | ||
nested-function-names-issue-8587.rs | ||
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 |