Issue #2894: A struct result that may hold views, viewing none of several ref parameters, is ‘static, and a view through an enum variant’s payload counts as one (the rerun of #2836)

Open and answer this issue on GitHub.

ready, bugs, yaml, queued · opened 2026-11-28 · updated 2026-11-29 · 0 comments

Part of #1548 Found while #2836

What it is

“A function with two ref parameters returning a struct that may hold views” (#2836) was built in 7e55fa06 and reverted in 3d5ad47c, because it broke tests/language. The driver treats #2836 as fixed (its Fixes line is in the history), so the rerun is filed here.

Today, a function with several ref parameters that hands back a struct able to hold views, holding none, fails in rustc. The result is written E<'_, '_>: E0106 “missing lifetime specifiers … borrowed from n or ds” (NK1343). The issue’s probe is in #2836.

7e55fa06 made emit_function.nika emit_function write such a result 'static when the result-source inference (rsrc_seed/buffered) found no parameter as its source. That inference misses a view reaching the struct through an enum variant’s constructor, here one declared in another file of the package:

// tests/language/src/views_across_files.nika
fn views_across_first(text: ref String) -> ViewsAcrossLine {
    return ViewsAcrossLine { first: ViewsAcrossToken::Word(text), count: 1 }
}

So that result was written 'static, and rustc refused it with “lifetime may not live long enough”.

To build

  1. The result-source inference follows a value into a variant’s payload, including a variant of an enum declared in another file of the package, before an empty borrows may mean 'static.
  2. Re-apply 7e55fa06’s change (holds_view(ty) || self.carries_a_view(world, ty) in nothing_borrowed) and its test a_struct_of_views_viewing_none_of_two_ref_parameters_is_static.
  3. Tests: #2836’s probe prints abc -. tests/language passes 404/404, which covers views_across_files.

Done when

The probe prints abc -, tests/language passes, and --filter static, --filter borrow and --filter struct_of_views stay green.

Back to Open Issues