# Valen 借用检查器：逆向时间旅行

Original title: A new way to think about borrow checking (in reverse)

> Hacker News story 50140383 · language: zh · submitted 2026-10-18
> Web version: https://zeli.app/zh/story/50140383
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 132 · by [verdagon](<https://news.ycombinator.com/user?id=verdagon>) · 💬 19
[original](<https://verdagon.dev/blog/reverse-borrow-checking>) · [HN discussion](<https://news.ycombinator.com/item?id=50140383>)

## Summary

你是否想过逆向遍历函数能带来什么？Valen 的借用检查器做到了这一点。它不走寻常路，在安全检测阶段从函数末尾反向扫描至开头。这种独特的逆向机制能更优雅地处理循环和变量生命周期，精准捕捉 use-after-free 错误。不同于 Rust 或 Vale 的前向检查逻辑，Valen 通过逆向扫描将“未来”的使用信息提前纳入考量，为内存安全提供了一种全新的思考维度。

## Key quote

> 几年前，如果你告诉我逆向遍历函数是个好主意，我会觉得你疯了。

## HN discussion (19 comments)

### [Animats](<https://news.ycombinator.com/item?id=50148685>)

> 很有意思。
>
> 在 Hoare 类型的正确性证明工作中，通常的做法是从证明目标（例如 assert 语句）出发，反向向上回溯程序，添加关于影响断言中变量的代码的信息。这种借用检查的方法遵循了这一模式。你需要在某个时刻拥有某种状态，然后反向回溯，看看前面的代码能否让你达到该状态。这对生命周期来说非常合理。
>
> 在编译器内部这样做的主要问题是性能。你需要为每一个需要证明的内容进行回溯，导致同一段代码被多次遍历。我过去曾认为编译器应该更多地采用验证技术，但人们一听到编译时间增加就开始抱怨。

### [verdagon](<https://news.ycombinator.com/item?id=50140433>)

> 弄清楚如何实现这一点的过程简直像坐过山车一样刺激。我一开始完全不知道该如何入手，于是带着纸笔进了山里，直到想出了点门道。
>
> 我最初尝试的是一种“编译时代际引用”的方法，即每个引用在编译时都会记录它是何时创建的。后来这个方法又演变成了其他几种思路，直到我终于想出了这种反向方法。接下来我们拭目以待，看它是否能行得通。
>
> 希望大家喜欢！

### [gnarlouse](<https://news.ycombinator.com/item?id=50147174>)

> 我没什么能帮上的，但作为一个旁观者，作为一个热爱 Rust 的人，我真心希望 @verdagon 能从中收获美好的结果！

---

## Cite

- Page: https://zeli.app/zh/story/50140383
- Date: 2026-10-18
- Source: verdagon.dev (https://verdagon.dev/blog/reverse-borrow-checking)
- Hacker News: https://news.ycombinator.com/item?id=50140383

## Other languages

- en: https://zeli.app/story/50140383 · markdown: https://zeli.app/story/50140383.md
- ja: https://zeli.app/ja/story/50140383 · markdown: https://zeli.app/ja/story/50140383.md
- ko: https://zeli.app/ko/story/50140383 · markdown: https://zeli.app/ko/story/50140383.md
- de: https://zeli.app/de/story/50140383 · markdown: https://zeli.app/de/story/50140383.md
- es: https://zeli.app/es/story/50140383 · markdown: https://zeli.app/es/story/50140383.md
- ru: https://zeli.app/ru/story/50140383 · markdown: https://zeli.app/ru/story/50140383.md
