Require DerefPure for patterns
This commit is contained in:
parent
5f2c7d2bfd
commit
b56279569b
11 changed files with 41 additions and 5 deletions
|
@ -199,6 +199,7 @@ language_item_table! {
|
||||||
|
|
||||||
Deref, sym::deref, deref_trait, Target::Trait, GenericRequirement::Exact(0);
|
Deref, sym::deref, deref_trait, Target::Trait, GenericRequirement::Exact(0);
|
||||||
DerefMut, sym::deref_mut, deref_mut_trait, Target::Trait, GenericRequirement::Exact(0);
|
DerefMut, sym::deref_mut, deref_mut_trait, Target::Trait, GenericRequirement::Exact(0);
|
||||||
|
DerefPure, sym::deref_pure, deref_pure_trait, Target::Trait, GenericRequirement::Exact(0);
|
||||||
DerefTarget, sym::deref_target, deref_target, Target::AssocTy, GenericRequirement::None;
|
DerefTarget, sym::deref_target, deref_target, Target::AssocTy, GenericRequirement::None;
|
||||||
Receiver, sym::receiver, receiver_trait, Target::Trait, GenericRequirement::None;
|
Receiver, sym::receiver, receiver_trait, Target::Trait, GenericRequirement::None;
|
||||||
|
|
||||||
|
|
|
@ -2002,8 +2002,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
pat_info: PatInfo<'tcx, '_>,
|
pat_info: PatInfo<'tcx, '_>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
// FIXME(deref_patterns): use `DerefPure` for soundness
|
// Register a `DerefPure` bound, which is required by all `deref!()` pats.
|
||||||
// FIXME(deref_patterns): use `DerefMut` when required
|
self.register_bound(
|
||||||
|
expected,
|
||||||
|
tcx.require_lang_item(hir::LangItem::DerefPure, Some(span)),
|
||||||
|
self.misc(span),
|
||||||
|
);
|
||||||
// <expected as Deref>::Target
|
// <expected as Deref>::Target
|
||||||
let ty = Ty::new_projection(
|
let ty = Ty::new_projection(
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -674,6 +674,7 @@ symbols! {
|
||||||
deref_mut,
|
deref_mut,
|
||||||
deref_mut_method,
|
deref_mut_method,
|
||||||
deref_patterns,
|
deref_patterns,
|
||||||
|
deref_pure,
|
||||||
deref_target,
|
deref_target,
|
||||||
derive,
|
derive,
|
||||||
derive_const,
|
derive_const,
|
||||||
|
|
|
@ -161,7 +161,7 @@ use core::marker::Unsize;
|
||||||
use core::mem::{self, SizedTypeProperties};
|
use core::mem::{self, SizedTypeProperties};
|
||||||
use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
|
use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
|
||||||
use core::ops::{
|
use core::ops::{
|
||||||
CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DispatchFromDyn, Receiver,
|
CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver,
|
||||||
};
|
};
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::ptr::{self, addr_of_mut, NonNull, Unique};
|
use core::ptr::{self, addr_of_mut, NonNull, Unique};
|
||||||
|
@ -1939,6 +1939,9 @@ impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T: ?Sized, A: Allocator> DerefPure for Box<T, A> {}
|
||||||
|
|
||||||
#[unstable(feature = "receiver_trait", issue = "none")]
|
#[unstable(feature = "receiver_trait", issue = "none")]
|
||||||
impl<T: ?Sized, A: Allocator> Receiver for Box<T, A> {}
|
impl<T: ?Sized, A: Allocator> Receiver for Box<T, A> {}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@
|
||||||
#![feature(const_waker)]
|
#![feature(const_waker)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(deprecated_suggestion)]
|
#![feature(deprecated_suggestion)]
|
||||||
|
#![feature(deref_pure_trait)]
|
||||||
#![feature(dispatch_from_dyn)]
|
#![feature(dispatch_from_dyn)]
|
||||||
#![feature(error_generic_member_access)]
|
#![feature(error_generic_member_access)]
|
||||||
#![feature(error_in_core)]
|
#![feature(error_in_core)]
|
||||||
|
|
|
@ -260,7 +260,7 @@ use core::marker::{PhantomData, Unsize};
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
use core::mem::size_of_val;
|
use core::mem::size_of_val;
|
||||||
use core::mem::{self, align_of_val_raw, forget, ManuallyDrop};
|
use core::mem::{self, align_of_val_raw, forget, ManuallyDrop};
|
||||||
use core::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Receiver};
|
use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver};
|
||||||
use core::panic::{RefUnwindSafe, UnwindSafe};
|
use core::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
|
@ -2126,6 +2126,9 @@ impl<T: ?Sized, A: Allocator> Deref for Rc<T, A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T: ?Sized, A: Allocator> DerefPure for Rc<T, A> {}
|
||||||
|
|
||||||
#[unstable(feature = "receiver_trait", issue = "none")]
|
#[unstable(feature = "receiver_trait", issue = "none")]
|
||||||
impl<T: ?Sized> Receiver for Rc<T> {}
|
impl<T: ?Sized> Receiver for Rc<T> {}
|
||||||
|
|
||||||
|
|
|
@ -2479,6 +2479,9 @@ impl ops::Deref for String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl ops::DerefPure for String {}
|
||||||
|
|
||||||
#[stable(feature = "derefmut_for_string", since = "1.3.0")]
|
#[stable(feature = "derefmut_for_string", since = "1.3.0")]
|
||||||
impl ops::DerefMut for String {
|
impl ops::DerefMut for String {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -21,7 +21,7 @@ use core::marker::{PhantomData, Unsize};
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
use core::mem::size_of_val;
|
use core::mem::size_of_val;
|
||||||
use core::mem::{self, align_of_val_raw};
|
use core::mem::{self, align_of_val_raw};
|
||||||
use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
|
use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, Receiver};
|
||||||
use core::panic::{RefUnwindSafe, UnwindSafe};
|
use core::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::ptr::{self, NonNull};
|
use core::ptr::{self, NonNull};
|
||||||
|
@ -2107,6 +2107,9 @@ impl<T: ?Sized, A: Allocator> Deref for Arc<T, A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T: ?Sized, A: Allocator> DerefPure for Arc<T, A> {}
|
||||||
|
|
||||||
#[unstable(feature = "receiver_trait", issue = "none")]
|
#[unstable(feature = "receiver_trait", issue = "none")]
|
||||||
impl<T: ?Sized> Receiver for Arc<T> {}
|
impl<T: ?Sized> Receiver for Arc<T> {}
|
||||||
|
|
||||||
|
|
|
@ -2772,6 +2772,9 @@ impl<T, A: Allocator> ops::DerefMut for Vec<T, A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T, A: Allocator> ops::DerefPure for Vec<T, A> {}
|
||||||
|
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
|
impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
|
||||||
|
|
|
@ -275,6 +275,17 @@ impl<T: ?Sized> DerefMut for &mut T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// UwU
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
#[cfg_attr(not(bootstrap), lang = "deref_pure")]
|
||||||
|
pub unsafe trait DerefPure {}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T: ?Sized> DerefPure for &T {}
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
unsafe impl<T: ?Sized> DerefPure for &mut T {}
|
||||||
|
|
||||||
/// Indicates that a struct can be used as a method receiver, without the
|
/// Indicates that a struct can be used as a method receiver, without the
|
||||||
/// `arbitrary_self_types` feature. This is implemented by stdlib pointer types like `Box<T>`,
|
/// `arbitrary_self_types` feature. This is implemented by stdlib pointer types like `Box<T>`,
|
||||||
/// `Rc<T>`, `&T`, and `Pin<P>`.
|
/// `Rc<T>`, `&T`, and `Pin<P>`.
|
||||||
|
|
|
@ -165,6 +165,9 @@ pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssig
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use self::deref::{Deref, DerefMut};
|
pub use self::deref::{Deref, DerefMut};
|
||||||
|
|
||||||
|
#[unstable(feature = "deref_pure_trait", issue = "87121")]
|
||||||
|
pub use self::deref::DerefPure;
|
||||||
|
|
||||||
#[unstable(feature = "receiver_trait", issue = "none")]
|
#[unstable(feature = "receiver_trait", issue = "none")]
|
||||||
pub use self::deref::Receiver;
|
pub use self::deref::Receiver;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue