ref/refmut

This commit is contained in:
Gus Wynn
2021-09-28 17:57:08 -07:00
parent 4cc3297dc4
commit cb8e83caeb
5 changed files with 14 additions and 3 deletions

View File

@@ -1303,6 +1303,11 @@ impl Clone for BorrowRef<'_> {
/// ///
/// See the [module-level documentation](self) for more. /// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a Ref across suspend \
points can cause BorrowErrors"
)]
pub struct Ref<'b, T: ?Sized + 'b> { pub struct Ref<'b, T: ?Sized + 'b> {
value: &'b T, value: &'b T,
borrow: BorrowRef<'b>, borrow: BorrowRef<'b>,
@@ -1679,6 +1684,11 @@ impl<'b> BorrowRefMut<'b> {
/// ///
/// See the [module-level documentation](self) for more. /// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a RefMut across suspend \
points can cause BorrowErrors"
)]
pub struct RefMut<'b, T: ?Sized + 'b> { pub struct RefMut<'b, T: ?Sized + 'b> {
value: &'b mut T, value: &'b mut T,
borrow: BorrowRefMut<'b>, borrow: BorrowRefMut<'b>,

View File

@@ -141,6 +141,7 @@
#![feature(link_llvm_intrinsics)] #![feature(link_llvm_intrinsics)]
#![feature(llvm_asm)] #![feature(llvm_asm)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![cfg_attr(not(bootstrap), feature(must_not_suspend))]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(never_type)] #![feature(never_type)]
#![feature(no_core)] #![feature(no_core)]

View File

@@ -192,7 +192,7 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}
not(bootstrap), not(bootstrap),
must_not_suspend = "Holding a MutexGuard across suspend \ must_not_suspend = "Holding a MutexGuard across suspend \
points can cause deadlocks, delays, \ points can cause deadlocks, delays, \
and cause Future's to not implement `Send`" and cause Futures to not implement `Send`"
)] )]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> { pub struct MutexGuard<'a, T: ?Sized + 'a> {

View File

@@ -99,7 +99,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
not(bootstrap), not(bootstrap),
must_not_suspend = "Holding a RwLockReadGuard across suspend \ must_not_suspend = "Holding a RwLockReadGuard across suspend \
points can cause deadlocks, delays, \ points can cause deadlocks, delays, \
and cause Future's to not implement `Send`" and cause Futures to not implement `Send`"
)] )]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {

View File

@@ -11,7 +11,7 @@ note: the lint level is defined here
| |
LL | #![deny(must_not_suspend)] LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
note: Holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Future's to not implement `Send` note: Holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send`
--> $DIR/mutex.rs:7:9 --> $DIR/mutex.rs:7:9
| |
LL | let _guard = m.lock().unwrap(); LL | let _guard = m.lock().unwrap();