Skip to content

Commit e53a2a7

Browse files
committed
Stabilize the TryFrom and TryInto traits
Tracking issue: #33417
1 parent 9fd399f commit e53a2a7

File tree

12 files changed

+29
-30
lines changed

12 files changed

+29
-30
lines changed

src/libcore/array.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
5959
}
6060

6161
/// The error type returned when a conversion from a slice to an array fails.
62-
#[unstable(feature = "try_from", issue = "33417")]
62+
#[stable(feature = "try_from", since = "1.26.0")]
6363
#[derive(Debug, Copy, Clone)]
6464
pub struct TryFromSliceError(());
6565

@@ -148,7 +148,7 @@ macro_rules! array_impls {
148148
}
149149
}
150150

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

@@ -162,7 +162,7 @@ macro_rules! array_impls {
162162
}
163163
}
164164

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

src/libcore/char.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl FromStr for char {
265265
}
266266

267267

268-
#[unstable(feature = "try_from", issue = "33417")]
268+
#[stable(feature = "try_from", since = "1.26.0")]
269269
impl TryFrom<u32> for char {
270270
type Error = CharTryFromError;
271271

@@ -280,11 +280,11 @@ impl TryFrom<u32> for char {
280280
}
281281

282282
/// The error type returned when a conversion from u32 to char fails.
283-
#[unstable(feature = "try_from", issue = "33417")]
283+
#[stable(feature = "try_from", since = "1.26.0")]
284284
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
285285
pub struct CharTryFromError(());
286286

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

src/libcore/convert.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -322,22 +322,26 @@ pub trait From<T>: Sized {
322322
///
323323
/// [`TryFrom`]: trait.TryFrom.html
324324
/// [`Into`]: trait.Into.html
325-
#[unstable(feature = "try_from", issue = "33417")]
325+
#[stable(feature = "try_from", since = "1.26.0")]
326326
pub trait TryInto<T>: Sized {
327327
/// The type returned in the event of a conversion error.
328+
#[stable(feature = "try_from", since = "1.26.0")]
328329
type Error;
329330

330331
/// Performs the conversion.
332+
#[stable(feature = "try_from", since = "1.26.0")]
331333
fn try_into(self) -> Result<T, Self::Error>;
332334
}
333335

334336
/// Attempt to construct `Self` via a conversion.
335-
#[unstable(feature = "try_from", issue = "33417")]
337+
#[stable(feature = "try_from", since = "1.26.0")]
336338
pub trait TryFrom<T>: Sized {
337339
/// The type returned in the event of a conversion error.
340+
#[stable(feature = "try_from", since = "1.26.0")]
338341
type Error;
339342

340343
/// Performs the conversion.
344+
#[stable(feature = "try_from", since = "1.26.0")]
341345
fn try_from(value: T) -> Result<Self, Self::Error>;
342346
}
343347

@@ -405,7 +409,7 @@ impl<T> From<T> for T {
405409

406410

407411
// TryFrom implies TryInto
408-
#[unstable(feature = "try_from", issue = "33417")]
412+
#[stable(feature = "try_from", since = "1.26.0")]
409413
impl<T, U> TryInto<U> for T where U: TryFrom<T>
410414
{
411415
type Error = U::Error;
@@ -417,7 +421,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
417421

418422
// Infallible conversions are semantically equivalent to fallible conversions
419423
// with an uninhabited error type.
420-
#[unstable(feature = "try_from", issue = "33417")]
424+
#[stable(feature = "try_from", since = "1.26.0")]
421425
impl<T, U> TryFrom<U> for T where T: From<U> {
422426
type Error = !;
423427

src/libcore/num/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3647,7 +3647,7 @@ macro_rules! from_str_radix_int_impl {
36473647
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
36483648

36493649
/// The error type returned when a checked integral type conversion fails.
3650-
#[unstable(feature = "try_from", issue = "33417")]
3650+
#[stable(feature = "try_from", since = "1.26.0")]
36513651
#[derive(Debug, Copy, Clone)]
36523652
pub struct TryFromIntError(());
36533653

@@ -3662,14 +3662,14 @@ impl TryFromIntError {
36623662
}
36633663
}
36643664

3665-
#[unstable(feature = "try_from", issue = "33417")]
3665+
#[stable(feature = "try_from", since = "1.26.0")]
36663666
impl fmt::Display for TryFromIntError {
36673667
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
36683668
self.__description().fmt(fmt)
36693669
}
36703670
}
36713671

3672-
#[unstable(feature = "try_from", issue = "33417")]
3672+
#[stable(feature = "try_from", since = "1.26.0")]
36733673
impl From<!> for TryFromIntError {
36743674
fn from(never: !) -> TryFromIntError {
36753675
never
@@ -3679,7 +3679,7 @@ impl From<!> for TryFromIntError {
36793679
// no possible bounds violation
36803680
macro_rules! try_from_unbounded {
36813681
($source:ty, $($target:ty),*) => {$(
3682-
#[unstable(feature = "try_from", issue = "33417")]
3682+
#[stable(feature = "try_from", since = "1.26.0")]
36833683
impl TryFrom<$source> for $target {
36843684
type Error = TryFromIntError;
36853685

@@ -3694,7 +3694,7 @@ macro_rules! try_from_unbounded {
36943694
// only negative bounds
36953695
macro_rules! try_from_lower_bounded {
36963696
($source:ty, $($target:ty),*) => {$(
3697-
#[unstable(feature = "try_from", issue = "33417")]
3697+
#[stable(feature = "try_from", since = "1.26.0")]
36983698
impl TryFrom<$source> for $target {
36993699
type Error = TryFromIntError;
37003700

@@ -3713,7 +3713,7 @@ macro_rules! try_from_lower_bounded {
37133713
// unsigned to signed (only positive bound)
37143714
macro_rules! try_from_upper_bounded {
37153715
($source:ty, $($target:ty),*) => {$(
3716-
#[unstable(feature = "try_from", issue = "33417")]
3716+
#[stable(feature = "try_from", since = "1.26.0")]
37173717
impl TryFrom<$source> for $target {
37183718
type Error = TryFromIntError;
37193719

@@ -3732,7 +3732,7 @@ macro_rules! try_from_upper_bounded {
37323732
// all other cases
37333733
macro_rules! try_from_both_bounded {
37343734
($source:ty, $($target:ty),*) => {$(
3735-
#[unstable(feature = "try_from", issue = "33417")]
3735+
#[stable(feature = "try_from", since = "1.26.0")]
37363736
impl TryFrom<$source> for $target {
37373737
type Error = TryFromIntError;
37383738

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#![feature(step_trait)]
4444
#![feature(test)]
4545
#![feature(trusted_len)]
46-
#![feature(try_from)]
4746
#![feature(try_trait)]
4847
#![feature(exact_chunks)]
4948
#![feature(atomic_nand)]

src/librustc_apfloat/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
#![cfg_attr(stage0, feature(slice_patterns))]
5050
#![cfg_attr(stage0, feature(i128_type))]
51-
#![feature(try_from)]
51+
#![cfg_attr(stage0, feature(try_from))]
5252

5353
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
5454
#[allow(unused_extern_crates)]

src/libstd/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ impl Error for num::ParseIntError {
275275
}
276276
}
277277

278-
#[unstable(feature = "try_from", issue = "33417")]
278+
#[stable(feature = "try_from", since = "1.26.0")]
279279
impl Error for num::TryFromIntError {
280280
fn description(&self) -> &str {
281281
self.__description()
282282
}
283283
}
284284

285-
#[unstable(feature = "try_from", issue = "33417")]
285+
#[stable(feature = "try_from", since = "1.26.0")]
286286
impl Error for array::TryFromSliceError {
287287
fn description(&self) -> &str {
288288
self.__description()
@@ -356,7 +356,7 @@ impl Error for cell::BorrowMutError {
356356
}
357357
}
358358

359-
#[unstable(feature = "try_from", issue = "33417")]
359+
#[stable(feature = "try_from", since = "1.26.0")]
360360
impl Error for char::CharTryFromError {
361361
fn description(&self) -> &str {
362362
"converted integer out of range for `char`"

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@
310310
#![feature(test, rustc_private)]
311311
#![feature(thread_local)]
312312
#![feature(toowned_clone_into)]
313-
#![feature(try_from)]
314313
#![feature(try_reserve)]
315314
#![feature(unboxed_closures)]
316315
#![feature(unicode)]

src/libstd_unicode/char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode};
4242
pub use core::char::ParseCharError;
4343

4444
// unstable re-exports
45-
#[unstable(feature = "try_from", issue = "33417")]
45+
#[stable(feature = "try_from", since = "1.26.0")]
4646
pub use core::char::CharTryFromError;
4747
#[unstable(feature = "decode_utf8", issue = "33906")]
4848
pub use core::char::{DecodeUtf8, decode_utf8};

src/libstd_unicode/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#![feature(lang_items)]
4040
#![feature(non_exhaustive)]
4141
#![feature(staged_api)]
42-
#![feature(try_from)]
4342
#![feature(unboxed_closures)]
4443

4544
mod bool_trie;

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

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(try_from)]
12-
1311
use std::marker::PhantomData;
1412
use std::convert::{TryFrom, AsRef};
1513

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:17:1
2+
--> $DIR/conflict-with-std.rs:15: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:24:1
12+
--> $DIR/conflict-with-std.rs:22: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:31:1
21+
--> $DIR/conflict-with-std.rs:29:1
2222
|
2323
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
2424
| ^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)