fix: profile_tokio broken due to incompatible types #49

Merged
nondescriptpointer merged 2 commits from fix/profile-tokio-incompatible-types into dev 2025-08-18 21:52:09 -04:00

View File

@@ -17,6 +17,7 @@ pub fn new<
#[cfg(feature = "profile_tokio")]
coderabbitai[bot] commented 2025-08-17 16:12:03 -04:00 (Migrated from github.com)
Review

⚠️ Potential issue

Fix: Builder::spawn returns JoinHandle, not Result; remove map_err and wrap in Ok(...)

.spawn(async_future) returns JoinHandle<O>. There’s nothing to map via map_err; this won’t compile. To keep the return type Result<JoinHandle<O>> consistent with the non-profile_tokio branch, wrap the spawn in Ok(...).

Apply this diff:

-  .spawn(async_future).map_err(Into::into);
+  .spawn(async_future));

And wrap the whole expression in Ok(...):

-#[cfg(feature = "profile_tokio")]
-let result = tokio::task::Builder::new()
-  .name(name_fn().as_ref())
-  .spawn(async_future).map_err(Into::into);
+#[cfg(feature = "profile_tokio")]
+let result = Ok(tokio::task::Builder::new()
+  .name(name_fn().as_ref())
+  .spawn(async_future));
🤖 Prompt for AI Agents
In src/core/task.rs around lines 18 to 21, the code calls Builder::spawn which
returns a JoinHandle but then incorrectly calls map_err on it; remove the
map_err(Into::into) call and wrap the spawn result in Ok(... ) so the function
returns Result<JoinHandle<O>> consistent with the non-profile_tokio branch (i.e.
replace the map_err usage with returning
Ok(tokio::task::Builder::new().name(name_fn().as_ref()).spawn(async_future))).
_⚠️ Potential issue_ **Fix: Builder::spawn returns JoinHandle, not Result; remove map_err and wrap in Ok(...)** `.spawn(async_future)` returns `JoinHandle<O>`. There’s nothing to map via `map_err`; this won’t compile. To keep the return type `Result<JoinHandle<O>>` consistent with the non-`profile_tokio` branch, wrap the spawn in `Ok(...)`. Apply this diff: ```diff - .spawn(async_future).map_err(Into::into); + .spawn(async_future)); ``` And wrap the whole expression in `Ok(...)`: ```diff -#[cfg(feature = "profile_tokio")] -let result = tokio::task::Builder::new() - .name(name_fn().as_ref()) - .spawn(async_future).map_err(Into::into); +#[cfg(feature = "profile_tokio")] +let result = Ok(tokio::task::Builder::new() + .name(name_fn().as_ref()) + .spawn(async_future)); ``` <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/core/task.rs around lines 18 to 21, the code calls Builder::spawn which returns a JoinHandle but then incorrectly calls map_err on it; remove the map_err(Into::into) call and wrap the spawn result in Ok(... ) so the function returns Result<JoinHandle<O>> consistent with the non-profile_tokio branch (i.e. replace the map_err usage with returning Ok(tokio::task::Builder::new().name(name_fn().as_ref()).spawn(async_future))). ``` </details> <!-- fingerprinting:phantom:poseidon:chinchilla --> <!-- This is an auto-generated comment by CodeRabbit -->
let result = tokio::task::Builder::new()
.name(name_fn().as_ref())
.spawn(async_future);
.spawn(async_future)
.map_err(Into::into);
result
}