Set !const_evaluatable if ambig. and not inferred
This prevents an ICE due to a value not actually being evaluatable later.
This commit is contained in:
parent
77b61379b6
commit
b79a9a0900
3 changed files with 48 additions and 12 deletions
|
@ -215,8 +215,7 @@ fn satisfied_from_param_env<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(c) = single_match {
|
if let Some(Ok(c)) = single_match {
|
||||||
if let Ok(c) = c {
|
|
||||||
let is_ok = infcx
|
let is_ok = infcx
|
||||||
.commit_if_ok(|_| {
|
.commit_if_ok(|_| {
|
||||||
let ocx = ObligationCtxt::new_in_snapshot(infcx);
|
let ocx = ObligationCtxt::new_in_snapshot(infcx);
|
||||||
|
@ -226,7 +225,6 @@ fn satisfied_from_param_env<'tcx>(
|
||||||
})
|
})
|
||||||
.is_ok();
|
.is_ok();
|
||||||
assert!(is_ok);
|
assert!(is_ok);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
src/test/ui/const-generics/ensure_is_evaluatable.rs
Normal file
20
src/test/ui/const-generics/ensure_is_evaluatable.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#![feature(generic_const_exprs)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
fn foo<const N: usize, const M: usize>() -> [(); N+2]
|
||||||
|
where
|
||||||
|
[(); N + 1]:,
|
||||||
|
[(); M + 1]:,
|
||||||
|
{
|
||||||
|
bar()
|
||||||
|
//~^ ERROR: unconstrained
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar<const N: usize>() -> [(); N]
|
||||||
|
where
|
||||||
|
[(); N + 1]:,
|
||||||
|
{
|
||||||
|
[(); N]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
18
src/test/ui/const-generics/ensure_is_evaluatable.stderr
Normal file
18
src/test/ui/const-generics/ensure_is_evaluatable.stderr
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
error: unconstrained generic constant
|
||||||
|
--> $DIR/ensure_is_evaluatable.rs:9:5
|
||||||
|
|
|
||||||
|
LL | bar()
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
= help: try adding a `where` bound using this expression: `where [(); N + 1]:`
|
||||||
|
note: required by a bound in `bar`
|
||||||
|
--> $DIR/ensure_is_evaluatable.rs:15:10
|
||||||
|
|
|
||||||
|
LL | fn bar<const N: usize>() -> [(); N]
|
||||||
|
| --- required by a bound in this
|
||||||
|
LL | where
|
||||||
|
LL | [(); N + 1]:,
|
||||||
|
| ^^^^^ required by this bound in `bar`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue