Hide negative coherence checks under negative_impls feature flag
This commit is contained in:
parent
9e264137e9
commit
9534186857
5 changed files with 37 additions and 4 deletions
|
@ -233,10 +233,11 @@ fn overlap_within_probe(
|
|||
.unwrap_or(false)
|
||||
} else {
|
||||
!selcx.predicate_may_hold_fatal(o)
|
||||
|| o.flip_polarity(tcx)
|
||||
.as_ref()
|
||||
.map(|o| selcx.infcx().predicate_must_hold_modulo_regions(o))
|
||||
.unwrap_or(false)
|
||||
|| tcx.features().negative_impls
|
||||
&& o.flip_polarity(tcx)
|
||||
.as_ref()
|
||||
.map(|o| selcx.infcx().predicate_must_hold_modulo_regions(o))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
});
|
||||
// FIXME: the call to `selcx.predicate_may_hold_fatal` above should be ported
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
use std::ops::DerefMut;
|
||||
|
||||
trait Foo {}
|
||||
impl<T: DerefMut> Foo for T {}
|
||||
impl<U> Foo for &U {}
|
||||
//~^ ERROR: conflicting implementations of trait `Foo` for type `&_` [E0119]
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,11 @@
|
|||
error[E0119]: conflicting implementations of trait `Foo` for type `&_`
|
||||
--> $DIR/coherence-overlap-negate-not-use-feature-gate.rs:5:1
|
||||
|
|
||||
LL | impl<T: DerefMut> Foo for T {}
|
||||
| --------------------------- first implementation here
|
||||
LL | impl<U> Foo for &U {}
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
|
@ -0,0 +1,11 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(negative_impls)]
|
||||
|
||||
use std::ops::DerefMut;
|
||||
|
||||
trait Foo {}
|
||||
impl<T: DerefMut> Foo for T {}
|
||||
impl<U> Foo for &U {}
|
||||
|
||||
fn main() {}
|
|
@ -3,6 +3,8 @@
|
|||
//
|
||||
// Check that if we promise to not impl what would overlap it doesn't actually overlap
|
||||
|
||||
#![feature(negative_impls)]
|
||||
|
||||
extern crate error_lib as lib;
|
||||
use lib::Error;
|
||||
|
||||
|
|
Loading…
Reference in a new issue