Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:02:16.464Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

async_block_without_await.rs

80 lines · 1.6 KB · rust
1// Tests for the `async_block_without_await` lint.
2
3#![allow(unused)]
4
5async fn returns_42() -> i32 {
6    42
7}
8
9fn sync_fn() -> i32 {
10    42
11}
12
13fn main() {
14    // --- Should warn ---
15
16    // Empty async block.
17    let _f = async {};
18
19    // Async block with a pure expression.
20    let _f = async { 42 };
21
22    // Async move block without await.
23    let _f = async move {
24        let x = 1;
25        x + 2
26    };
27
28    // Async block calling a sync function.
29    let _f = async { sync_fn() };
30
31    // Nested: the *inner* async block has no await (should warn on it).
32    // The outer block awaits the inner future, so the outer is fine.
33    let _f = async {
34        let inner = async { 42 };
35        inner.await
36    };
37
38    // --- Should NOT warn ---
39
40    // Async block with an await.
41    let _f = async { returns_42().await };
42
43    // Async block with await in a let binding.
44    let _f = async {
45        let x = returns_42().await;
46        x + 1
47    };
48
49    // Async move block with await.
50    let _f = async move { returns_42().await };
51
52    // Regular closure (not async at all).
53    let _f = || 42;
54}
55
56// --- Trait impl cases ---
57
58use std::future::Future;
59
60trait AsyncWork {
61    fn do_work(&self) -> impl Future<Output = i32>;
62}
63
64struct Worker;
65
66// Should NOT warn: the trait requires returning a future, so the
67// implementor has no choice but to use `async { ... }`.
68impl AsyncWork for Worker {
69    fn do_work(&self) -> impl Future<Output = i32> {
70        async { 42 }
71    }
72}
73
74// Should warn: inherent impl — the author chose `async` freely.
75impl Worker {
76    fn compute(&self) -> impl Future<Output = i32> {
77        async { 42 }
78    }
79}
80
Served at tenant.openagents/omega Member data and write actions are omitted.