const_evaluatable_checked: collect predicates from fn_sig
This commit is contained in:
parent
78a089487b
commit
e1f408e6c8
6 changed files with 72 additions and 6 deletions
|
|
@ -8,6 +8,7 @@ fn user<T>() {
|
|||
//~^ ERROR constant expression depends
|
||||
//~| ERROR constant expression depends
|
||||
//~| ERROR constant expression depends
|
||||
//~| ERROR constant expression depends
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,19 @@ LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
|
|||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/cross_crate_predicate.rs:7:13
|
||||
|
|
||||
LL | let _ = const_evaluatable_lib::test1::<T>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
::: $DIR/auxiliary/const_evaluatable_lib.rs:6:41
|
||||
|
|
||||
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
|
||||
| ----- required by this bound in `test1`
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/cross_crate_predicate.rs:7:13
|
||||
|
|
||||
|
|
@ -29,8 +42,13 @@ error: constant expression depends on a generic parameter
|
|||
|
|
||||
LL | let _ = const_evaluatable_lib::test1::<T>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
::: $DIR/auxiliary/const_evaluatable_lib.rs:6:41
|
||||
|
|
||||
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
|
||||
| ----- required by this bound in `test1::{{constant}}#1`
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
#![feature(const_generics, const_evaluatable_checked)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
fn test<const N: usize>() -> [u8; N - 1] {
|
||||
//~^ ERROR evaluation of constant
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test::<0>();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/from-sig-fail.rs:4:35
|
||||
|
|
||||
LL | fn test<const N: usize>() -> [u8; N - 1] {
|
||||
| ^^^^^ attempt to compute `0_usize - 1_usize` which would overflow
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// run-pass
|
||||
#![feature(const_generics, const_evaluatable_checked)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const B: bool>;
|
||||
|
||||
fn test<const N: usize>() -> Foo<{ N > 10 }> {
|
||||
Foo
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _: Foo<true> = test::<12>();
|
||||
let _: Foo<false> = test::<9>();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue