If inherent associated type selection fails, we should still consider trait associated type candidates as a fallback #142006
Labels
C-bug
Category: This is a bug.
F-inherent_associated_types
`#![feature(inherent_associated_types)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
For context, applicable inherent associated item candidates shadow trait associated item ones (where applicable means the self type of the candidate impl unifies and its predicates hold). IAT selection does respect that which is good as it follows the behavior of associated functions and constants (in bodies).
However, contrary to inherent associated functions and constants (in bodies), we currently bail out early with a hard error if we fail to select an applicable IAT! Moreover assuming PR #140247 gets merged in its current form, this will extend to candidates in general. Meaning, we'll error early if there are no candidates whatsoever! (See my separate comment for an example).
Ideally, we'd only fail overall if we also failed to find a suitable trait associated type candidate (by means of
resolve_type_relative_path
). Rephrased, inapplicable IAT candidates should not shadow trait assoc ty candidates.Examples
Inherent Associated Types
These should compile but currently don't for the reason mentioned above.
Inherent Associated Functions & Constants
When resolving associated functions and constants (in bodies), inapplicable inherent candidates do not shadow trait candidates, so the following cases pass compilation as expected and exit with 0 when executed.
Example | IAC&IAF inapplicable (unsatisfied predicate)
Example | IAC&IAF inapplicable (ununifiable self ty)
The text was updated successfully, but these errors were encountered: