File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -149,8 +149,32 @@ pub const fn forget<T>(t: T) {
149149
150150/// Like [`forget`], but also accepts unsized values.
151151///
152- /// This function is just a shim intended to be removed when the `unsized_locals` feature gets
153- /// stabilized.
152+ /// While Rust does not permit unsized locals since its removal in [#111942] it is
153+ /// still possible to call functions with unsized values from a function argument
154+ /// or in-place construction.
155+ ///
156+ /// ```rust
157+ /// #![feature(unsized_fn_params, forget_unsized)]
158+ /// #![allow(internal_features)]
159+ ///
160+ /// use std::mem::forget_unsized;
161+ ///
162+ /// pub fn in_place() {
163+ /// forget_unsized(*Box::<str>::from("str"));
164+ /// }
165+ ///
166+ /// pub fn param(x: str) {
167+ /// forget_unsized(x);
168+ /// }
169+ /// ```
170+ ///
171+ /// This works because the compiler will alter these functions to pass the parameter
172+ /// by reference instead. This trick is necessary to support `Box<dyn FnOnce()>: FnOnce()`.
173+ /// See [#68304] and [#71170] for more information.
174+ ///
175+ /// [#111942]: https://github.com/rust-lang/rust/issues/111942
176+ /// [#68304]: https://github.com/rust-lang/rust/issues/68304
177+ /// [#71170]: https://github.com/rust-lang/rust/pull/71170
154178#[ inline]
155179#[ unstable( feature = "forget_unsized" , issue = "none" ) ]
156180pub fn forget_unsized < T : ?Sized > ( t : T ) {
Original file line number Diff line number Diff line change @@ -653,7 +653,6 @@ fn thin_box() {
653653 // if `{size,align}_of_for_meta<T: ?Sized>(T::Metadata)` are added.
654654 // * Constructing a `ThinBox` without consuming and deallocating a `Box`
655655 // requires either the unstable `Unsize` marker trait,
656- // or the unstable `unsized_locals` language feature,
657656 // or taking `&dyn T` and restricting to `T: Copy`.
658657
659658 use std:: alloc:: * ;
You can’t perform that action at this time.
0 commit comments