diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-28 12:10:44 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-28 12:30:52 -0400 |
| commit | 08c7ff22645cbb661edd67a8a30cf3dd67a07c23 (patch) | |
| tree | 40f7ac041b539c28769a654a1fed15b9bd166b9c /tests | |
| parent | 4ea92e3c7a07eac39c213520730f8221ce6f70b7 (diff) | |
| download | rust-08c7ff22645cbb661edd67a8a30cf3dd67a07c23.tar.gz rust-08c7ff22645cbb661edd67a8a30cf3dd67a07c23.zip | |
Restrict const ty's regions to static when putting them in canonical var list
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/coherence/negative-coherence/regions-in-canonical.rs | 23 | ||||
| -rw-r--r-- | tests/ui/coherence/negative-coherence/regions-in-canonical.stderr | 11 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/coherence/negative-coherence/regions-in-canonical.rs b/tests/ui/coherence/negative-coherence/regions-in-canonical.rs new file mode 100644 index 00000000000..6c2a11e0135 --- /dev/null +++ b/tests/ui/coherence/negative-coherence/regions-in-canonical.rs @@ -0,0 +1,23 @@ +//@ check-pass + +#![feature(adt_const_params)] +//~^ WARN the feature `adt_const_params` is incomplete +#![feature(with_negative_coherence, negative_impls)] + +pub trait A<const K: &'static str> {} +pub trait C {} + + +struct W<T>(T); + +// Negative coherence: +// Proving `W<!T>: !A<"">` requires proving `CONST alias-eq ""`, which requires proving +// `CONST normalizes-to (?1c: &str)`. The type's region is uniquified, so it ends up being +// put in to the canonical vars list with an infer region => ICE. +impl<T> C for T where T: A<""> {} +impl<T> C for W<T> {} + +impl<T> !A<CONST> for W<T> {} +const CONST: &str = ""; + +fn main() {} diff --git a/tests/ui/coherence/negative-coherence/regions-in-canonical.stderr b/tests/ui/coherence/negative-coherence/regions-in-canonical.stderr new file mode 100644 index 00000000000..dc8c926f182 --- /dev/null +++ b/tests/ui/coherence/negative-coherence/regions-in-canonical.stderr @@ -0,0 +1,11 @@ +warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/regions-in-canonical.rs:3:12 + | +LL | #![feature(adt_const_params)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + |
