diff options
| author | bors <bors@rust-lang.org> | 2018-02-16 00:03:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-02-16 00:03:10 +0000 |
| commit | efda9bae8788fdc68ea1d05be3c5b66d3e291961 (patch) | |
| tree | 424f318bc35d961925a61831e2a30eba54fc2163 /src/libsyntax/parse | |
| parent | 1670a532dd769763f1d6ad9e5d624ec31361a098 (diff) | |
| parent | 220bb22e1b621ad5a10a44080e3e1872d99f3e9f (diff) | |
| download | rust-efda9bae8788fdc68ea1d05be3c5b66d3e291961.tar.gz rust-efda9bae8788fdc68ea1d05be3c5b66d3e291961.zip | |
Auto merge of #45404 - giannicic:defaultimpl2, r=nikomatsakis
#37653 support `default impl` for specialization
this commit implements the second part of the `default impl` feature:
> - a `default impl` need not include all items from the trait
> - a `default impl` alone does not mean that a type implements the trait
The first point allows rustc to compile and run something like this:
```
trait Foo {
fn foo_one(&self) -> &'static str;
fn foo_two(&self) -> &'static str;
}
default impl<T> Foo for T {
fn foo_one(&self) -> &'static str {
"generic"
}
}
struct MyStruct;
fn main() {
assert!(MyStruct.foo_one() == "generic");
}
```
but it shows a proper error if trying to call `MyStruct.foo_two()`
The second point allows a `default impl` to be considered as not implementing the `Trait` if it doesn't implement all the trait items.
The tests provided (in the compile-fail section) should cover all the possible trait resolutions.
Let me know if some tests is missed.
See [referenced ](https://github.com/rust-lang/rust/issues/37653) issue for further info
r? @nikomatsakis
Diffstat (limited to 'src/libsyntax/parse')
0 files changed, 0 insertions, 0 deletions
