More test cases for tracked_fn_return_ref

This commit is contained in:
Lukas Wirth 2025-02-15 18:14:35 +01:00
parent d9afdc9182
commit 0017fb24b9
2 changed files with 60 additions and 0 deletions

View file

@ -26,4 +26,24 @@ fn tracked_fn_return_struct_containing_ref<'db>(
}
}
#[salsa::tracked]
fn tracked_fn_return_struct_containing_ref_elided_implicit<'db>(
db: &'db dyn Db,
input: MyInput,
) -> ContainsRef {
ContainsRef {
text: input.text(db),
}
}
#[salsa::tracked]
fn tracked_fn_return_struct_containing_ref_elided_explicit<'db>(
db: &'db dyn Db,
input: MyInput,
) -> ContainsRef<'_> {
ContainsRef {
text: input.text(db),
}
}
fn main() {}

View file

@ -1,3 +1,34 @@
error[E0106]: missing lifetime specifier
--> tests/compile-fail/tracked_fn_return_ref.rs:33:6
|
33 | ) -> ContainsRef {
| ^^^^^^^^^^^ expected named lifetime parameter
|
help: consider using the `'db` lifetime
|
33 | ) -> ContainsRef<'db> {
| +++++
warning: elided lifetime has a name
--> tests/compile-fail/tracked_fn_return_ref.rs:33:6
|
30 | fn tracked_fn_return_struct_containing_ref_elided_implicit<'db>(
| --- lifetime `'db` declared here
...
33 | ) -> ContainsRef {
| ^^^^^^^^^^^ this elided lifetime gets resolved as `'db`
|
= note: `#[warn(elided_named_lifetimes)]` on by default
warning: elided lifetime has a name
--> tests/compile-fail/tracked_fn_return_ref.rs:43:18
|
40 | fn tracked_fn_return_struct_containing_ref_elided_explicit<'db>(
| --- lifetime `'db` declared here
...
43 | ) -> ContainsRef<'_> {
| ^^ this elided lifetime gets resolved as `'db`
error: lifetime may not live long enough
--> tests/compile-fail/tracked_fn_return_ref.rs:15:67
|
@ -12,3 +43,12 @@ error: lifetime may not live long enough
...
23 | ) -> ContainsRef<'db> {
| ^^^^^^^^^^^ requires that `'db` must outlive `'static`
error: lifetime may not live long enough
--> tests/compile-fail/tracked_fn_return_ref.rs:43:6
|
40 | fn tracked_fn_return_struct_containing_ref_elided_explicit<'db>(
| --- lifetime `'db` defined here
...
43 | ) -> ContainsRef<'_> {
| ^^^^^^^^^^^ requires that `'db` must outlive `'static`