0xMiden / 0xMiden/miden-vm

Flag unused masm imports (exempt reachable `pub use`)

未关闭
#3,302 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
assembly
主要语言
Rust
星标
772
派生
352
平均合并
1 天 12 小时
30 天内合并 PR
93

描述

### Feature description

In MASM, imports aren't checked for use, so dead `use { … } from …` statements accumulate. While experimenting with [this PR branch](https://github.com/0xMiden/protocol/pull/3146/changes) locally I found it became slightly easier to accumulate unused imports.

I propose following Rust's `unused_imports` lint, but stricter, a hard compile error, no warn-only mode:

- Any non-`pub` import whose bound name is never referenced in its scope fails to build.
- Exempt `pub use` re-exports reachable as public API (their consumers are downstream, invisible to the checker).
- Aliases: the `X as Y` binding is what must be used. Globs (`*`): leave unlinted like Rust, if present.

I think its better to be stricter in MASM than Rust regarding unused imports since MASM's primary functionality is as a smart contract language.

### Why is this feature needed?

Remove potential footguns & potential security issues in smart contracts which use masm.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。