rust/compiler
Dylan DPC cbe429c7a5
Rollup merge of #112076 - compiler-errors:bidirectional-alias-eq, r=lcnr
Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-relate goal

Sometimes we get into the case where the choice of normalizes-to branch in alias-relate are both valid, but we cannot make a choice of which one to take because they are different -- either returning equivalent but permuted region constraints, or equivalent opaque type definitions but differing modulo normalization.

In this case, we can make progress by considering a fourth candidate where we compute both normalizes-to branches together and canonicalize that as a response. This is essentially the AND intersection of both normalizes-to branches. In an ideal world, we'd be returning something more like the OR intersection of both branches, but we have no way of representing that either for regions (maybe eventually) or opaques (don't see that happening ever).

This is incomplete, so like the subst-relate fallback it's only considered outside of coherence. But it doesn't seem like a dramatic strengthening of inference or anything, and is useful for helping opaque type inference succeed when the hidden type is a projection.

## Example

Consider the goal - `AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter)`.

We have three ways of currently solving this goal:
1. SubstRelate - fails because we can't directly equate the substs of different alias kinds.
2. NormalizesToRhs - `Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter`
    * Ends up infering opaque definition - `Tait := <[i32; 32] as IntoIterator>::IntoIter`
3. NormalizesToLhs - `<[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait`
    * Find impl candidate, substitute the associated type - `std::array::IntoIter<i32, 32>`
    * Equate `std::array::IntoIter<i32, 32>` and `Tait`
        * Ends up infering opaque definition - `Tait := std::array::IntoIter<i32, 32>`

The problem here is that 2 and 3 are essentially both valid, since we have aliases that normalize on both sides, but due to lazy norm, they end up inferring different opaque type definitions that are only equal *after* normalizing them further.

---

r? `@lcnr`
2023-06-07 18:01:28 +05:30
..
rustc
rustc_abi Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_apfloat
rustc_arena
rustc_ast Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
rustc_ast_lowering Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_ast_passes cleanup 2023-06-03 09:44:30 +08:00
rustc_ast_pretty Migrate offset_of from a macro to builtin # syntax 2023-05-05 21:44:13 +02:00
rustc_attr Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgr 2023-06-06 21:28:34 +00:00
rustc_builtin_macros Auto merge of #111748 - nnethercote:Cow-DiagnosticMessage, r=WaffleLapkin 2023-05-29 07:10:44 +00:00
rustc_codegen_cranelift Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obk 2023-06-02 16:02:06 -07:00
rustc_codegen_gcc Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_codegen_llvm Use load-store instead of memcpy for short integer arrays 2023-06-04 00:51:49 -07:00
rustc_codegen_ssa Auto merge of #111999 - scottmcm:codegen-less-memcpy, r=compiler-errors 2023-06-06 01:50:28 +00:00
rustc_const_eval Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obk 2023-06-02 16:02:06 -07:00
rustc_data_structures Update dependencies with reported vulnerabilities 2023-06-02 12:34:01 -05:00
rustc_driver fix spelling error 2023-06-05 16:01:09 +02:00
rustc_driver_impl Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
rustc_error_codes Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
rustc_error_messages Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_errors Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errors 2023-06-02 07:57:21 +00:00
rustc_expand Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
rustc_feature cleanup 2023-06-03 09:44:30 +08:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
rustc_hir Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_hir_analysis Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorino 2023-06-07 09:03:33 +00:00
rustc_hir_pretty Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_hir_typeck Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorino 2023-06-07 09:03:33 +00:00
rustc_incremental Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_index Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearth 2023-05-25 00:33:43 +00:00
rustc_infer Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorino 2023-06-07 09:03:33 +00:00
rustc_interface Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_lexer Don't try to eat non-existent decimal digits. 2023-05-15 18:33:12 +10:00
rustc_lint Rollup merge of #112343 - GuillaumeGomez:extern-crate-missing-docs, r=notriddle 2023-06-06 22:00:20 +02:00
rustc_lint_defs Remove const eval limit and implement an exponential backoff lint instead 2023-05-31 10:24:17 +00:00
rustc_llvm Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
rustc_log
rustc_macros Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_metadata Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_middle Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorino 2023-06-07 09:03:33 +00:00
rustc_mir_build Show note for type ascription interpreted as a constant pattern, not a new variable 2023-06-04 20:49:30 +08:00
rustc_mir_dataflow unique borrows are mutating uses 2023-05-29 17:15:48 +02:00
rustc_mir_transform cleanup some skip_binder -> subst_identity 2023-06-05 18:40:36 -06:00
rustc_monomorphize Clarify follow_inlining. 2023-06-02 13:07:30 +10:00
rustc_parse Fix suggestion for matching struct with .. on both ends 2023-06-03 15:02:13 +08:00
rustc_parse_format
rustc_passes Rollup merge of #112081 - obeis:doc-test-literal, r=compiler-errors 2023-06-05 23:47:57 +02:00
rustc_plugin_impl
rustc_privacy Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
rustc_query_impl deps: bump crates 2023-05-26 13:03:47 +03:00
rustc_query_system Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_resolve Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
rustc_serialize Fix the FileEncoder buffer size. 2023-05-15 08:59:11 +10:00
rustc_session Auto merge of #103877 - oli-obk:const_eval_step_limit, r=fee1-dead 2023-06-01 05:32:00 +00:00
rustc_smir Rollup merge of #111250 - spastorino:smir-terminator-2, r=oli-obk 2023-06-06 22:00:18 +02:00
rustc_span Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber 2023-06-01 01:27:32 +00:00
rustc_symbol_mangling Rollup merge of #112182 - rcvalle:rust-cfi-fix-111185, r=compiler-errors 2023-06-02 18:12:45 +02:00
rustc_target Auto merge of #111819 - nikarh:vita-improved, r=Amanieu 2023-06-07 03:20:15 +00:00
rustc_trait_selection Rollup merge of #112076 - compiler-errors:bidirectional-alias-eq, r=lcnr 2023-06-07 18:01:28 +05:30
rustc_traits Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
rustc_transmute
rustc_ty_utils Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_type_ir better TyKind::Debug 2023-05-26 18:55:02 +01:00