Skip to content

Commit 38e20bb

Browse files
committed
Add test that statics still work
1 parent f2fbc8e commit 38e20bb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/tracked_fn_return_static.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Test that a `tracked` function can return a
2+
//! non-`Update` type, so long as it has `'static` lifetime.
3+
4+
use salsa::Database;
5+
6+
#[salsa::input]
7+
struct Input {}
8+
9+
#[salsa::tracked]
10+
fn test(_db: &dyn salsa::Database, _: Input) -> &'static str {
11+
"test"
12+
}
13+
14+
#[test]
15+
fn invoke() {
16+
salsa::DatabaseImpl::new().attach(|db| {
17+
let input = Input::new(db);
18+
let x: &str = test(db, input);
19+
assert_eq!(x, "test");
20+
})
21+
}

0 commit comments

Comments
 (0)