{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/38305","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/38305/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/38305/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/38305/events","html_url":"https://github.com/rust-lang/rust/issues/38305","id":194851063,"number":38305,"title":"Overloaded call inferred to be through Fn when only FnOnce works","user":{"login":"programble","id":166462,"avatar_url":"https://avatars.githubusercontent.com/u/166462?v=3","gravatar_id":"","url":"https://api.github.com/users/programble","html_url":"https://github.com/programble","followers_url":"https://api.github.com/users/programble/followers","following_url":"https://api.github.com/users/programble/following{/other_user}","gists_url":"https://api.github.com/users/programble/gists{/gist_id}","starred_url":"https://api.github.com/users/programble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/programble/subscriptions","organizations_url":"https://api.github.com/users/programble/orgs","repos_url":"https://api.github.com/users/programble/repos","events_url":"https://api.github.com/users/programble/events{/privacy}","received_events_url":"https://api.github.com/users/programble/received_events","type":"User","site_admin":false},"labels":[{"id":122406831,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-closures","name":"A-closures","color":"d7e102","default":false},{"id":31942528,"url":"https://api.github.com/repos/rust-lang/rust/labels/I-nominated","name":"I-nominated","color":"e10c02","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":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-11T19:37:35Z","updated_at":"2016-12-11T19:42:12Z","closed_at":null,"body":"Repro: https://is.gd/AbO8K4\r\n\r\nA wrapper around a closure `F` implements `FnOnce`, `FnMut` and `Fn` where `F` does. However, when the wrapper is created with a closure which implements only `FnOnce`, and then the wrapper is called, the compiler expects the closure to implement `FnMut` or `Fn`.\r\n\r\n```\r\nrustc 1.15.0-nightly (daf8c1dfc 2016-12-05)\r\nbinary: rustc\r\ncommit-hash: daf8c1dfce3b448fc581cc319f64632ec22bd0e1\r\ncommit-date: 2016-12-05\r\nhost: x86_64-apple-darwin\r\nrelease: 1.15.0-nightly\r\nLLVM version: 3.9\r\n```\r\n\r\ncc @eddyb (discussed on IRC)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/266302574","html_url":"https://github.com/rust-lang/rust/issues/38305#issuecomment-266302574","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/38305","id":266302574,"user":{"login":"eddyb","id":77424,"avatar_url":"https://avatars.githubusercontent.com/u/77424?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"created_at":"2016-12-11T19:42:12Z","updated_at":"2016-12-11T19:42:12Z","body":"cc @nikomatsakis @nagisa Is this one of the closure inference cases where the current algorithm is suboptimal? AFAICT the wrong trait is inferred at the callsite and it's not changed later, or even if it's changed to `FnOnce` there might be some obligation left around.\r\n\r\nError for posterity:\r\n```rust\r\nerror[E0525]: expected a closure that implements the `FnMut` trait, but this closure only implements `FnOnce`\r\n  --> <anon>:31:26\r\n   |\r\n31 |     let f = Wrapper { f: || foo };\r\n   |                          ^^^^^^\r\n   |\r\nnote: the requirement to implement `FnMut` derives from here\r\n  --> <anon>:32:5\r\n   |\r\n32 |     f();\r\n   |     ^^^\r\n```"}}
{"actor":{"display_login":"eddyb"}}