0xMiden / 0xMiden/miden-vm

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

Aperta
#3,302 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
assembly
Lingua principale
Rust
Stelle
772
Fork
352
Merge medio
1g 12h
PR unite (30g)
93

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.