diff options
| author | Michael Goulet <michael@errs.io> | 2023-07-19 17:28:40 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-10-23 23:35:27 +0000 |
| commit | 1d99ddbfe81b7d766c6e6f54dbc722c70d0b6be7 (patch) | |
| tree | 5346c52396599679574460794743bac7db1859ea | |
| parent | 8597bf1df72cd78135f2234285b0234d1ac1836e (diff) | |
| download | rust-1d99ddbfe81b7d766c6e6f54dbc722c70d0b6be7.tar.gz rust-1d99ddbfe81b7d766c6e6f54dbc722c70d0b6be7.zip | |
Consider regions
3 files changed, 44 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 0a476540d51..a4f600560ae 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -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; } diff --git a/tests/ui/coherence/negative-coherence-considering-regions.any_lt.stderr b/tests/ui/coherence/negative-coherence-considering-regions.any_lt.stderr new file mode 100644 index 00000000000..4cf50b4f208 --- /dev/null +++ b/tests/ui/coherence/negative-coherence-considering-regions.any_lt.stderr @@ -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`. diff --git a/tests/ui/coherence/negative-coherence-considering-regions.rs b/tests/ui/coherence/negative-coherence-considering-regions.rs new file mode 100644 index 00000000000..a43ad19eca7 --- /dev/null +++ b/tests/ui/coherence/negative-coherence-considering-regions.rs @@ -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() {} |
