When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.
15 lines
247 B
Rust
15 lines
247 B
Rust
// build-pass
|
|
|
|
// Check that the evaluation of const-functions with
|
|
// zero-sized types as arguments compiles successfully
|
|
|
|
struct Zst {}
|
|
|
|
const fn foo(val: Zst) -> Zst { val }
|
|
|
|
const FOO: Zst = foo(Zst {});
|
|
|
|
fn main() {
|
|
const _: Zst = FOO;
|
|
}
|