diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 3ab95438c3ff3..3935dfe309c10 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -227,7 +227,7 @@ impl dyn Any { // SAFETY: just checked whether we are pointing to the correct type, and we can rely on // that check for memory safety because we have implemented Any for all types; no other // impls can exist as they would conflict with our impl. - unsafe { Some(self.downcast_ref_unchecked()) } + unsafe { Some(self.downcast_unchecked_ref()) } } else { None } @@ -263,7 +263,7 @@ impl dyn Any { // SAFETY: just checked whether we are pointing to the correct type, and we can rely on // that check for memory safety because we have implemented Any for all types; no other // impls can exist as they would conflict with our impl. - unsafe { Some(self.downcast_mut_unchecked()) } + unsafe { Some(self.downcast_unchecked_mut()) } } else { None } @@ -281,7 +281,7 @@ impl dyn Any { /// let x: Box = Box::new(1_usize); /// /// unsafe { - /// assert_eq!(*x.downcast_ref_unchecked::(), 1); + /// assert_eq!(*x.downcast_unchecked_ref::(), 1); /// } /// ``` /// @@ -291,7 +291,7 @@ impl dyn Any { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_ref_unchecked(&self) -> &T { + pub unsafe fn downcast_unchecked_ref(&self) -> &T { debug_assert!(self.is::()); // SAFETY: caller guarantees that T is the correct type unsafe { &*(self as *const dyn Any as *const T) } @@ -309,7 +309,7 @@ impl dyn Any { /// let mut x: Box = Box::new(1_usize); /// /// unsafe { - /// *x.downcast_mut_unchecked::() += 1; + /// *x.downcast_unchecked_mut::() += 1; /// } /// /// assert_eq!(*x.downcast_ref::().unwrap(), 2); @@ -321,7 +321,7 @@ impl dyn Any { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn downcast_unchecked_mut(&mut self) -> &mut T { debug_assert!(self.is::()); // SAFETY: caller guarantees that T is the correct type unsafe { &mut *(self as *mut dyn Any as *mut T) } @@ -417,7 +417,7 @@ impl dyn Any + Send { /// let x: Box = Box::new(1_usize); /// /// unsafe { - /// assert_eq!(*x.downcast_ref_unchecked::(), 1); + /// assert_eq!(*x.downcast_unchecked_ref::(), 1); /// } /// ``` /// @@ -427,9 +427,9 @@ impl dyn Any + Send { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_ref_unchecked(&self) -> &T { + pub unsafe fn downcast_unchecked_ref(&self) -> &T { // SAFETY: guaranteed by caller - unsafe { ::downcast_ref_unchecked::(self) } + unsafe { ::downcast_unchecked_ref::(self) } } /// Forwards to the method defined on the type `dyn Any`. @@ -444,7 +444,7 @@ impl dyn Any + Send { /// let mut x: Box = Box::new(1_usize); /// /// unsafe { - /// *x.downcast_mut_unchecked::() += 1; + /// *x.downcast_unchecked_mut::() += 1; /// } /// /// assert_eq!(*x.downcast_ref::().unwrap(), 2); @@ -456,9 +456,9 @@ impl dyn Any + Send { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn downcast_unchecked_mut(&mut self) -> &mut T { // SAFETY: guaranteed by caller - unsafe { ::downcast_mut_unchecked::(self) } + unsafe { ::downcast_unchecked_mut::(self) } } } @@ -551,7 +551,7 @@ impl dyn Any + Send + Sync { /// let x: Box = Box::new(1_usize); /// /// unsafe { - /// assert_eq!(*x.downcast_ref_unchecked::(), 1); + /// assert_eq!(*x.downcast_unchecked_ref::(), 1); /// } /// ``` /// # Safety @@ -560,9 +560,9 @@ impl dyn Any + Send + Sync { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_ref_unchecked(&self) -> &T { + pub unsafe fn downcast_unchecked_ref(&self) -> &T { // SAFETY: guaranteed by caller - unsafe { ::downcast_ref_unchecked::(self) } + unsafe { ::downcast_unchecked_ref::(self) } } /// Forwards to the method defined on the type `Any`. @@ -577,7 +577,7 @@ impl dyn Any + Send + Sync { /// let mut x: Box = Box::new(1_usize); /// /// unsafe { - /// *x.downcast_mut_unchecked::() += 1; + /// *x.downcast_unchecked_mut::() += 1; /// } /// /// assert_eq!(*x.downcast_ref::().unwrap(), 2); @@ -588,9 +588,9 @@ impl dyn Any + Send + Sync { /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] - pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { + pub unsafe fn downcast_unchecked_mut(&mut self) -> &mut T { // SAFETY: guaranteed by caller - unsafe { ::downcast_mut_unchecked::(self) } + unsafe { ::downcast_unchecked_mut::(self) } } } diff --git a/tests/ui/suggestions/ambiguous-assoc-type-path-suggest-similar-item.rs b/tests/ui/suggestions/ambiguous-assoc-type-path-suggest-similar-item.rs index a9c2c20ef374a..45f9f6bc5191d 100644 --- a/tests/ui/suggestions/ambiguous-assoc-type-path-suggest-similar-item.rs +++ b/tests/ui/suggestions/ambiguous-assoc-type-path-suggest-similar-item.rs @@ -44,7 +44,7 @@ fn main() { //~^ ERROR ambiguous associated type [E0223] //~| HELP if there were a trait named `Example` with associated type `wrapping` - // this one ideally should suggest `downcast_mut_unchecked` + // this one ideally should suggest `downcast_unchecked_mut` ::downcast::mut_unchecked; //~^ ERROR ambiguous associated type [E0223] //~| HELP if there were a trait named `Example` with associated type `downcast`