{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/41255","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/41255/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/41255/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/41255/events","html_url":"https://github.com/rust-lang/rust/issues/41255","id":221348673,"number":41255,"title":"Matching on floating-point literal values is totally allowed and shouldn't be","user":{"login":"carols10cents","id":193874,"avatar_url":"https://avatars1.githubusercontent.com/u/193874?v=3","gravatar_id":"","url":"https://api.github.com/users/carols10cents","html_url":"https://github.com/carols10cents","followers_url":"https://api.github.com/users/carols10cents/followers","following_url":"https://api.github.com/users/carols10cents/following{/other_user}","gists_url":"https://api.github.com/users/carols10cents/gists{/gist_id}","starred_url":"https://api.github.com/users/carols10cents/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carols10cents/subscriptions","organizations_url":"https://api.github.com/users/carols10cents/orgs","repos_url":"https://api.github.com/users/carols10cents/repos","events_url":"https://api.github.com/users/carols10cents/events{/privacy}","received_events_url":"https://api.github.com/users/carols10cents/received_events","type":"User","site_admin":false},"labels":[{"id":203429200,"url":"https://api.github.com/repos/rust-lang/rust/labels/P-high","name":"P-high","color":"eb6420","default":false},{"id":211668100,"url":"https://api.github.com/repos/rust-lang/rust/labels/T-compiler","name":"T-compiler","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars3.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},"assignees":[{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars3.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":9,"created_at":"2017-04-12T18:21:55Z","updated_at":"2017-04-20T19:00:28Z","closed_at":null,"body":"Per [this comment](https://github.com/rust-lang/rust/issues/36890#issuecomment-293296201) on the tracking issue for disallowing the use of constants set to floating point numbers (which errors as expected today), @nikomatsakis says the intention was to disallow floating point literal values in matches, but uh... [this is totally accepted by Rust 1.16.0](http://play.integer32.com/?gist=bcea5207d14e8329db1155425af61cbf&version=undefined):\r\n\r\n```\r\nfn main() {\r\n    let x = 13.4;\r\n\r\n    match x {\r\n        1.0 => println!(\"one\"),\r\n        22.4 => println!(\"two\"),\r\n        3.67 => println!(\"three\"),\r\n        13.4 => println!(\"thirteen point four\"),\r\n        _ => println!(\"anything\"),\r\n    }\r\n}\r\n```\r\n\r\nThis prints \"thirteen point four\". I expected to get a compiler error like the one I get if I [change a floating point value in the match to a constant](http://play.integer32.com/?gist=5cc8597493c209ce0c765e56c8027835&version=undefined):\r\n\r\n```\r\nconst FOO: f64 = 3.67;\r\n\r\nfn main() {\r\n    let x = 13.4;\r\n\r\n    match x {\r\n        1.0 => println!(\"one\"),\r\n        22.4 => println!(\"two\"),\r\n        FOO => println!(\"three\"),\r\n        13.4 => println!(\"thirteen point four\"),\r\n        _ => println!(\"anything\"),\r\n    }\r\n}\r\n```\r\n\r\nresults in:\r\n\r\n```\r\nerror: floating point constants cannot be used in patterns, #[deny(illegal_floating_point_constant_pattern)] on by default\r\n --> src/main.rs:9:9\r\n  |\r\n9 |         FOO => println!(\"three\"),\r\n  |         ^^^\r\n  |\r\n  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!\r\n  = note: for more information, see issue #36890 <https://github.com/rust-lang/rust/issues/36890>\r\n```"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/295859507","html_url":"https://github.com/rust-lang/rust/issues/41255#issuecomment-295859507","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/41255","id":295859507,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars3.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2017-04-20T19:00:28Z","updated_at":"2017-04-20T19:00:28Z","body":"@aidanhs we'd also have to settle what NaN ought to do (would it ever be a match?). My inclination would be to make floating point matches align with what `==` does in every respect (it seems very surprising to make the precise bit-pattern significant here)."}}
{"actor":{"display_login":"nikomatsakis"}}