about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-09-24 23:45:15 +0200
committerGitHub <noreply@github.com>2019-09-24 23:45:15 +0200
commit94628afbefe70c29b8f4080327145d98c17a7e2b (patch)
tree683ab61fb585ff8cd8dafa77ec9eb591bc74e9ce /src/rustllvm/RustWrapper.cpp
parentc623aa4a54c875287858d7f524a9e4483ca2de64 (diff)
parent61cfe92a992f8cd8b1af8e443c442be9559c3a19 (diff)
downloadrust-94628afbefe70c29b8f4080327145d98c17a7e2b.tar.gz
rust-94628afbefe70c29b8f4080327145d98c17a7e2b.zip
Rollup merge of #63934 - Aaron1011:fix/impl-trait-coherence, r=nikomatsakis
Fix coherence checking for impl trait in type aliases

**UPDATE**: This PR now treats all opaque types as remote. The original description appears below, but is no longer accurate.

Fixes #63677

[RFC 2071](https://github.com/rust-lang/rfcs/pull/2071) (impl-trait-existential-types) does not explicitly state how `type_alias_impl_trait` should interact with coherence. However, there's only one choice which makes sense - coherence should look at the underlying type (i.e. the *"defining"* type of the `impl Trait`) of the type alias, just like we do for non-`impl Trait` type aliases.

Specifically, `impl Trait` type aliases that resolve to a local type should be treated like a local type with respect to coherence (e.g. `impl Trait` type aliases which resolve to a foreign type should be treated as a foreign type, and those that resolve to a local type should be treated as a local type).

Since neither inherent impls nor direct trait impl (i.e. `impl MyType` or `impl MyTrait for MyType`) are allowed for type aliases, this usually does not come up. Before we ever attempt to do coherence checking, we will have errored out if an `impl Trait` type alias was used directly in an `impl` clause.

However, during trait selection, we sometimes need to prove bounds like `T: Sized` for some type `T`. If `T` is an impl trait type alias, this requires to know the coherence behavior for `impl Trait` type aliases when we perform coherence checking.

Note: Since determining the underlying type of an `impl Trait` type alias requires us to perform body type checking, this commit causes us to type check some bodies easier than we otherwise would have. However, since this is done through a query, this shouldn't cause any problems

For completeness, I've added an additional test of the coherence-related behavior of `impl Trait` type aliases.

cc https://github.com/rust-lang/rust/issues/63063
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions