Revert "Auto merge of #89450 - usbalbin:const_try_revert, r=oli-obk"
This reverts commita8387aef8c
, reversing changes made to6e12110812
.
This commit is contained in:
parent
84b1d859c8
commit
e22fe4008c
8 changed files with 54 additions and 15 deletions
|
@ -534,9 +534,10 @@ where
|
|||
|
||||
// From implies Into
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T, U> Into<U> for T
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
|
||||
impl<T, U> const Into<U> for T
|
||||
where
|
||||
U: From<T>,
|
||||
U: ~const From<T>,
|
||||
{
|
||||
fn into(self) -> U {
|
||||
U::from(self)
|
||||
|
|
|
@ -112,6 +112,7 @@
|
|||
#![feature(const_float_classify)]
|
||||
#![feature(const_fmt_arguments_new)]
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_convert)]
|
||||
#![feature(const_inherent_unchecked_arith)]
|
||||
#![feature(const_int_unchecked_arith)]
|
||||
#![feature(const_intrinsic_copy)]
|
||||
|
|
|
@ -2077,7 +2077,8 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
|
|||
}
|
||||
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
impl<T> ops::Try for Option<T> {
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
|
||||
impl<T> const ops::Try for Option<T> {
|
||||
type Output = T;
|
||||
type Residual = Option<convert::Infallible>;
|
||||
|
||||
|
@ -2096,6 +2097,7 @@ impl<T> ops::Try for Option<T> {
|
|||
}
|
||||
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
|
||||
impl<T> const ops::FromResidual for Option<T> {
|
||||
#[inline]
|
||||
fn from_residual(residual: Option<convert::Infallible>) -> Self {
|
||||
|
|
|
@ -1945,7 +1945,8 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
|
|||
}
|
||||
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
impl<T, E> ops::Try for Result<T, E> {
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
|
||||
impl<T, E> const ops::Try for Result<T, E> {
|
||||
type Output = T;
|
||||
type Residual = Result<convert::Infallible, E>;
|
||||
|
||||
|
@ -1964,7 +1965,10 @@ impl<T, E> ops::Try for Result<T, E> {
|
|||
}
|
||||
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Result<T, F> {
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
|
||||
impl<T, E, F: ~const From<E>> const ops::FromResidual<Result<convert::Infallible, E>>
|
||||
for Result<T, F>
|
||||
{
|
||||
#[inline]
|
||||
fn from_residual(residual: Result<convert::Infallible, E>) -> Self {
|
||||
match residual {
|
||||
|
|
16
library/core/tests/convert.rs
Normal file
16
library/core/tests/convert.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
#[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<String>) -> Vec<String> {
|
||||
x.into()
|
||||
}
|
||||
|
||||
const BAR: Vec<String> = into(Vec::new());
|
||||
assert_eq!(BAR, Vec::<String>::new());
|
||||
}
|
|
@ -12,11 +12,11 @@
|
|||
#![feature(const_convert)]
|
||||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||||
#![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)]
|
||||
|
@ -96,6 +96,7 @@ mod char;
|
|||
mod clone;
|
||||
mod cmp;
|
||||
mod const_ptr;
|
||||
mod convert;
|
||||
mod fmt;
|
||||
mod future;
|
||||
mod hash;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
// run-pass
|
||||
|
||||
const _FOO: fn() -> String = || "foo".into();
|
||||
|
||||
pub fn bar() -> fn() -> String {
|
||||
|| "bar".into()
|
||||
}
|
||||
|
||||
fn main(){}
|
23
src/test/ui/consts/try-operator.rs
Normal file
23
src/test/ui/consts/try-operator.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(try_trait_v2)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_try)]
|
||||
#![feature(const_convert)]
|
||||
|
||||
fn main() {
|
||||
const fn result() -> Result<bool, ()> {
|
||||
Err(())?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
const FOO: Result<bool, ()> = result();
|
||||
assert_eq!(Err(()), FOO);
|
||||
|
||||
const fn option() -> Option<()> {
|
||||
None?;
|
||||
Some(())
|
||||
}
|
||||
const BAR: Option<()> = option();
|
||||
assert_eq!(None, BAR);
|
||||
}
|
Loading…
Add table
Reference in a new issue