close
Skip to content

library: use strict provenance lints consistently#156832

Open
hanna-kruppe wants to merge 2 commits into
rust-lang:mainfrom
hanna-kruppe:consistent-strict-provenance-lints
Open

library: use strict provenance lints consistently#156832
hanna-kruppe wants to merge 2 commits into
rust-lang:mainfrom
hanna-kruppe:consistent-strict-provenance-lints

Conversation

@hanna-kruppe
Copy link
Copy Markdown
Contributor

@hanna-kruppe hanna-kruppe commented May 22, 2026

The fuzzy_provenance_casts lint is enabled in most of the standard library, but its identical twin lossy_provenance_casts was not. As discussed in the tracking issue for those lints, there doesn't seem to be any good reason to enable one without the other. This PR applies this principle and as a result removes some unnecessary ptr->int as casts.

It's also preparation for merging the two lints, which removes the option of only enabling fuzzy_provenance_casts.

Tracking issue: #130351

@rustbot rustbot added O-SGX Target: SGX S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 22, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 22, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates

@rustbot

This comment has been minimized.

@hanna-kruppe hanna-kruppe force-pushed the consistent-strict-provenance-lints branch from 49b7330 to ce7d549 Compare May 22, 2026 13:40
@rust-log-analyzer

This comment has been minimized.

@hanna-kruppe hanna-kruppe marked this pull request as draft May 22, 2026 14:45
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2026
@rust-log-analyzer

This comment has been minimized.

@hanna-kruppe hanna-kruppe force-pushed the consistent-strict-provenance-lints branch from ba63f5d to 2509ca0 Compare May 23, 2026 14:00
@hanna-kruppe hanna-kruppe marked this pull request as ready for review May 23, 2026 14:00
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 23, 2026
@hanna-kruppe
Copy link
Copy Markdown
Contributor Author

hanna-kruppe commented May 23, 2026

The CI failure is due to a clippy lint using rustc_hir_typeck to test if an as cast would be possible, and rustc emitting the strict provenance lints during this check. I created rust-lang/rust-clippy#17063 for that, it's not solely a problem of the strict provenance lints. The specific expressions that trigger the bug in the CI job are these two pointer->int transmutes:

The "invalid span" warnings seems to caused by a mix of that clippy issue (check_cast uses DUMMY_SPAN because diagnostics are not expected) and the span manipulation in the lints. I created #156850 for another issue with the span manipulation that I discovered while debugging, but I think that one's unrelated (I haven't been able to provoke an invalid span without the clippy issue in the mix).

I didn't find an easy workaround for the clippy bug that I'd be comfortable including in this PR. So I'll try moving the strict provenance lints out of the HIR typechecking path and convert them to normal late lints (edit: opened #156862 for this). So this PR should be ready for review in theory, but can't pass CI until I've either done that or someone finds another fix for rust-lang/rust-clippy#17063

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2026
@rust-log-analyzer

This comment has been minimized.

@hanna-kruppe hanna-kruppe force-pushed the consistent-strict-provenance-lints branch from 2509ca0 to 02378db Compare May 25, 2026 17:28
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 25, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

The `fuzzy_provenance_casts` lint is enabled in most of the standard
library, but its identical twin `lossy_provenance_casts` was not. As
discussed in the tracking issue for those lints, there doesn't seem to
be any good reason to enable one without the other. This PR applies this
principle and as a result removes some unnecessary ptr->int `as` casts.

It's also preparation for merging the two lints, which removes the
option of only enabling `fuzzy_provenance_casts`.
@hanna-kruppe hanna-kruppe force-pushed the consistent-strict-provenance-lints branch from 02378db to fed6279 Compare May 25, 2026 18:45
@hanna-kruppe
Copy link
Copy Markdown
Contributor Author

hanna-kruppe commented May 25, 2026

#156862 was merged and fixed the previous CI failure as expected. Another job failed after rebase but that was spurious (actions runner died midway), so: @rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels May 25, 2026
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented May 30, 2026

r? jhpratt

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

📌 Commit fed6279 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 30, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 30, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request May 30, 2026
…venance-lints, r=jhpratt

library: use strict provenance lints consistently

The `fuzzy_provenance_casts` lint is enabled in most of the standard library, but its identical twin `lossy_provenance_casts` was not. As discussed in the tracking issue for those lints, there doesn't seem to be any good reason to enable one without the other. This PR applies this principle and as a result removes some unnecessary ptr->int `as` casts.

It's also preparation for merging the two lints, which removes the option of only enabling `fuzzy_provenance_casts`.

Tracking issue: rust-lang#130351
rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
Rollup of 6 pull requests

Successful merges:

 - #156832 (library: use strict provenance lints consistently)
 - #157006 (net tests: let the OS pick the port numbers)
 - #157126 (Avoid redundant note when a #[derive] is already suggested)
 - #151690 (std: Refactor `env::var` function)
 - #155826 (std::process: uefi: avoid panicking in Stdio From impls.)
 - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

⌛ Testing commit fed6279 with merge 6402f0d...

Workflow: https://github.com/rust-lang/rust/actions/runs/26694683369

rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
…ts, r=jhpratt

library: use strict provenance lints consistently

The `fuzzy_provenance_casts` lint is enabled in most of the standard library, but its identical twin `lossy_provenance_casts` was not. As discussed in the tracking issue for those lints, there doesn't seem to be any good reason to enable one without the other. This PR applies this principle and as a result removes some unnecessary ptr->int `as` casts.

It's also preparation for merging the two lints, which removes the option of only enabling `fuzzy_provenance_casts`.

Tracking issue: #130351
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

JonathanBrouwer commented May 30, 2026

💔 This PR failed tests as part of a rollup
After fixing the problem, consider running a try job for the failed job before re-approving
@bors r-

Link to failure:
#157167 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

This pull request was unapproved.

This PR was contained in a rollup (#157167), which was unapproved.

Auto build was cancelled due to unapproval. Cancelled workflows:

View changes since this unapproval

@rustbot rustbot added the O-unix Operating system: Unix-like label May 31, 2026
@hanna-kruppe
Copy link
Copy Markdown
Contributor Author

Added a commit that should fix that failure. @bors ready

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 31, 2026

Unknown command "ready". Run @bors help to see available commands.

@hanna-kruppe
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-SGX Target: SGX O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants