-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #105339 - BoxyUwU:wf_ct_kind_expr, r=TaKO8Ki
support `ConstKind::Expr` in `is_const_evaluatable` and `WfPredicates::compute` Fixes #105205 Currently we haven't implemented a way to evaluate `ConstKind::Expr(Expr::Binop(Add, 1, 2))` so I just left that with a `FIXME` and a `delay_span_bug` since I have no idea how to do that and it would make this a much larger (and more complicated) PR :P
- Loading branch information
Showing
4 changed files
with
99 additions
and
20 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
22 changes: 22 additions & 0 deletions
22
src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.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,22 @@ | ||
#![feature(generic_const_exprs, generic_arg_infer)] | ||
#![allow(incomplete_features)] | ||
|
||
// minimized repro for #105205 | ||
// | ||
// the `foo::<_, L>` call results in a `WellFormed(_)` obligation and a | ||
// `ConstEvaluatable(Unevaluated(_ + 1 + L))` obligation. Attempting to fulfill the latter | ||
// unifies the `_` with `Expr(L - 1)` from the paramenv which turns the `WellFormed` | ||
// obligation into `WellFormed(Expr(L - 1))` | ||
|
||
fn foo<const N: usize, const M: usize>(_: [(); N + 1 + M]) {} | ||
|
||
fn ice<const L: usize>() | ||
where | ||
[(); (L - 1) + 1 + L]:, | ||
{ | ||
foo::<_, L>([(); L + 1 + L]); | ||
//~^ ERROR: mismatched types | ||
//~^^ ERROR: unconstrained generic constant | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.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,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/wf_obligation.rs:17:17 | ||
| | ||
LL | foo::<_, L>([(); L + 1 + L]); | ||
| ^^^^^^^^^^^^^^^ expected `N + 1 + M`, found `L + 1 + L` | ||
| | ||
= note: expected constant `N + 1 + M` | ||
found constant `L + 1 + L` | ||
|
||
error: unconstrained generic constant | ||
--> $DIR/wf_obligation.rs:17:22 | ||
| | ||
LL | foo::<_, L>([(); L + 1 + L]); | ||
| ^^^^^^^^^ | ||
| | ||
= help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |