rust-lang / rust-lang/rust

Tracking Issue for strict_provenance_lints

Open
#130,351 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-strict-provenance B-experimental C-tracking-issue T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Original split-lint description for posterity

This tracks the two lints associated with the strict provenance feature:

  • fuzzy_provenance_casts: detects an as cast from an integer to a pointer. It is better to use with_exposed_provenance instead to make explicit what happens.
  • lossy_provenance_casts: detects an as cast from a pointer to an integer. It is better to use expose_provenance instead to make explicit what happens.

I am not sure if having two lints here is really justified, IMO they could be merged into one -- not sure what that one should be called, though. Other than that, this seems like a useful lint to ensure the codebase follows strict provenance (or opts-out explicitly, via the methods mentioned above).

This tracks one lint, implicit_provenance_casts, which forbids as casts from integers to pointers and vice/versa.

I am also not sure if this shouldn't maybe be a clippy lint instead of a rustc lint?

Open questions:

  • What replacement should be auto-suggested? Currently the lint suggests to replace as usize by .addr() which seems dangerous as it will introduce UB if the integer is cast back to a pointer.

Cc @rust-lang/opsem

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's description of the implicit_provenance_casts lint and its relationship to strict provenance. Resolve whether this belongs in rustc or Clippy and what safe replacement should be suggested instead of .addr(); done means those design questions and the lint scope have been settled.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.