{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26848","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26848/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26848/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26848/events","html_url":"https://github.com/rust-lang/rust/pull/26848","id":93506035,"number":26848,"title":"allow constant evaluation of function calls","user":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"milestone":null,"comments":11,"created_at":"2015-07-07T11:12:30Z","updated_at":"2015-07-27T23:22:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/26848","html_url":"https://github.com/rust-lang/rust/pull/26848","diff_url":"https://github.com/rust-lang/rust/pull/26848.diff","patch_url":"https://github.com/rust-lang/rust/pull/26848.patch"},"body":"this has the funky side-effect of also allowing constant evaluation of function calls to functions that are not `const fn` as long as `check_const` didn't mark that function `NOT_CONST`\r\n\r\nIt's still not possible to call a normal function from a `const fn`, but let statements' initialization value can get const evaluated (this caused the fallout in the overflowing tests)\r\n\r\nwe can now do this:\r\n\r\n```rust\r\nconst fn add(x: usize, y: usize) -> usize { x + y }\r\nconst ARR: [i32; add(1, 2)] = [5, 6, 7];\r\n```\r\n\r\nalso added a test for destructuring in const fn args\r\n```rust\r\nconst fn i((a, b): (u32, u32)) -> u32 { a + b } //~ ERROR: E0022\r\n```\r\n\r\nThis is a **[breaking change]**, since it turns some runtime panics into compile-time errors. This statement is true for ANY improvement to the const evaluator."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/125377171","html_url":"https://github.com/rust-lang/rust/pull/26848#issuecomment-125377171","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/26848","id":125377171,"user":{"login":"eefriedman","id":12769964,"avatar_url":"https://avatars.githubusercontent.com/u/12769964?v=3","gravatar_id":"","url":"https://api.github.com/users/eefriedman","html_url":"https://github.com/eefriedman","followers_url":"https://api.github.com/users/eefriedman/followers","following_url":"https://api.github.com/users/eefriedman/following{/other_user}","gists_url":"https://api.github.com/users/eefriedman/gists{/gist_id}","starred_url":"https://api.github.com/users/eefriedman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eefriedman/subscriptions","organizations_url":"https://api.github.com/users/eefriedman/orgs","repos_url":"https://api.github.com/users/eefriedman/repos","events_url":"https://api.github.com/users/eefriedman/events{/privacy}","received_events_url":"https://api.github.com/users/eefriedman/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T23:22:26Z","updated_at":"2015-07-27T23:22:26Z","body":"Looking over this more carefully, I'm pretty sure this approach is going to exacerbate the existing problems with overflow in constant evaluation in type-checking.  You simply can't correctly evaluate a const fn correctly in general without knowing the declared argument and result types.  For example:\r\n```rust\r\nconst fn bmax() -> u8 { !0 }\r\nconst fn smax() -> u16 { !0 }\r\nlet c: [u8; bmax() as usize] = [0; 255];\r\nlet c: [u8; smax() as usize] = [0; 65535];\r\n```"}}