diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-19 09:03:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-19 09:03:26 +0100 |
| commit | b941f290ac40c32aa7096dff8a2588b818cc79cb (patch) | |
| tree | c947e7dcff5b987bbb0a07968d48c8657c31a7c2 /src/test/ui/thinlto | |
| parent | c0ad9429ab8b64808672695397adf9bf7547e4b6 (diff) | |
| parent | 01d0ae96188b99c367178a38906b7269e1ada244 (diff) | |
| download | rust-b941f290ac40c32aa7096dff8a2588b818cc79cb.tar.gz rust-b941f290ac40c32aa7096dff8a2588b818cc79cb.zip | |
Rollup merge of #57501 - petrochenkov:highvar, r=alexreg
High priority resolutions for associated variants
In https://github.com/rust-lang/rust/pull/56225 variants were assigned lowest priority during name resolution to avoid crater run and potential breakage.
This PR changes the rules to give variants highest priority instead.
Some motivation:
- If variants (and their constructors) are treated as associated items, then they are obviously *inherent* associated items since they don't come from traits.
- Inherent associated items have higher priority during resolution than associated items from traits.
- The reason is that there is a way to disambiguate in favor of trait items (`<Type as Trait>::Ambiguous`), but there's no way to disambiguate in favor of inherent items, so they became unusable in case of ambiguities if they have low priority.
- It's technically problematic to fallback from associated types to anything until lazy normalization (?) is implemented.
Crater found some regressions from this change, but they are all in type positions, e.g.
```rust
fn f() -> Self::Ambiguos { ... } // Variant `Ambiguous` or associated type `Ambiguous`?
```
, so variants are not usable there right now, but they may become usable in the future if https://github.com/rust-lang/rfcs/pull/2593 is accepted.
This PR keeps code like this successfully resolving, but introduces a future-compatibility lint `ambiguous_associated_items` that recommends rewriting it as `<Self as Trait>::Ambiguous`.
Diffstat (limited to 'src/test/ui/thinlto')
0 files changed, 0 insertions, 0 deletions
