Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-r...
source link: https://github.com/rust-lang/rust/pull/112076
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Conversation
Member
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:
- SubstRelate - fails because we can't directly equate the substs of different alias kinds.
- NormalizesToRhs -
Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter
- Ends up infering opaque definition -
Tait := <[i32; 32] as IntoIterator>::IntoIter
- Ends up infering opaque definition -
- 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>
andTait
- Ends up infering opaque definition -
Tait := std::array::IntoIter<i32, 32>
- Ends up infering opaque definition -
- Find impl candidate, substitute the associated type -
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
Recommend
-
27
README.md BlueChip BlueChip accepts payloads from GraphQL or JsonAPI servers, normalizes them into your store and provides an ORM like syntax for retrieving the data for use. Source
-
21
README.md normalizr
-
16
Have you ever needed to know if two intervals overlap? I wrote Rampart , a small Haskell library to help with that. The other day at work we were workin...
-
7
使用subst命令快速跳转到工作间 2017-10-02 • 使用subst命令快速跳转到工作间 程序员或多或少都会在命令行下面工作。我个人比较常使用命令行,特别是使用git做版本管理的时候。并且开发...
-
8
How they relate: ETH1x, ETH2 and Rollups
-
6
Conversation Contributor ...
-
6
重写Jekyll的Relate功能Jekyll 的 ‘Relate-相关文章’的功能,写的真的不好用。完全表达不了相关文章的含义。于是打算修一下 Relate 部分的功能。网上查了很久,很多人在抱怨,但没人把写好的 Relate 放到网上。唯一一个Jekyll 的...
-
7
Feature Flags (Toggles) in DevOps: How These Concepts Relate December 28, 2020 ...
-
0
Substack launches its Twitter-like Notes just days after Twitter throttled Substack links / Notes could prove to be a worthy Twitter alternative for some, especially for Substack writers who have already built audienc...
-
4
rails 7 Published on 17 May 2023
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK