-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #123170 - compiler-errors:const-statics, r=lcnr
Replace regions in const canonical vars' types with `'static` in next-solver canonicalizer We shouldn't ever have non-static regions in consts on stable (or really any regions at all, lol). The test I committed is less minimal than, e.g., #123155 -- however, I believe that it actually portrays the underlying issue here a bit better than that one. In the linked issue, we end up emitting a normalizes-to predicate for a const placeholder because we don't actually unify `false` and `""`. In the test I committed, we emit a normalizes-to predicate as a part of actually solving a negative coherence goal. Fixes #123155 Fixes #118783 r? lcnr
- Loading branch information
Showing
7 changed files
with
120 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/ui/coherence/negative-coherence/regions-in-canonical.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/coherence/negative-coherence/regions-in-canonical.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|