about summary refs log tree commit diff
path: root/src/rustllvm/ExecutionEngineWrapper.cpp
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2015-12-29 13:37:34 -0800
committerAaron Turon <aturon@mozilla.com>2016-03-14 15:04:37 -0700
commitb7e5112e88b8e73a5bff5a84f37f1d2a608e821c (patch)
treee53a74d0b0998fc2df36fbead6d2369cdb79842f /src/rustllvm/ExecutionEngineWrapper.cpp
parent5dedbdaea4254a78c58c322f636ecd9175cb53fa (diff)
downloadrust-b7e5112e88b8e73a5bff5a84f37f1d2a608e821c.tar.gz
rust-b7e5112e88b8e73a5bff5a84f37f1d2a608e821c.zip
Implement default associated type inheritance.
This commit leverages the specialization graph infrastructure to allow
specializing trait implementations to leave off associated types for
which their parents have provided defaults.

It also modifies the type projection code to avoid projecting associated
types unless either (1) all input types are fully known or (2) the
available associated type is "final", i.e. not marked `default`.
This restriction is required for soundness, due to examples like:

```rust
trait Foo {
    type Assoc;
}

impl<T> Foo for T {
    default type Assoc = ();
}

impl Foo for u8 {
    type Assoc = String;
}

fn generic<T>() -> <T as Foo>::Assoc {
    () //~ ERROR
}

fn main() {
    let s: String = generic::<u8>();
    println!("{}", s); // bad news
}
```
Diffstat (limited to 'src/rustllvm/ExecutionEngineWrapper.cpp')
0 files changed, 0 insertions, 0 deletions