{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/29093","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/29093/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/29093/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/29093/events","html_url":"https://github.com/rust-lang/rust/issues/29093","id":111769334,"number":29093,"title":"Global const expr with macro causes compiler panic","user":{"login":"leeopop","id":3205589,"avatar_url":"https://avatars.githubusercontent.com/u/3205589?v=3","gravatar_id":"","url":"https://api.github.com/users/leeopop","html_url":"https://github.com/leeopop","followers_url":"https://api.github.com/users/leeopop/followers","following_url":"https://api.github.com/users/leeopop/following{/other_user}","gists_url":"https://api.github.com/users/leeopop/gists{/gist_id}","starred_url":"https://api.github.com/users/leeopop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeopop/subscriptions","organizations_url":"https://api.github.com/users/leeopop/orgs","repos_url":"https://api.github.com/users/leeopop/repos","events_url":"https://api.github.com/users/leeopop/events{/privacy}","received_events_url":"https://api.github.com/users/leeopop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-16T06:23:23Z","updated_at":"2015-10-16T10:32:54Z","closed_at":null,"body":"I would like to have compile-time evaluation of my const values\r\nfrom the environment variables.\r\nI wonder whether I had some grammar mistakes, however the compiler panics.\r\nThis occurs all stable, beta, and nightly versions (from play.rust-lang.org).\r\n\r\nI tried this code:\r\n```\r\nconst DEFAULT_PACKET_BUFFER_SIZE : usize = 2048;\r\n\r\npub const PACKET_BUFFER_SIZE : usize = match option_env!(\"PACKET_BUFFER_SIZE\") {\r\n    None => DEFAULT_PACKET_BUFFER_SIZE,\r\n    Some(num_str) => {\r\n        match num_str.parse::<usize>() {\r\n            Ok(num) => {\r\n                match num.is_power_of_two() {\r\n                    true => num,\r\n                    _ => DEFAULT_PACKET_BUFFER_SIZE,\r\n                }\r\n                },\r\n            _ => { DEFAULT_PACKET_BUFFER_SIZE },\r\n        }\r\n    }\r\n};\r\n\r\nfn main()\r\n{\r\n    println!(\"{}\",DEFAULT_PACKET_BUFFER_SIZE);\r\n}\r\n```\r\n\r\n\r\nI expected to see this happen: \r\ncompiles with environment variables, statically evaluated.\r\n\r\nInstead, this happened:\r\ncompiler panic.\r\n\r\n## Meta\r\n\r\n```\r\nPS C:\\workspace\\git\\FPS\\src> cargo build --verbose\r\n       Fresh winapi v0.2.4\r\n       Fresh rustc-serialize v0.3.16\r\n       Fresh libc v0.1.10\r\n       Fresh winapi-build v0.1.1\r\n       Fresh advapi32-sys v0.1.2\r\n       Fresh rand v0.3.11\r\n       Fresh num v0.1.27\r\n   Compiling FPS v0.0.0 (file:///C:/workspace/git/FPS)\r\n     Running `rustc lib.rs --crate-name fps --crate-type lib -g --out-dir C:\\workspace\\git\\FPS\\target\\debug --emit=dep-i\r\nnfo,link -L dependency=C:\\workspace\\git\\FPS\\target\\debug -L dependency=C:\\workspace\\git\\FPS\\target\\debug\\deps --extern i\r\nlog2=C:\\workspace\\git\\FPS\\target\\debug\\deps\\libilog2-d6c9b6aa20d924f8.rlib`\r\n       Fresh ilog2 v0.2.2\r\nN\\env.rs:5:10: 5:17 error: internal compiler error: no enclosing scope found for scope: Misc(13)\r\nN\\env.rs:5     Some(num_str) => {\r\n                    ^~~~~~~\r\nnote: the compiler unexpectedly panicked. this is a bug.\r\nnote: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports\r\nnote: run with `RUST_BACKTRACE=1` for a backtrace\r\nthread 'rustc' panicked at 'Box<Any>', ../src/libsyntax\\diagnostic.rs:176\r\n\r\n\r\nCould not compile `FPS`.\r\n\r\nCaused by:\r\n  Process didn't exit successfully: `rustc lib.rs --crate-name fps --crate-type lib -g --out-dir C:\\workspace\\git\\FPS\\ta\r\nrget\\debug --emit=dep-info,link -L dependency=C:\\workspace\\git\\FPS\\target\\debug -L dependency=C:\\workspace\\git\\FPS\\targe\r\nt\\debug\\deps --extern ilog2=C:\\workspace\\git\\FPS\\target\\debug\\deps\\libilog2-d6c9b6aa20d924f8.rlib` (exit code: 101)\r\nPS C:\\workspace\\git\\FPS\\src>\r\n```\r\n\r\n```\r\nPS C:\\workspace\\git\\FPS\\src> rustc --version --verbose\r\nrustc 1.3.0 (9a92aaf19 2015-09-15)\r\nbinary: rustc\r\ncommit-hash: 9a92aaf19a64603b02b4130fe52958cc12488900\r\ncommit-date: 2015-09-15\r\nhost: x86_64-pc-windows-gnu\r\nrelease: 1.3.0\r\n```\r\n\r\nhttp://puu.sh/kM1Yo/036518bf32.png"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/148678706","html_url":"https://github.com/rust-lang/rust/issues/29093#issuecomment-148678706","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/29093","id":148678706,"user":{"login":"leeopop","id":3205589,"avatar_url":"https://avatars.githubusercontent.com/u/3205589?v=3","gravatar_id":"","url":"https://api.github.com/users/leeopop","html_url":"https://github.com/leeopop","followers_url":"https://api.github.com/users/leeopop/followers","following_url":"https://api.github.com/users/leeopop/following{/other_user}","gists_url":"https://api.github.com/users/leeopop/gists{/gist_id}","starred_url":"https://api.github.com/users/leeopop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeopop/subscriptions","organizations_url":"https://api.github.com/users/leeopop/orgs","repos_url":"https://api.github.com/users/leeopop/repos","events_url":"https://api.github.com/users/leeopop/events{/privacy}","received_events_url":"https://api.github.com/users/leeopop/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T10:32:54Z","updated_at":"2015-10-16T10:32:54Z","body":"@cristicbz Thank you for your helpful comment :)\r\n"}}