diff options
| author | Michael Goulet <michael@errs.io> | 2025-01-05 19:11:00 +0000 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-01-10 15:54:24 -0800 |
| commit | 1b8413e296dd1d80158578049b3c97fa1e0dae4c (patch) | |
| tree | d50f1458d83d02277c941f0395f7a4cd3b8bed8d /tests | |
| parent | 273873a671380d5394a6c93157be34825e6d8c5f (diff) | |
| download | rust-1b8413e296dd1d80158578049b3c97fa1e0dae4c.tar.gz rust-1b8413e296dd1d80158578049b3c97fa1e0dae4c.zip | |
Don't do AccessDepth::Drop for types with no drop impl
(cherry picked from commit 4a099b29cdb6a7841019406f0f2b5035a1fd9a08)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/drop/tail_expr_drop_order-on-thread-local.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/ui/drop/tail_expr_drop_order-on-thread-local.rs b/tests/ui/drop/tail_expr_drop_order-on-thread-local.rs new file mode 100644 index 00000000000..e38175fd1b6 --- /dev/null +++ b/tests/ui/drop/tail_expr_drop_order-on-thread-local.rs @@ -0,0 +1,56 @@ +//@ check-pass + +#![feature(thread_local)] +#![deny(tail_expr_drop_order)] + +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; + +pub struct Global; + +#[thread_local] +static REENTRANCY_STATE: State<Global> = State { marker: PhantomData, controller: Global }; + +pub struct Token(PhantomData<*mut ()>); + +pub fn with_mut<T>(f: impl FnOnce(&mut Token) -> T) -> T { + f(&mut REENTRANCY_STATE.borrow_mut()) +} + +pub struct State<T: ?Sized = Global> { + marker: PhantomData<*mut ()>, + controller: T, +} + +impl<T: ?Sized> State<T> { + pub fn borrow_mut(&self) -> TokenMut<'_, T> { + todo!() + } +} + +pub struct TokenMut<'a, T: ?Sized = Global> { + state: &'a State<T>, + token: Token, +} + +impl<T> Deref for TokenMut<'_, T> { + type Target = Token; + + fn deref(&self) -> &Self::Target { + todo!() + } +} + +impl<T> DerefMut for TokenMut<'_, T> { + fn deref_mut(&mut self) -> &mut Self::Target { + todo!() + } +} + +impl<T: ?Sized> Drop for TokenMut<'_, T> { + fn drop(&mut self) { + todo!() + } +} + +fn main() {} |
