mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-07 20:43:03 +00:00
Specialization already rejects defining opaque types
This commit is contained in:
parent
150448d2e0
commit
b8bd981545
31
tests/ui/specialization/min_specialization/impl-on-opaque.rs
Normal file
31
tests/ui/specialization/min_specialization/impl-on-opaque.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Test that specializing on opaque types is allowed
|
||||
|
||||
//@ check-pass
|
||||
|
||||
#![feature(min_specialization, type_alias_impl_trait)]
|
||||
|
||||
trait SpecTrait<U> {
|
||||
fn f();
|
||||
}
|
||||
|
||||
impl<U> SpecTrait<U> for () {
|
||||
default fn f() {}
|
||||
}
|
||||
|
||||
type Opaque = impl Tuple;
|
||||
|
||||
trait Tuple {}
|
||||
|
||||
impl Tuple for () {}
|
||||
|
||||
impl SpecTrait<Opaque> for () {
|
||||
fn f() {}
|
||||
}
|
||||
|
||||
impl SpecTrait<u32> for () {
|
||||
fn f() {}
|
||||
}
|
||||
|
||||
fn foo() -> Opaque {}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,28 @@
|
||||
// Test that specializing on opaque types is allowed
|
||||
|
||||
#![feature(min_specialization, type_alias_impl_trait)]
|
||||
|
||||
trait SpecTrait<U, V> {
|
||||
fn f();
|
||||
}
|
||||
|
||||
impl<U> SpecTrait<U, ()> for () {
|
||||
default fn f() {}
|
||||
}
|
||||
|
||||
type Opaque = impl Tuple;
|
||||
|
||||
trait Tuple {}
|
||||
|
||||
impl Tuple for () {}
|
||||
|
||||
// FIXME: this passes if we use `<(), ()>` here instead of `<(), Opaque>`,
|
||||
// even though there can't be more overlap from the opaque version
|
||||
impl SpecTrait<(), Opaque> for () {
|
||||
//~^ ERROR: conflicting implementations
|
||||
fn f() {}
|
||||
}
|
||||
|
||||
fn foo() -> Opaque {}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,12 @@
|
||||
error[E0119]: conflicting implementations of trait `SpecTrait<(), ()>` for type `()`
|
||||
--> $DIR/impl-on-opaque2.rs:21:1
|
||||
|
|
||||
LL | impl<U> SpecTrait<U, ()> for () {
|
||||
| ------------------------------- first implementation here
|
||||
...
|
||||
LL | impl SpecTrait<(), Opaque> for () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
Loading…
Reference in New Issue
Block a user