Skip to content

Conversation

@justanotheranonymoususer
Copy link
Contributor

Per my understanding, needed for mut access next line.

@rustbot rustbot added 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 Jan 5, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
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

@scottmcm
Copy link
Member

scottmcm commented Jan 9, 2026

Punting on pin,
@rustbot reroll

@rustbot rustbot assigned joboet and unassigned scottmcm Jan 9, 2026
@joboet
Copy link
Member

joboet commented Jan 9, 2026

Sure, though this isn't intended to compile anyway...
@bors r+ rollup

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 9, 2026

📌 Commit 39b08b6 has been approved by joboet

It is now in the queue for this repository.

@justanotheranonymoususer
Copy link
Contributor Author

this isn't intended to compile anyway...

Only because get_pin_mut doesn't exist. It compiles without that line.

Also, I figured the argument to exploit_ref_cell should be mut.

This compiles:

use std::cell::RefCell;
use std::pin::Pin;

trait RefCellPinExt<'a, T> {
    fn get_pin_mut(self) -> Pin<&'a mut T>;
}

impl<'a, T> RefCellPinExt<'a, T> for Pin<&'a mut RefCell<T>> {
    fn get_pin_mut(self) -> Pin<&'a mut T> {
        // SAFETY: That's actually unsafe. Don't do this in real code!
        unsafe { self.map_unchecked_mut(|rc| rc.get_mut()) }
    }
}

fn exploit_ref_cell<T>(mut rc: Pin<&mut RefCell<T>>) {
    // Here we get pinned access to the `T`.
    let _: Pin<&mut T> = rc.as_mut().get_pin_mut();

    // And here we have `&mut T` to the same data.
    let shared: &RefCell<T> = rc.into_ref().get_ref();
    let mut borrow = shared.borrow_mut();
    let content = &mut *borrow;
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=e54a0a6082785b63359650b128f15071

Maybe we better replace it with this version? It's longer, but the compiler can check that it compiles. It's incorrect and unsafe, but having it compile makes sure the example is not bogus.

@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 9, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 9, 2026

⚠️ A new commit 2a68b2ec8a6735435fe91af086b0f32042540151 was pushed to the branch, the PR will need to be re-approved.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 9, 2026
@justanotheranonymoususer
Copy link
Contributor Author

Updated to code that compiles, LMK WDYT

@rust-log-analyzer

This comment has been minimized.

@justanotheranonymoususer
Copy link
Contributor Author

@joboet ping

@joboet
Copy link
Member

joboet commented Jan 22, 2026

Updated to code that compiles, LMK WDYT

I don't think that's a good idea. The example not compiling makes it even clearer that this is unsound. Could you please revert to the previous version?

@joboet _pin_g

😄. Sorry, I filter my review queue by S-waiting-on-review, so your PR didn't appear. You can use @rustbot ready to change the label.

@justanotheranonymoususer
Copy link
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 Jan 22, 2026
@joboet
Copy link
Member

joboet commented Jan 22, 2026

Thanks! Just one thing before I approve this again: Could you squash the commits into one, please?

@justanotheranonymoususer
Copy link
Contributor Author

Not via github, I'm afraid. Can you use squash merge? Or is it an absolute requirement for me to clone the repo?

Per my understanding, needed for mut access next line.
@joboet
Copy link
Member

joboet commented Jan 22, 2026

We use a custom merge bot that isn't able to do squash merges unfortunately. I've performed the squash for you.

@justanotheranonymoususer
Copy link
Contributor Author

@rustbot ready

@joboet
Copy link
Member

joboet commented Jan 25, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 25, 2026

📌 Commit 672828e has been approved by joboet

It is now in the queue for this repository.

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

Add missing mut to pin.rs docs

Per my understanding, needed for mut access next line.
rust-bors bot pushed a commit that referenced this pull request Jan 26, 2026
Rollup of 4 pull requests

Successful merges:

 - #150353 (refactor rustc-hash integration)
 - #151611 (Improve is_ascii performance on x86_64 with explicit SSE2 intrinsics)
 - #150705 (Add missing mut to pin.rs docs)
 - #151639 (Fix broken WASIp1 reference link)
rust-bors bot pushed a commit that referenced this pull request Jan 26, 2026
Rollup of 6 pull requests

Successful merges:

 - #151611 (Improve is_ascii performance on x86_64 with explicit SSE2 intrinsics)
 - #150705 (Add missing mut to pin.rs docs)
 - #151294 (compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]`)
 - #151589 (Add a `documentation` remapping path scope for rustdoc usage)
 - #151639 (Fix broken WASIp1 reference link)
 - #151645 (Update `sysinfo` version to `0.38.0`)
@rust-bors rust-bors bot merged commit ef849a2 into rust-lang:main Jan 26, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 26, 2026
rust-timer added a commit that referenced this pull request Jan 26, 2026
Rollup merge of #150705 - justanotheranonymoususer:patch-1, r=joboet

Add missing mut to pin.rs docs

Per my understanding, needed for mut access next line.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jan 26, 2026
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#151611 (Improve is_ascii performance on x86_64 with explicit SSE2 intrinsics)
 - rust-lang/rust#150705 (Add missing mut to pin.rs docs)
 - rust-lang/rust#151294 (compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]`)
 - rust-lang/rust#151589 (Add a `documentation` remapping path scope for rustdoc usage)
 - rust-lang/rust#151639 (Fix broken WASIp1 reference link)
 - rust-lang/rust#151645 (Update `sysinfo` version to `0.38.0`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants