From 81bb5a54c3090ff01af3f54f63e4818cb676e8e9 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sat, 2 Oct 2021 00:07:48 +0200 Subject: [PATCH 1/2] Revert "Auto merge of #86853 - usbalbin:const_try, r=oli-obk" This reverts commit c6007fdc7059c677a6c089e8d2915b264c0d1326, reversing changes made to 69c1c6a173dcae20c245348f6c7d19074b6109b7. --- library/core/src/convert/mod.rs | 8 +++----- library/core/src/lib.rs | 1 - library/core/src/option.rs | 6 ++---- library/core/src/result.rs | 8 ++------ library/core/tests/convert.rs | 16 ---------------- library/core/tests/lib.rs | 4 +--- src/test/ui/consts/try-operator.rs | 23 ----------------------- 7 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 library/core/tests/convert.rs delete mode 100644 src/test/ui/consts/try-operator.rs diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 72dbe845c97a9..1e512af48051e 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -532,10 +532,9 @@ where // From implies Into #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl const Into for T +impl Into for T where - U: ~const From, + U: From, { fn into(self) -> U { U::from(self) @@ -544,8 +543,7 @@ where // From (and thus Into) is reflexive #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl const From for T { +impl From for T { fn from(t: T) -> T { t } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 4408b5a3d2088..2230461b5f4b5 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -82,7 +82,6 @@ #![feature(const_float_bits_conv)] #![feature(const_float_classify)] #![feature(const_heap)] -#![feature(const_convert)] #![feature(const_inherent_unchecked_arith)] #![feature(const_int_unchecked_arith)] #![feature(const_intrinsic_copy)] diff --git a/library/core/src/option.rs b/library/core/src/option.rs index a162c0340fb24..94d892dd787a6 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2019,8 +2019,7 @@ impl> FromIterator> for Option { } #[unstable(feature = "try_trait_v2", issue = "84277")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl const ops::Try for Option { +impl ops::Try for Option { type Output = T; type Residual = Option; @@ -2039,8 +2038,7 @@ impl const ops::Try for Option { } #[unstable(feature = "try_trait_v2", issue = "84277")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl const ops::FromResidual for Option { +impl ops::FromResidual for Option { #[inline] fn from_residual(residual: Option) -> Self { match residual { diff --git a/library/core/src/result.rs b/library/core/src/result.rs index bd4e623732e2a..4a300f857e9ed 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1889,8 +1889,7 @@ impl> FromIterator> for Result { } #[unstable(feature = "try_trait_v2", issue = "84277")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl const ops::Try for Result { +impl ops::Try for Result { type Output = T; type Residual = Result; @@ -1909,10 +1908,7 @@ impl const ops::Try for Result { } #[unstable(feature = "try_trait_v2", issue = "84277")] -#[rustc_const_unstable(feature = "const_convert", issue = "88674")] -impl> const ops::FromResidual> - for Result -{ +impl> ops::FromResidual> for Result { #[inline] fn from_residual(residual: Result) -> Self { match residual { diff --git a/library/core/tests/convert.rs b/library/core/tests/convert.rs deleted file mode 100644 index f1048f4cf09cb..0000000000000 --- a/library/core/tests/convert.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[test] -fn convert() { - 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()); -} diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index f25106abc8821..cd3aed4cd28f8 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -9,13 +9,12 @@ #![feature(cfg_target_has_atomic)] #![feature(const_assume)] #![feature(const_cell_into_inner)] -#![feature(const_convert)] #![feature(const_maybe_uninit_assume_init)] -#![feature(const_num_from_num)] #![feature(const_ptr_read)] #![feature(const_ptr_write)] #![feature(const_ptr_offset)] #![feature(const_trait_impl)] +#![feature(const_num_from_num)] #![feature(core_intrinsics)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] @@ -84,7 +83,6 @@ mod char; mod clone; mod cmp; mod const_ptr; -mod convert; mod fmt; mod hash; mod intrinsics; diff --git a/src/test/ui/consts/try-operator.rs b/src/test/ui/consts/try-operator.rs deleted file mode 100644 index fe43b132cbd7f..0000000000000 --- a/src/test/ui/consts/try-operator.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass - -#![feature(try_trait_v2)] -#![feature(const_trait_impl)] -#![feature(const_try)] -#![feature(const_convert)] - -fn main() { - const fn result() -> Result { - Err(())?; - Ok(true) - } - - const FOO: Result = result(); - assert_eq!(Err(()), FOO); - - const fn option() -> Option<()> { - None?; - Some(()) - } - const BAR: Option<()> = option(); - assert_eq!(None, BAR); -} From 6a0c97aa5c31131a1d7c89b1a6d632c7a10744ab Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sat, 2 Oct 2021 01:12:15 +0200 Subject: [PATCH 2/2] Add regression test for #89432 Co-authored-by: Josh Stone --- src/test/ui/consts/not_const_clusure_in_const.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/test/ui/consts/not_const_clusure_in_const.rs diff --git a/src/test/ui/consts/not_const_clusure_in_const.rs b/src/test/ui/consts/not_const_clusure_in_const.rs new file mode 100644 index 0000000000000..fd2cfa442d3f6 --- /dev/null +++ b/src/test/ui/consts/not_const_clusure_in_const.rs @@ -0,0 +1,9 @@ +// run-pass + +const _FOO: fn() -> String = || "foo".into(); + +pub fn bar() -> fn() -> String { + || "bar".into() +} + +fn main(){}