Skip to content

Commit b1b873f

Browse files
committed
Extend const_convert to rest of blanket core::convert impls
1 parent 83b15bf commit b1b873f

File tree

1 file changed

+15
-10
lines changed
  • library/core/src/convert

1 file changed

+15
-10
lines changed

library/core/src/convert/mod.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,10 @@ pub trait TryFrom<T>: Sized {
485485

486486
// As lifts over &
487487
#[stable(feature = "rust1", since = "1.0.0")]
488-
impl<T: ?Sized, U: ?Sized> AsRef<U> for &T
488+
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
489+
impl<T: ?Sized, U: ?Sized> const AsRef<U> for &T
489490
where
490-
T: AsRef<U>,
491+
T: ~const AsRef<U>,
491492
{
492493
fn as_ref(&self) -> &U {
493494
<T as AsRef<U>>::as_ref(*self)
@@ -496,9 +497,10 @@ where
496497

497498
// As lifts over &mut
498499
#[stable(feature = "rust1", since = "1.0.0")]
499-
impl<T: ?Sized, U: ?Sized> AsRef<U> for &mut T
500+
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
501+
impl<T: ?Sized, U: ?Sized> const AsRef<U> for &mut T
500502
where
501-
T: AsRef<U>,
503+
T: ~const AsRef<U>,
502504
{
503505
fn as_ref(&self) -> &U {
504506
<T as AsRef<U>>::as_ref(*self)
@@ -515,9 +517,10 @@ where
515517

516518
// AsMut lifts over &mut
517519
#[stable(feature = "rust1", since = "1.0.0")]
518-
impl<T: ?Sized, U: ?Sized> AsMut<U> for &mut T
520+
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
521+
impl<T: ?Sized, U: ?Sized> const AsMut<U> for &mut T
519522
where
520-
T: AsMut<U>,
523+
T: ~const AsMut<U>,
521524
{
522525
fn as_mut(&mut self) -> &mut U {
523526
(*self).as_mut()
@@ -571,9 +574,10 @@ impl<T> const From<!> for T {
571574

572575
// TryFrom implies TryInto
573576
#[stable(feature = "try_from", since = "1.34.0")]
574-
impl<T, U> TryInto<U> for T
577+
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
578+
impl<T, U> const TryInto<U> for T
575579
where
576-
U: TryFrom<T>,
580+
U: ~const TryFrom<T>,
577581
{
578582
type Error = U::Error;
579583

@@ -585,9 +589,10 @@ where
585589
// Infallible conversions are semantically equivalent to fallible conversions
586590
// with an uninhabited error type.
587591
#[stable(feature = "try_from", since = "1.34.0")]
588-
impl<T, U> TryFrom<U> for T
592+
#[rustc_const_unstable(feature = "const_convert", issue = "88674")]
593+
impl<T, U> const TryFrom<U> for T
589594
where
590-
U: Into<T>,
595+
U: ~const Into<T>,
591596
{
592597
type Error = Infallible;
593598

0 commit comments

Comments
 (0)