turbo
3683efc2 - vdbg! macro (#4868)

Commit
2 years ago
vdbg! macro (#4868) ### Description The `vdbg!` macro works the same way as the `dbg!` macro, with the additional benefit of automatically calling `ValueDebugFormat` implementations. This means that you can do: ```rust vdbg!(42, asset_ident_vc); vdbg!(42, asset_ident_vc; depth = 1); ``` and the macro will print out ```rust [src/main.rs:10] 42 = 42 [src/main.rs:10] some_vc = AssetIdent { path: FileSystemPath { fs: FileSystem(DiskFileSystem { name: "project", root: "...", }), path: "...", }, query: None, fragment: None, assets: [], modifiers: [], part: None, } ``` ```rust [src/main.rs:10] 42 = 42 [src/main.rs:10] asset_ident_vc = AssetIdent { path: FileSystemPath, query: core::option::Option<turbo_tasks::primitives::StringVc>, fragment: core::option::Option<turbo_tasks::primitives::StringVc>, assets: alloc::vec::Vec<(turbo_tasks::primitives::StringVc, turbopack_core::ident::AssetIdentVc)>, modifiers: alloc::vec::Vec<turbo_tasks::primitives::StringVc>, part: core::option::Option<turbopack_core::resolve::ModulePartVc>, } ``` This is an ergonomic improvement over having to call `.dbg()` or `.dbg_depth()` manually in four major ways: 1. No need to be in an async context and call `.await?`: the macro will spawn a task on its own. This means that it is no longer necessary to convert a `turbo_tasks::function` to async just to debug one of its arguments. 2. No need to import the `turbo_tasks::debug::ValueDebug` trait. You can call `turbo_tasks::vdbg!(...)` directly, of `vdbg!(...)` if you have it imported already. 3. No need to call `eprintln!` or `dbg!`: `vdbg!` calls `eprintln!` directly under the hood, with the same format as `dbg!`. 4. It's just one macro, with support for the `depth` argument baked in. ### Testing Instructions N/A link WEB-520
Author
Parents
Loading