-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't do AccessDepth::Drop for types with no drop impl
- Loading branch information
1 parent
197f6d8
commit 4a099b2
Showing
2 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |