diff options
| author | bors <bors@rust-lang.org> | 2021-10-14 10:06:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-14 10:06:30 +0000 |
| commit | c34ac8747ca96d09cb08b8f5adddead826e77c06 (patch) | |
| tree | 23a25e70efd4d935b3aea4b3082baed6add97917 /src/test/codegen | |
| parent | 7807a694c2f079fd3f395821bcc357eee8650071 (diff) | |
| parent | 11fac09eadc3a60982e46e2fed177d6b0a686041 (diff) | |
| download | rust-c34ac8747ca96d09cb08b8f5adddead826e77c06.tar.gz rust-c34ac8747ca96d09cb08b8f5adddead826e77c06.zip | |
Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
Add `const_eval_select` intrinsic Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime. See https://github.com/rust-lang/const-eval/issues/7 for previous discussion. r? `@oli-obk.`
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/intrinsics/const_eval_select.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/codegen/intrinsics/const_eval_select.rs b/src/test/codegen/intrinsics/const_eval_select.rs new file mode 100644 index 00000000000..34e653b4b9d --- /dev/null +++ b/src/test/codegen/intrinsics/const_eval_select.rs @@ -0,0 +1,17 @@ +// compile-flags: -C no-prepopulate-passes + +#![crate_type = "lib"] +#![feature(const_eval_select)] + +use std::intrinsics::const_eval_select; + +const fn foo(_: i32) -> i32 { 1 } + +#[no_mangle] +pub fn hi(n: i32) -> i32 { n } + +#[no_mangle] +pub unsafe fn hey() { + // CHECK: call i32 @hi(i32 + const_eval_select((42,), foo, hi); +} |
