-
Couldn't load subscription status.
- Fork 13.9k
Closed
Closed
Copy link
Labels
C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Consider this example:
#![feature(shared, unique)]
use std::ptr::{Shared, Unique};
use std::rc::Rc;
use std::sync::Arc;
fn main() {
let x = Box::new(10);
assert_eq!(format!("{:p}", &*x), format!("{:p}", x));
let a = &mut 10 as *mut _;
let x = Shared::new(a).unwrap();
assert_eq!(format!("{:p}", a), format!("{:p}", x));
let a = &mut 10 as *mut _;
let x = Unique::new(a).unwrap();
assert_eq!(format!("{:p}", a), format!("{:p}", x));
let x = Rc::new(10);
println!("rc {:p} {:p}", &*x, x);
let x = Arc::new(10);
println!("arc {:p} {:p}", &*x, x);
}the code runs fine but the printed values are different:
rc 0x7f1eefa1e070 0x7f1eefa1e060
arc 0x7f1eefa1e0d0 0x7f1eefa1e0c0
The Pointer implementation for Rc and Arc prints the address of the inner data (RcBox and ArcInner) instead of the address of the stored value. This seems to be inconsistent with the Pointer implementation for Box, Shared and Unique.
If this is a real issue, I can write a patch to fix it.
Metadata
Metadata
Assignees
Labels
C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.