Consider regions
This commit is contained in:
parent
8597bf1df7
commit
1d99ddbfe8
3 changed files with 44 additions and 2 deletions
|
@ -434,12 +434,19 @@ fn impl_intersection_has_negative_obligation(
|
|||
param_env,
|
||||
negative_predicate,
|
||||
));
|
||||
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// FIXME: regions here too...
|
||||
// FIXME: We could use the assumed_wf_types from both impls, I think,
|
||||
// if that wasn't implemented just for LocalDefId, and we'd need to do
|
||||
//the normalization ourselves since this is totally fallible...
|
||||
let outlives_env = OutlivesEnvironment::new(param_env);
|
||||
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
error[E0119]: conflicting implementations of trait `Bar` for type `&_`
|
||||
--> $DIR/negative-coherence-considering-regions.rs:22:1
|
||||
|
|
||||
LL | impl<T> Bar for T where T: Foo {}
|
||||
| ------------------------------ first implementation here
|
||||
...
|
||||
LL | impl<T> Bar for &T {}
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
23
tests/ui/coherence/negative-coherence-considering-regions.rs
Normal file
23
tests/ui/coherence/negative-coherence-considering-regions.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// revisions: any_lt static_lt
|
||||
//[static_lt] check-pass
|
||||
|
||||
#![feature(negative_impls)]
|
||||
#![feature(with_negative_coherence)]
|
||||
|
||||
trait Foo {}
|
||||
|
||||
impl<T> !Foo for &'static T {}
|
||||
|
||||
trait Bar {}
|
||||
|
||||
impl<T> Bar for T where T: Foo {}
|
||||
|
||||
#[cfg(any_lt)]
|
||||
impl<T> Bar for &T {}
|
||||
//[any_lt]~^ ERROR conflicting implementations of trait `Bar` for type `&_`
|
||||
|
||||
#[cfg(static_lt)]
|
||||
impl<T> Bar for &'static T {}
|
||||
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Reference in a new issue