Issue #1210: tiers: to_string() of a field of an unannotated list literal’s element still lends a temporary (E0716)

Open and answer this issue on GitHub.

ready · opened 2026-11-03 · updated 2026-11-03 · 0 comments

The fix for #1143 (39e9f9c5) covers a field whose struct the tiers pass knows (a declared list, a field, a parameter). An unannotated list literal of struct literals is not covered:

struct Site { line: i64 }
fn pad_left(s: String, n: i64) -> String { s }
fn main() {
    let sites = [Site { line: 7 }]
    for site in sites {
        let c = pad_left(site.line.to_string(), 4)
        println(c)
    }
}

rustc refuses the emitted code with E0716 (temporary value dropped while borrowed): text_tiers.nika element_struct knows no element type of an unannotated list literal, so site.line is an unknown place and its to_string() is taken as a view.

To build

  1. text_tiers.nika: record the struct of a list literal of struct literals on the local, so its elements’ fields are known places.
  2. Test in tests/compiler/ with the probe above.

Found by b35.


Generated by Claude Code

Back to Open Issues