Skip to content

Remove pointer "as" casts#1403

Merged
BenFordTytherington merged 1 commit intoKDAB:mainfrom
jnbooth:remove-pointer-as-casts
Feb 24, 2026
Merged

Remove pointer "as" casts#1403
BenFordTytherington merged 1 commit intoKDAB:mainfrom
jnbooth:remove-pointer-as-casts

Conversation

@jnbooth
Copy link
Contributor

@jnbooth jnbooth commented Jan 28, 2026

Instead of using as * pointer conversions, it's recommended to use pointer::cast and pointer::cast_mut. This approach is safer because pointer::cast won't accidentally cast from immutable to mutable or vice versa (see #1402), and pointer::cast_mut only casts between mutable and immutable, so it won't accidentally cast to the wrong type (see #1401). This PR refactors the remaining pointer conversions that were not addressed by #1401 or #1402. Once all three are merged, the ptr_as_ptr and ptr_cast_constness lints can be enabled. Alternatively, #1401 and #1402 can be merged, and then those lints can be added to this PR.

@jnbooth jnbooth changed the title Remove poiner "as" casts Remove pointer "as" casts Jan 28, 2026
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (55106f0) to head (e5f02ce).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           75        75           
  Lines        13124     13124           
=========================================
  Hits         13124     13124           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@BenFordTytherington BenFordTytherington left a comment

Choose a reason for hiding this comment

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

Looks like a good refactor to me, makes the code a little easier to read

@BenFordTytherington BenFordTytherington added this pull request to the merge queue Feb 24, 2026
Merged via the queue into KDAB:main with commit e010614 Feb 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants