diff options
Diffstat (limited to 'src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs')
-rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs new file mode 100644 index 000000000..99eacaa83 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs @@ -0,0 +1,30 @@ +#![feature(const_trait_impl)] + +struct NonConstAdd(i32); + +impl std::ops::Add for NonConstAdd { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + NonConstAdd(self.0 + rhs.0) + } +} + +trait Foo { + type Bar: ~const std::ops::Add; +} + +impl const Foo for NonConstAdd { + type Bar = NonConstAdd; + //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts +} + +trait Baz { + type Qux: std::ops::Add; +} + +impl const Baz for NonConstAdd { + type Qux = NonConstAdd; // OK +} + +fn main() {} |