File tree Expand file tree Collapse file tree 1 file changed +55
-3
lines changed
Expand file tree Collapse file tree 1 file changed +55
-3
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,43 @@ pub mod expecting_unsafe_fn {
241241 {
242242 unreachable ! ( )
243243 }
244+ /// Twelve arguments.
245+ #[ allow( clippy:: module_inception) ]
246+ pub mod arg {
247+ /// Used by `unsafe_fn`.
248+ #[ allow( clippy:: too_many_arguments) ]
249+ pub unsafe fn fun <
250+ A1 ,
251+ A2 ,
252+ A3 ,
253+ A4 ,
254+ A5 ,
255+ A6 ,
256+ A7 ,
257+ A8 ,
258+ A9 ,
259+ A10 ,
260+ A11 ,
261+ A12 ,
262+ R ,
263+ > (
264+ _: A1 ,
265+ _: A2 ,
266+ _: A3 ,
267+ _: A4 ,
268+ _: A5 ,
269+ _: A6 ,
270+ _: A7 ,
271+ _: A8 ,
272+ _: A9 ,
273+ _: A10 ,
274+ _: A11 ,
275+ _: A12 ,
276+ ) -> R
277+ {
278+ unreachable ! ( )
279+ }
280+ }
244281 }
245282 }
246283 }
@@ -327,10 +364,25 @@ macro_rules! expecting_unsafe_fn_path {
327364/// Use the result of `unsafe_fn!` immediately as a mutable array/slice (assign/modify its slot(s)).
328365/// ```
329366/// # use prudent::unsafe_fn;
330- /// unsafe fn return_mut_ref_array() -> &'static mut [bool; 1] { let boxed = Box::new([true]);
331- /// Box::leak(boxed) }
367+ /// // NOT running under MIRI, because of the intentional leak.
368+ /// if !cfg!(miri) {
369+ /// unsafe fn return_mut_ref_array() -> &'static mut [bool; 1] {
370+ /// let boxed = Box::new([true]);
371+ /// Box::leak(boxed)
372+ /// }
373+ ///
374+ /// unsafe_fn!( return_mut_ref_array)[0] = true;
375+ /// }
376+ /// ```
377+ /// The same, but without a leak:
378+ /// ```
379+ /// # use prudent::unsafe_fn;
380+ /// unsafe fn return_same_mut_ref<T>(mref: &mut T) -> &mut T {
381+ /// mref
382+ /// }
332383///
333- /// unsafe_fn!( return_mut_ref_array)[0] = true;
384+ /// let mut marray = [true];
385+ /// unsafe_fn!( return_same_mut_ref, &mut marray )[0] = true;
334386/// ```
335387/// TODO docs about tuple tree
336388#[ macro_export]
You can’t perform that action at this time.
0 commit comments