Skip to content

AtomicPtr doesn't implement std::fmt::Pointer #29212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
apasel422 opened this issue Oct 21, 2015 · 3 comments
Closed

AtomicPtr doesn't implement std::fmt::Pointer #29212

apasel422 opened this issue Oct 21, 2015 · 3 comments
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@apasel422
Copy link
Contributor

It can use a technique analogous to its Debug impl to do so.

@nagisa
Copy link
Member

nagisa commented Oct 21, 2015

If we impl fmt::Pointer for AtomicPtr, we should also consider implementing Display for AtomicBool, AtomicIsize and AtomicUsize. I think not implementing these traits just yet is conscious.

@steveklabnik
Copy link
Member

Triage: no change. here's a test case

use std::sync::atomic::AtomicPtr;

fn main() {
    let ptr = &mut 5;
    let some_ptr  = AtomicPtr::new(ptr);
    
    println!("{:p}", some_ptr);
}

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 24, 2017
@dtolnay dtolnay added C-feature-accepted Category: A feature request that has been accepted pending implementation. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 17, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 17, 2017

I would be fine with adding these impls. The impls should access the atomic using the most restrictive memory ordering. Then if you want any other ordering there is a totally reasonable workaround:

println!("{:p}", some_ptr.load(Ordering::Relaxed));

varkor added a commit to varkor/rust that referenced this issue Dec 10, 2017
bors added a commit that referenced this issue Dec 12, 2017
Add `std::fmt::Pointer` implementation for `AtomicPtr`

Resolves #29212.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants