Skip to content

Simplify pointer usage in Buffer::format method#67

Merged
dtolnay merged 1 commit intodtolnay:masterfrom
xtqqczze:as_mut_ptr
Feb 2, 2026
Merged

Simplify pointer usage in Buffer::format method#67
dtolnay merged 1 commit intodtolnay:masterfrom
xtqqczze:as_mut_ptr

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Feb 2, 2026

No description provided.

Copy link
Copy Markdown
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay dtolnay merged commit e693c49 into dtolnay:master Feb 2, 2026
11 checks passed
@xtqqczze xtqqczze deleted the as_mut_ptr branch February 2, 2026 19:15
@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Feb 2, 2026

Perhaps this could have been expressed more naturally as a reference transmute:

mem::transmute::<&mut Buffer, &mut <I as private::Sealed>::Buffer>(self)

@dtolnay
Copy link
Copy Markdown
Owner

dtolnay commented Feb 2, 2026

Reference transmutes are discouraged by clippy.

warning: transmute from a reference to a reference
   --> src/lib.rs:108:13
    |
108 |             mem::transmute::<&mut Buffer, &mut <I as private::Sealed>::Buffer>(self)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(self as *mut Buffer as *mut <I as private::Sealed>::Buffer)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Feb 2, 2026

transmute_ptr_to_ptr is a pedantic lint, see:

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Feb 2, 2026

Reference transmutes are discouraged by clippy.

We are basically doing a reference transmute here, just via a raw pointer. If this is somehow unsound, the code should be refactored.

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