rust-lang / rust-lang/rust-clippy

Should `cast_{un,}signed()` be considered an `as` cast for linting purposes?

Open
#14,975 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

S-needs-discussion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

cast_signed() and cast_unsigned() are stable since 1.87.

They produce the same result as an as cast, but they ensure that the bit-width remains the same.

Should lints like cast_possible_wrap, cast_abs_to_unsigned and cast_sign_loss consider the new cast_{un,}signed() as as casts too?

Should this be configurable?

Related: https://github.com/rust-lang/rust-clippy/issues/14974.

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

The issue names no files, tests, or entry points. Start by reviewing the related rust-lang/rust-clippy issue 14974 and the existing behavior of cast_possible_wrap, cast_abs_to_unsigned, and cast_sign_loss; the work is complete only after the treatment of cast_signed() and cast_unsigned(), including configurability, is decided and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.