{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/53039","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/53039/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/53039/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/53039/events","html_url":"https://github.com/rust-lang/rust/issues/53039","id":347537384,"node_id":"MDU6SXNzdWUzNDc1MzczODQ=","number":53039,"title":"Document interaction between `std::alloc` and `Box::{into_raw, from_raw}`","user":{"login":"FenrirWolf","id":8870156,"node_id":"MDQ6VXNlcjg4NzAxNTY=","avatar_url":"https://avatars0.githubusercontent.com/u/8870156?v=4","gravatar_id":"","url":"https://api.github.com/users/FenrirWolf","html_url":"https://github.com/FenrirWolf","followers_url":"https://api.github.com/users/FenrirWolf/followers","following_url":"https://api.github.com/users/FenrirWolf/following{/other_user}","gists_url":"https://api.github.com/users/FenrirWolf/gists{/gist_id}","starred_url":"https://api.github.com/users/FenrirWolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FenrirWolf/subscriptions","organizations_url":"https://api.github.com/users/FenrirWolf/orgs","repos_url":"https://api.github.com/users/FenrirWolf/repos","events_url":"https://api.github.com/users/FenrirWolf/events{/privacy}","received_events_url":"https://api.github.com/users/FenrirWolf/received_events","type":"User","site_admin":false},"labels":[{"id":211668062,"node_id":"MDU6TGFiZWwyMTE2NjgwNjI=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-libs","name":"T-libs","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-08-03T21:11:20Z","updated_at":"2018-08-06T15:46:30Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The [current documentation](https://doc.rust-lang.org/1.28.0/std/boxed/struct.Box.html#method.from_raw) for `Box::from_raw` states that `Box`es can only be made from raw pointers previously derived from `Box::into_raw`, but now that there are stable functions to directly access the allocator, one can imagine writing code like this:\r\n\r\n```\r\nuse std::alloc::{alloc, Layout};\r\nuse std::ptr;\r\n\r\nfn main() {\r\n    let boxed = unsafe {\r\n        let raw = alloc(Layout::from_size_align(4, 4).unwrap()) as *mut i32;\r\n\r\n        ptr::write(raw, 42);\r\n\r\n        Box::from_raw(raw)\r\n    };\r\n\r\n    println!(\"{}\", boxed); // prints `42` with `Box`'s `Display` impl\r\n\r\n    // `boxed` gets dropped here instead of deallocating directly with `std::alloc::dealloc`\r\n}\r\n```\r\n\r\nIs such code sound? Or is `Box`'s allocator still considered unspecified?"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/410754198","html_url":"https://github.com/rust-lang/rust/issues/53039#issuecomment-410754198","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/53039","id":410754198,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDc1NDE5OA==","user":{"login":"alexcrichton","id":64996,"node_id":"MDQ6VXNlcjY0OTk2","avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"created_at":"2018-08-06T15:46:30Z","updated_at":"2018-08-06T15:46:30Z","author_association":"MEMBER","body":"I suspect that this is defacto true today in the sense that it's \"as if\" we've documented this anyway, likely with unsafe code relying on it. That, plus what @SimonSapin was mentioning, I think we should go ahead and document this."}}
{"actor":{"display_login":"alexcrichton"}}