{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/51267","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/51267/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/51267/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/51267/events","html_url":"https://github.com/rust-lang/rust/issues/51267","id":328377200,"node_id":"MDU6SXNzdWUzMjgzNzcyMDA=","number":51267,"title":"count_zeros, count_ones, leading_zeros, trailing_zeros should be const","user":{"login":"glandium","id":1038527,"node_id":"MDQ6VXNlcjEwMzg1Mjc=","avatar_url":"https://avatars3.githubusercontent.com/u/1038527?v=4","gravatar_id":"","url":"https://api.github.com/users/glandium","html_url":"https://github.com/glandium","followers_url":"https://api.github.com/users/glandium/followers","following_url":"https://api.github.com/users/glandium/following{/other_user}","gists_url":"https://api.github.com/users/glandium/gists{/gist_id}","starred_url":"https://api.github.com/users/glandium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glandium/subscriptions","organizations_url":"https://api.github.com/users/glandium/orgs","repos_url":"https://api.github.com/users/glandium/repos","events_url":"https://api.github.com/users/glandium/events{/privacy}","received_events_url":"https://api.github.com/users/glandium/received_events","type":"User","site_admin":false},"labels":[{"id":900795185,"node_id":"MDU6TGFiZWw5MDA3OTUxODU=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-const-eval","name":"A-const-eval","color":"d7e102","default":false},{"id":268744493,"node_id":"MDU6TGFiZWwyNjg3NDQ0OTM=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-const-fn","name":"A-const-fn","color":"d7e102","default":false},{"id":630652267,"node_id":"MDU6TGFiZWw2MzA2NTIyNjc=","url":"https://api.github.com/repos/rust-lang/rust/labels/C-feature-request","name":"C-feature-request","color":"f5f1fd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-01T04:19:20Z","updated_at":"2018-06-01T21:44:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"One thing that I would like to do is to compile-time assert that the log2 of an alignment is less a given size. A simple way to do log2 of a power of 2 is to use `trailing_zeros`. But `trailing_zeros` is not const, so it's not possible to do a compile-time check.\r\n\r\nThe equivalent `__builtin`s in clang are const (example: https://godbolt.org/g/RxWczn) so llvm should be able to handle that.\r\n\r\nHowever, adding `const` to the functions in `core::num` requires adding `const` to the corresponding intrinsics, and that is not supported (`extern items cannot be 'const'`)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/394017438","html_url":"https://github.com/rust-lang/rust/issues/51267#issuecomment-394017438","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/51267","id":394017438,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDAxNzQzOA==","user":{"login":"faern","id":332294,"node_id":"MDQ6VXNlcjMzMjI5NA==","avatar_url":"https://avatars1.githubusercontent.com/u/332294?v=4","gravatar_id":"","url":"https://api.github.com/users/faern","html_url":"https://github.com/faern","followers_url":"https://api.github.com/users/faern/followers","following_url":"https://api.github.com/users/faern/following{/other_user}","gists_url":"https://api.github.com/users/faern/gists{/gist_id}","starred_url":"https://api.github.com/users/faern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faern/subscriptions","organizations_url":"https://api.github.com/users/faern/orgs","repos_url":"https://api.github.com/users/faern/repos","events_url":"https://api.github.com/users/faern/events{/privacy}","received_events_url":"https://api.github.com/users/faern/received_events","type":"User","site_admin":false},"created_at":"2018-06-01T21:44:55Z","updated_at":"2018-06-01T21:44:55Z","author_association":"CONTRIBUTOR","body":"Initially I only planned on making `swap_bytes` and the endianess conversion `const fn`s. But since we also merged making `cttz`, `ctlz` and `ctpop` constant intrinsics this could very well be extended to the integer methods using these intrinsics as well.\r\n\r\nI made the appropriate methods on integers constant and pushed a [feature branch to my fork](https://github.com/faern/rust/tree/const-int-ops), the diff can be viewed at https://github.com/rust-lang/rust/compare/master...faern:const-int-ops?expand=1. Please check if it makes all the methods you need `const fn`s. To try that branch one must first point to a very new nightly rustc for stage0 in `config.toml`.\r\n\r\nI'm going to try to get that feature branch merged into nightly as soon as Rust 1.27 comes out and the stage0 compiler is bumped. But yes, if I understand the way the stage0 compiler is bumped, this can't hit stable before Rust 1.29."}}
{"actor":{"display_login":"faern"}}