|
| 1 | +(* Generated by coq-of-rust *) |
| 2 | +Require Import CoqOfRust.CoqOfRust. |
| 3 | + |
| 4 | +Module collections. |
| 5 | + Module btree. |
| 6 | + Module borrow. |
| 7 | + (* StructRecord |
| 8 | + { |
| 9 | + name := "DormantMutRef"; |
| 10 | + ty_params := [ "T" ]; |
| 11 | + fields := |
| 12 | + [ |
| 13 | + ("ptr", Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ]); |
| 14 | + ("_marker", |
| 15 | + Ty.apply (Ty.path "core::marker::PhantomData") [ Ty.apply (Ty.path "&mut") [ T ] ]) |
| 16 | + ]; |
| 17 | + } *) |
| 18 | + |
| 19 | + Module Impl_core_marker_Sync_where_core_marker_Sync_ref_mut_T_for_alloc_collections_btree_borrow_DormantMutRef_T. |
| 20 | + Definition Self (T : Ty.t) : Ty.t := |
| 21 | + Ty.apply (Ty.path "alloc::collections::btree::borrow::DormantMutRef") [ T ]. |
| 22 | + |
| 23 | + Axiom Implements : |
| 24 | + forall (T : Ty.t), |
| 25 | + M.IsTraitInstance |
| 26 | + "core::marker::Sync" |
| 27 | + (Self T) |
| 28 | + (* Trait polymorphic types *) [] |
| 29 | + (* Instance *) []. |
| 30 | + End Impl_core_marker_Sync_where_core_marker_Sync_ref_mut_T_for_alloc_collections_btree_borrow_DormantMutRef_T. |
| 31 | + |
| 32 | + Module Impl_core_marker_Send_where_core_marker_Send_ref_mut_T_for_alloc_collections_btree_borrow_DormantMutRef_T. |
| 33 | + Definition Self (T : Ty.t) : Ty.t := |
| 34 | + Ty.apply (Ty.path "alloc::collections::btree::borrow::DormantMutRef") [ T ]. |
| 35 | + |
| 36 | + Axiom Implements : |
| 37 | + forall (T : Ty.t), |
| 38 | + M.IsTraitInstance |
| 39 | + "core::marker::Send" |
| 40 | + (Self T) |
| 41 | + (* Trait polymorphic types *) [] |
| 42 | + (* Instance *) []. |
| 43 | + End Impl_core_marker_Send_where_core_marker_Send_ref_mut_T_for_alloc_collections_btree_borrow_DormantMutRef_T. |
| 44 | + |
| 45 | + Module Impl_alloc_collections_btree_borrow_DormantMutRef_T. |
| 46 | + Definition Self (T : Ty.t) : Ty.t := |
| 47 | + Ty.apply (Ty.path "alloc::collections::btree::borrow::DormantMutRef") [ T ]. |
| 48 | + |
| 49 | + (* |
| 50 | + pub fn new(t: &'a mut T) -> (&'a mut T, Self) { |
| 51 | + let ptr = NonNull::from(t); |
| 52 | + // SAFETY: we hold the borrow throughout 'a via `_marker`, and we expose |
| 53 | + // only this reference, so it is unique. |
| 54 | + let new_ref = unsafe { &mut *ptr.as_ptr() }; |
| 55 | + (new_ref, Self { ptr, _marker: PhantomData }) |
| 56 | + } |
| 57 | + *) |
| 58 | + Definition new (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := |
| 59 | + let Self : Ty.t := Self T in |
| 60 | + match τ, α with |
| 61 | + | [], [ t ] => |
| 62 | + ltac:(M.monadic |
| 63 | + (let t := M.alloc (| t |) in |
| 64 | + M.read (| |
| 65 | + let ptr := |
| 66 | + M.alloc (| |
| 67 | + M.call_closure (| |
| 68 | + M.get_trait_method (| |
| 69 | + "core::convert::From", |
| 70 | + Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ], |
| 71 | + [ Ty.apply (Ty.path "&mut") [ T ] ], |
| 72 | + "from", |
| 73 | + [] |
| 74 | + |), |
| 75 | + [ M.read (| t |) ] |
| 76 | + |) |
| 77 | + |) in |
| 78 | + let new_ref := |
| 79 | + M.alloc (| |
| 80 | + M.call_closure (| |
| 81 | + M.get_associated_function (| |
| 82 | + Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ], |
| 83 | + "as_ptr", |
| 84 | + [] |
| 85 | + |), |
| 86 | + [ M.read (| ptr |) ] |
| 87 | + |) |
| 88 | + |) in |
| 89 | + M.alloc (| |
| 90 | + Value.Tuple |
| 91 | + [ |
| 92 | + M.read (| new_ref |); |
| 93 | + Value.StructRecord |
| 94 | + "alloc::collections::btree::borrow::DormantMutRef" |
| 95 | + [ |
| 96 | + ("ptr", M.read (| ptr |)); |
| 97 | + ("_marker", Value.StructTuple "core::marker::PhantomData" []) |
| 98 | + ] |
| 99 | + ] |
| 100 | + |) |
| 101 | + |))) |
| 102 | + | _, _ => M.impossible |
| 103 | + end. |
| 104 | + |
| 105 | + Axiom AssociatedFunction_new : |
| 106 | + forall (T : Ty.t), |
| 107 | + M.IsAssociatedFunction (Self T) "new" (new T). |
| 108 | + |
| 109 | + (* |
| 110 | + pub unsafe fn awaken(self) -> &'a mut T { |
| 111 | + // SAFETY: our own safety conditions imply this reference is again unique. |
| 112 | + unsafe { &mut *self.ptr.as_ptr() } |
| 113 | + } |
| 114 | + *) |
| 115 | + Definition awaken (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := |
| 116 | + let Self : Ty.t := Self T in |
| 117 | + match τ, α with |
| 118 | + | [], [ self ] => |
| 119 | + ltac:(M.monadic |
| 120 | + (let self := M.alloc (| self |) in |
| 121 | + M.call_closure (| |
| 122 | + M.get_associated_function (| |
| 123 | + Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ], |
| 124 | + "as_ptr", |
| 125 | + [] |
| 126 | + |), |
| 127 | + [ |
| 128 | + M.read (| |
| 129 | + M.get_struct_record_field |
| 130 | + self |
| 131 | + "alloc::collections::btree::borrow::DormantMutRef" |
| 132 | + "ptr" |
| 133 | + |) |
| 134 | + ] |
| 135 | + |))) |
| 136 | + | _, _ => M.impossible |
| 137 | + end. |
| 138 | + |
| 139 | + Axiom AssociatedFunction_awaken : |
| 140 | + forall (T : Ty.t), |
| 141 | + M.IsAssociatedFunction (Self T) "awaken" (awaken T). |
| 142 | + |
| 143 | + (* |
| 144 | + pub unsafe fn reborrow(&mut self) -> &'a mut T { |
| 145 | + // SAFETY: our own safety conditions imply this reference is again unique. |
| 146 | + unsafe { &mut *self.ptr.as_ptr() } |
| 147 | + } |
| 148 | + *) |
| 149 | + Definition reborrow (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := |
| 150 | + let Self : Ty.t := Self T in |
| 151 | + match τ, α with |
| 152 | + | [], [ self ] => |
| 153 | + ltac:(M.monadic |
| 154 | + (let self := M.alloc (| self |) in |
| 155 | + M.call_closure (| |
| 156 | + M.get_associated_function (| |
| 157 | + Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ], |
| 158 | + "as_ptr", |
| 159 | + [] |
| 160 | + |), |
| 161 | + [ |
| 162 | + M.read (| |
| 163 | + M.get_struct_record_field |
| 164 | + (M.read (| self |)) |
| 165 | + "alloc::collections::btree::borrow::DormantMutRef" |
| 166 | + "ptr" |
| 167 | + |) |
| 168 | + ] |
| 169 | + |))) |
| 170 | + | _, _ => M.impossible |
| 171 | + end. |
| 172 | + |
| 173 | + Axiom AssociatedFunction_reborrow : |
| 174 | + forall (T : Ty.t), |
| 175 | + M.IsAssociatedFunction (Self T) "reborrow" (reborrow T). |
| 176 | + |
| 177 | + (* |
| 178 | + pub unsafe fn reborrow_shared(&self) -> &'a T { |
| 179 | + // SAFETY: our own safety conditions imply this reference is again unique. |
| 180 | + unsafe { &*self.ptr.as_ptr() } |
| 181 | + } |
| 182 | + *) |
| 183 | + Definition reborrow_shared (T : Ty.t) (τ : list Ty.t) (α : list Value.t) : M := |
| 184 | + let Self : Ty.t := Self T in |
| 185 | + match τ, α with |
| 186 | + | [], [ self ] => |
| 187 | + ltac:(M.monadic |
| 188 | + (let self := M.alloc (| self |) in |
| 189 | + M.call_closure (| |
| 190 | + M.get_associated_function (| |
| 191 | + Ty.apply (Ty.path "core::ptr::non_null::NonNull") [ T ], |
| 192 | + "as_ptr", |
| 193 | + [] |
| 194 | + |), |
| 195 | + [ |
| 196 | + M.read (| |
| 197 | + M.get_struct_record_field |
| 198 | + (M.read (| self |)) |
| 199 | + "alloc::collections::btree::borrow::DormantMutRef" |
| 200 | + "ptr" |
| 201 | + |) |
| 202 | + ] |
| 203 | + |))) |
| 204 | + | _, _ => M.impossible |
| 205 | + end. |
| 206 | + |
| 207 | + Axiom AssociatedFunction_reborrow_shared : |
| 208 | + forall (T : Ty.t), |
| 209 | + M.IsAssociatedFunction (Self T) "reborrow_shared" (reborrow_shared T). |
| 210 | + End Impl_alloc_collections_btree_borrow_DormantMutRef_T. |
| 211 | + End borrow. |
| 212 | + End btree. |
| 213 | +End collections. |
0 commit comments