Elaborate predicates in min_specialization checks
Supertraits of specialization markers could circumvent checks for min_specialization. Elaborating predicates prevents this.
This commit is contained in:
parent
6dc08b909b
commit
c8f86cad2d
4 changed files with 76 additions and 18 deletions
|
|
@ -0,0 +1,29 @@
|
|||
// Check that supertraits cannot be used to work around min_specialization
|
||||
// limitations.
|
||||
|
||||
#![feature(min_specialization)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
trait HasMethod {
|
||||
fn method(&self);
|
||||
}
|
||||
|
||||
#[rustc_unsafe_specialization_marker]
|
||||
trait Marker: HasMethod {}
|
||||
|
||||
trait Spec {
|
||||
fn spec_me(&self);
|
||||
}
|
||||
|
||||
impl<T> Spec for T {
|
||||
default fn spec_me(&self) {}
|
||||
}
|
||||
|
||||
impl<T: Marker> Spec for T {
|
||||
//~^ ERROR cannot specialize on trait `HasMethod`
|
||||
fn spec_me(&self) {
|
||||
self.method();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
error: cannot specialize on trait `HasMethod`
|
||||
--> $DIR/spec-marker-supertraits.rs:22:1
|
||||
|
|
||||
LL | / impl<T: Marker> Spec for T {
|
||||
LL | |
|
||||
LL | | fn spec_me(&self) {
|
||||
LL | | self.method();
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue