Skip to content

Commit c80a8f5

Browse files
committed
Stabilize TryFrom and TryInto
1 parent 2f71203 commit c80a8f5

File tree

14 files changed

+30
-38
lines changed

14 files changed

+30
-38
lines changed

src/libcore/array.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
4949
}
5050

5151
/// The error type returned when a conversion from a slice to an array fails.
52-
#[unstable(feature = "try_from", issue = "33417")]
52+
#[stable(feature = "try_from", since = "1.34.0")]
5353
#[derive(Debug, Copy, Clone)]
5454
pub struct TryFromSliceError(());
5555

@@ -138,7 +138,7 @@ macro_rules! array_impls {
138138
}
139139
}
140140

141-
#[unstable(feature = "try_from", issue = "33417")]
141+
#[stable(feature = "try_from", since = "1.34.0")]
142142
impl<'a, T> TryFrom<&'a [T]> for [T; $N] where T: Copy {
143143
type Error = TryFromSliceError;
144144

@@ -147,7 +147,7 @@ macro_rules! array_impls {
147147
}
148148
}
149149

150-
#[unstable(feature = "try_from", issue = "33417")]
150+
#[stable(feature = "try_from", since = "1.34.0")]
151151
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
152152
type Error = TryFromSliceError;
153153

@@ -161,7 +161,7 @@ macro_rules! array_impls {
161161
}
162162
}
163163

164-
#[unstable(feature = "try_from", issue = "33417")]
164+
#[stable(feature = "try_from", since = "1.34.0")]
165165
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
166166
type Error = TryFromSliceError;
167167

src/libcore/char/convert.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl FromStr for char {
218218
}
219219

220220

221-
#[unstable(feature = "try_from", issue = "33417")]
221+
#[stable(feature = "try_from", since = "1.34.0")]
222222
impl TryFrom<u32> for char {
223223
type Error = CharTryFromError;
224224

@@ -233,11 +233,11 @@ impl TryFrom<u32> for char {
233233
}
234234

235235
/// The error type returned when a conversion from u32 to char fails.
236-
#[unstable(feature = "try_from", issue = "33417")]
236+
#[stable(feature = "try_from", since = "1.34.0")]
237237
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
238238
pub struct CharTryFromError(());
239239

240-
#[unstable(feature = "try_from", issue = "33417")]
240+
#[stable(feature = "try_from", since = "1.34.0")]
241241
impl fmt::Display for CharTryFromError {
242242
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
243243
"converted integer out of range for `char`".fmt(f)

src/libcore/char/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use self::convert::{from_u32, from_digit};
3030
pub use self::convert::from_u32_unchecked;
3131
#[stable(feature = "char_from_str", since = "1.20.0")]
3232
pub use self::convert::ParseCharError;
33-
#[unstable(feature = "try_from", issue = "33417")]
33+
#[stable(feature = "try_from", since = "1.34.0")]
3434
pub use self::convert::CharTryFromError;
3535
#[stable(feature = "decode_utf16", since = "1.9.0")]
3636
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};

src/libcore/convert.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,26 @@ pub trait From<T>: Sized {
370370
///
371371
/// [`TryFrom`]: trait.TryFrom.html
372372
/// [`Into`]: trait.Into.html
373-
#[unstable(feature = "try_from", issue = "33417")]
373+
#[stable(feature = "try_from", since = "1.34.0")]
374374
pub trait TryInto<T>: Sized {
375375
/// The type returned in the event of a conversion error.
376+
#[stable(feature = "try_from", since = "1.34.0")]
376377
type Error;
377378

378379
/// Performs the conversion.
380+
#[stable(feature = "try_from", since = "1.34.0")]
379381
fn try_into(self) -> Result<T, Self::Error>;
380382
}
381383

382384
/// Attempt to construct `Self` via a conversion.
383-
#[unstable(feature = "try_from", issue = "33417")]
385+
#[stable(feature = "try_from", since = "1.34.0")]
384386
pub trait TryFrom<T>: Sized {
385387
/// The type returned in the event of a conversion error.
388+
#[stable(feature = "try_from", since = "1.34.0")]
386389
type Error;
387390

388391
/// Performs the conversion.
392+
#[stable(feature = "try_from", since = "1.34.0")]
389393
fn try_from(value: T) -> Result<Self, Self::Error>;
390394
}
391395

@@ -453,7 +457,7 @@ impl<T> From<T> for T {
453457

454458

455459
// TryFrom implies TryInto
456-
#[unstable(feature = "try_from", issue = "33417")]
460+
#[stable(feature = "try_from", since = "1.34.0")]
457461
impl<T, U> TryInto<U> for T where U: TryFrom<T>
458462
{
459463
type Error = U::Error;
@@ -465,7 +469,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
465469

466470
// Infallible conversions are semantically equivalent to fallible conversions
467471
// with an uninhabited error type.
468-
#[unstable(feature = "try_from", issue = "33417")]
472+
#[stable(feature = "try_from", since = "1.34.0")]
469473
impl<T, U> TryFrom<U> for T where U: Into<T> {
470474
type Error = Infallible;
471475

src/libcore/num/mod.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,6 @@ assert_eq!(value, ", $swap_op, ");
20042004
When starting from a slice rather than an array, fallible conversion APIs can be used:
20052005
20062006
```
2007-
#![feature(try_from)]
20082007
use std::convert::TryInto;
20092008
20102009
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -2036,7 +2035,6 @@ assert_eq!(value, ", $swap_op, ");
20362035
When starting from a slice rather than an array, fallible conversion APIs can be used:
20372036
20382037
```
2039-
#![feature(try_from)]
20402038
use std::convert::TryInto;
20412039
20422040
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -2078,7 +2076,6 @@ assert_eq!(value, ", $swap_op, ");
20782076
When starting from a slice rather than an array, fallible conversion APIs can be used:
20792077
20802078
```
2081-
#![feature(try_from)]
20822079
use std::convert::TryInto;
20832080
20842081
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -3771,7 +3768,6 @@ assert_eq!(value, ", $swap_op, ");
37713768
When starting from a slice rather than an array, fallible conversion APIs can be used:
37723769
37733770
```
3774-
#![feature(try_from)]
37753771
use std::convert::TryInto;
37763772
37773773
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -3803,7 +3799,6 @@ assert_eq!(value, ", $swap_op, ");
38033799
When starting from a slice rather than an array, fallible conversion APIs can be used:
38043800
38053801
```
3806-
#![feature(try_from)]
38073802
use std::convert::TryInto;
38083803
38093804
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -3845,7 +3840,6 @@ assert_eq!(value, ", $swap_op, ");
38453840
When starting from a slice rather than an array, fallible conversion APIs can be used:
38463841
38473842
```
3848-
#![feature(try_from)]
38493843
use std::convert::TryInto;
38503844
38513845
fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {
@@ -4508,7 +4502,7 @@ macro_rules! from_str_radix_int_impl {
45084502
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
45094503

45104504
/// The error type returned when a checked integral type conversion fails.
4511-
#[unstable(feature = "try_from", issue = "33417")]
4505+
#[stable(feature = "try_from", since = "1.34.0")]
45124506
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
45134507
pub struct TryFromIntError(());
45144508

@@ -4523,14 +4517,14 @@ impl TryFromIntError {
45234517
}
45244518
}
45254519

4526-
#[unstable(feature = "try_from", issue = "33417")]
4520+
#[stable(feature = "try_from", since = "1.34.0")]
45274521
impl fmt::Display for TryFromIntError {
45284522
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
45294523
self.__description().fmt(fmt)
45304524
}
45314525
}
45324526

4533-
#[unstable(feature = "try_from", issue = "33417")]
4527+
#[stable(feature = "try_from", since = "1.34.0")]
45344528
impl From<Infallible> for TryFromIntError {
45354529
fn from(x: Infallible) -> TryFromIntError {
45364530
match x {}
@@ -4550,7 +4544,7 @@ impl From<!> for TryFromIntError {
45504544
// no possible bounds violation
45514545
macro_rules! try_from_unbounded {
45524546
($source:ty, $($target:ty),*) => {$(
4553-
#[unstable(feature = "try_from", issue = "33417")]
4547+
#[stable(feature = "try_from", since = "1.34.0")]
45544548
impl TryFrom<$source> for $target {
45554549
type Error = TryFromIntError;
45564550

@@ -4565,7 +4559,7 @@ macro_rules! try_from_unbounded {
45654559
// only negative bounds
45664560
macro_rules! try_from_lower_bounded {
45674561
($source:ty, $($target:ty),*) => {$(
4568-
#[unstable(feature = "try_from", issue = "33417")]
4562+
#[stable(feature = "try_from", since = "1.34.0")]
45694563
impl TryFrom<$source> for $target {
45704564
type Error = TryFromIntError;
45714565

@@ -4584,7 +4578,7 @@ macro_rules! try_from_lower_bounded {
45844578
// unsigned to signed (only positive bound)
45854579
macro_rules! try_from_upper_bounded {
45864580
($source:ty, $($target:ty),*) => {$(
4587-
#[unstable(feature = "try_from", issue = "33417")]
4581+
#[stable(feature = "try_from", since = "1.34.0")]
45884582
impl TryFrom<$source> for $target {
45894583
type Error = TryFromIntError;
45904584

@@ -4603,7 +4597,7 @@ macro_rules! try_from_upper_bounded {
46034597
// all other cases
46044598
macro_rules! try_from_both_bounded {
46054599
($source:ty, $($target:ty),*) => {$(
4606-
#[unstable(feature = "try_from", issue = "33417")]
4600+
#[stable(feature = "try_from", since = "1.34.0")]
46074601
impl TryFrom<$source> for $target {
46084602
type Error = TryFromIntError;
46094603

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![feature(str_internals)]
2828
#![feature(test)]
2929
#![feature(trusted_len)]
30-
#![feature(try_from)]
3130
#![feature(try_trait)]
3231
#![feature(align_offset)]
3332
#![feature(reverse_bits)]

src/librustc_apfloat/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![deny(rust_2018_idioms)]
3636

3737
#![feature(nll)]
38-
#![feature(try_from)]
3938
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
4039
#[allow(unused_extern_crates)]
4140
extern crate rustc_cratesio_shim;

src/librustc_mir/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2424
#![feature(unicode_internals)]
2525
#![feature(step_trait)]
2626
#![feature(slice_concat_ext)]
27-
#![feature(try_from)]
2827
#![feature(reverse_bits)]
2928
#![feature(try_blocks)]
3029

src/libstd/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,14 @@ impl Error for num::ParseIntError {
466466
}
467467
}
468468

469-
#[unstable(feature = "try_from", issue = "33417")]
469+
#[stable(feature = "try_from", since = "1.34.0")]
470470
impl Error for num::TryFromIntError {
471471
fn description(&self) -> &str {
472472
self.__description()
473473
}
474474
}
475475

476-
#[unstable(feature = "try_from", issue = "33417")]
476+
#[stable(feature = "try_from", since = "1.34.0")]
477477
impl Error for array::TryFromSliceError {
478478
fn description(&self) -> &str {
479479
self.__description()
@@ -548,7 +548,7 @@ impl Error for cell::BorrowMutError {
548548
}
549549
}
550550

551-
#[unstable(feature = "try_from", issue = "33417")]
551+
#[stable(feature = "try_from", since = "1.34.0")]
552552
impl Error for char::CharTryFromError {
553553
fn description(&self) -> &str {
554554
"converted integer out of range for `char`"

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@
281281
#![feature(rustc_private)]
282282
#![feature(thread_local)]
283283
#![feature(toowned_clone_into)]
284-
#![feature(try_from)]
285284
#![feature(try_reserve)]
286285
#![feature(unboxed_closures)]
287286
#![feature(untagged_unions)]

src/test/run-pass/try-from-int-error-partial-eq.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(try_from)]
21
#![allow(unused_must_use)]
32

43
use std::convert::TryFrom;

src/test/run-pass/try_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// This test was added to show the motivation for doing this
55
// over `TryFrom` being blanket impl for all `T: From`
66

7-
#![feature(try_from, never_type)]
7+
#![feature(never_type)]
88

99
use std::convert::{TryInto, Infallible};
1010

src/test/ui/e0119/conflict-with-std.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(try_from)]
21

32
use std::marker::PhantomData;
43
use std::convert::{TryFrom, AsRef};

src/test/ui/e0119/conflict-with-std.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
2-
--> $DIR/conflict-with-std.rs:7:1
2+
--> $DIR/conflict-with-std.rs:6:1
33
|
44
LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
99
where T: ?Sized;
1010

1111
error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
12-
--> $DIR/conflict-with-std.rs:14:1
12+
--> $DIR/conflict-with-std.rs:13:1
1313
|
1414
LL | impl From<S> for S { //~ ERROR conflicting implementations
1515
| ^^^^^^^^^^^^^^^^^^
@@ -18,7 +18,7 @@ LL | impl From<S> for S { //~ ERROR conflicting implementations
1818
- impl<T> std::convert::From<T> for T;
1919

2020
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
21-
--> $DIR/conflict-with-std.rs:21:1
21+
--> $DIR/conflict-with-std.rs:20:1
2222
|
2323
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
2424
| ^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)