diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-08-20 00:46:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-20 00:46:00 -0400 |
| commit | ef22202db230a47bd82b168684d3580c40531d28 (patch) | |
| tree | f5d7d90c247244920ac81efb57598ee33d94d8bb /tests/ui/async-await | |
| parent | 6e6522980a88f117152dafdaba7f8e21d1bdd3fd (diff) | |
| parent | ab6f4d62c0aab0f64b663bb572de8a896411b46a (diff) | |
| download | rust-ef22202db230a47bd82b168684d3580c40531d28.tar.gz rust-ef22202db230a47bd82b168684d3580c40531d28.zip | |
Rollup merge of #145623 - compiler-errors:pretty-async-name, r=wesleywiser
Pretty print the name of an future from calling async closure Fixes https://github.com/rust-lang/rust/issues/145606 by introducing a way to customize the path rendering of async closures' futures in the pretty printer API.
Diffstat (limited to 'tests/ui/async-await')
| -rw-r--r-- | tests/ui/async-await/async-closures/type-name.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/async-await/async-closures/type-name.rs b/tests/ui/async-await/async-closures/type-name.rs new file mode 100644 index 00000000000..12daad5a609 --- /dev/null +++ b/tests/ui/async-await/async-closures/type-name.rs @@ -0,0 +1,18 @@ +//@ run-pass +//@ edition: 2024 + +fn once<F: FnOnce() -> T, T>(f: F) -> T { + f() +} + +fn main() { + let closure = async || {}; + + // Name of future when called normally. + let name = std::any::type_name_of_val(&closure()); + assert_eq!(name, "type_name::main::{{closure}}::{{closure}}"); + + // Name of future when closure is called via its FnOnce shim. + let name = std::any::type_name_of_val(&once(closure)); + assert_eq!(name, "type_name::main::{{closure}}::{{closure}}::{{call_once}}"); +} |
