Skip to content

Add undocumented_as_casts lint#16682

Open
charlieHsiuC wants to merge 2 commits intorust-lang:masterfrom
charlieHsiuC:master
Open

Add undocumented_as_casts lint#16682
charlieHsiuC wants to merge 2 commits intorust-lang:masterfrom
charlieHsiuC:master

Conversation

@charlieHsiuC
Copy link

@charlieHsiuC charlieHsiuC commented Mar 7, 2026

Checks for as casts that do not have a preceding // CAST: comment.

fixes #15963

changelog: new lint: [undocumented_as_casts]

@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Mar 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2026

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Lintcheck changes for 27a4bdd

Lint Added Removed Changed
clippy::undocumented_as_casts 8649 0 0

This comment will be updated if you push new changes

Copy link
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review.

Also, please add tests where parts of the cast expression come from a declarative macro. For example, a cast!(expr, type) which expands to (expr) as type, or a copy!(expr as type).

View changes since this review

/// ```
#[clippy::version = "1.96.0"]
pub UNDOCUMENTED_AS_CASTS,
nursery,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the lint has no known bug, please use restriction instead of nursery.

Comment on lines +43 to +44
#[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use span_lint_and_help() instead?

}
}

/// Checks if there is a `// CAST:` or `/* CAST:` comment preceding the cast expression.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to share the logic with the "SAFETY" logic? It looks like a lot of duplicated functionalities.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Mar 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@samueltardieu samueltardieu added the lint-nominated Create an FCP-thread on Zulip for this PR label Mar 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2026

This lint has been nominated for inclusion.

A FCP topic has been created on Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lint-nominated Create an FCP-thread on Zulip for this PR needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

// CAST: ... comment on as casts

3 participants