lock: Specialize `OncePerX` more aggressively (#57660)
Accidental regression from
https://github.com/JuliaLang/julia/pull/57289. Due to the different
specialization rules for `Function` types, the `@noinline` bodies were
inferring very poorly treating `once` as a `Function` instead of the
much more specific `OncePerX{T,F}`.
Adds a trimming test case so that we don't regress again.