From b85107ec711aa4e7de8ffe3deab6f88800e2a680 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Mon, 2 Aug 2021 14:42:29 +0200 Subject: [PATCH] Add tests for feature(const_identity_convert) --- src/test/ui/consts/convert.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/ui/consts/convert.rs diff --git a/src/test/ui/consts/convert.rs b/src/test/ui/consts/convert.rs new file mode 100644 index 000000000000..e10374070acf --- /dev/null +++ b/src/test/ui/consts/convert.rs @@ -0,0 +1,20 @@ +// run-pass + +#![feature(const_trait_impl)] +#![feature(const_identity_convert)] + +fn main() { + const fn from(x: i32) -> i32 { + i32::from(x) + } + + const FOO: i32 = from(42); + assert_eq!(FOO, 42); + + const fn into(x: Vec) -> Vec { + x.into() + } + + const BAR: Vec = into(Vec::new()); + assert_eq!(BAR, Vec::::new()); +}