From 1c71814b83f35968c9dabfa6aa79dfb65415d1e1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 11 Dec 2023 12:43:25 +0100 Subject: [PATCH] Remove accidental `::{{closure}}` suffix from all `profile_function` scopes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I inadvertantly added this in https://github.com/EmbarkStudios/puffin/issues/165, somehow not noticing it until now 🤦 --- CHANGELOG.md | 8 +++++++- puffin/src/lib.rs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b6e6a6..97fed4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate + +- Remove accidental `::{{closure}}` suffix from all `profile_function` scopes. + ## [0.18.0] - 2023-11-21 -## [0.17.1] - 2023-11-20 - [PR#165](https://github.com/EmbarkStudios/puffin/issues/165) Faster profiling, add line numbers, better paths, and better function names +## [0.17.1] - 2023-11-20 - YANKED + +- Accidentally introduced a breaking change in [PR#165](https://github.com/EmbarkStudios/puffin/issues/165) + ## [0.17.0] - 2023-09-28 - [PR#140](https://github.com/EmbarkStudios/puffin/issues/140) Remove imgui support for diff --git a/puffin/src/lib.rs b/puffin/src/lib.rs index dbcf7770..b0f5b93b 100644 --- a/puffin/src/lib.rs +++ b/puffin/src/lib.rs @@ -619,6 +619,7 @@ pub fn type_name_of(_: T) -> &'static str { } /// Returns the name of the calling function without a long module path prefix. +#[doc(hidden)] #[macro_export] macro_rules! current_function_name { () => {{ @@ -825,7 +826,10 @@ macro_rules! profile_function { // SAFETY: accessing the statics is safe because it is done in cojunction with `std::sync::Once`` let (function_name, location) = unsafe { _INITITIALIZED.call_once(|| { - _FUNCTION_NAME = $crate::current_function_name!().leak(); + let function_name = $crate::current_function_name!(); + // We call `current_function_name`, so we need to strip that from the output: + let function_name = function_name.strip_suffix("::{{closure}}").unwrap_or(function_name.as_ref()); + _FUNCTION_NAME = function_name.to_owned().leak(); _LOCATION = format!("{}:{}", $crate::current_file_name!(), line!()).leak(); }); (_FUNCTION_NAME, _LOCATION)