fn main() { let lock2 = assume_no_alias_in_many::<(Lock,), _>(|| Lock::new()); let lock1 = Lock::new(); drop(lock1); } #[non_exhaustive] pub struct Lock; impl Lock { pub fn new() -> Self { borrow_mutably::(); Self } } impl Drop for Lock { fn drop(&mut self) { unborrow_mutably::(); } } fn borrow_mutably() { fn __autoken_borrow_mutably() {} __autoken_borrow_mutably::(); } fn borrow_immutably() { fn __autoken_borrow_immutably() {} __autoken_borrow_immutably::(); } fn unborrow_mutably() { fn __autoken_unborrow_mutably() {} __autoken_unborrow_mutably::(); } fn unborrow_immutably() { fn __autoken_unborrow_immutably() {} __autoken_unborrow_immutably::(); } pub fn assume_no_alias_in_many(f: impl FnOnce() -> Res) -> Res { #[allow(clippy::extra_unused_type_parameters)] // Used by autoken fn __autoken_assume_no_alias_in_many(f: impl FnOnce() -> Res) -> Res { f() } __autoken_assume_no_alias_in_many::(f) } pub fn assume_no_alias(f: impl FnOnce() -> Res) -> Res { fn __autoken_assume_no_alias(f: impl FnOnce() -> Res) -> Res { f() } __autoken_assume_no_alias::(f) }