{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/36554","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/36554/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/36554/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/36554/events","html_url":"https://github.com/rust-lang/rust/issues/36554","id":177610638,"number":36554,"title":"error 282: If we have no info about the actual type param, say something about the formal type param","user":{"login":"nrc","id":762626,"avatar_url":"https://avatars.githubusercontent.com/u/762626?v=3","gravatar_id":"","url":"https://api.github.com/users/nrc","html_url":"https://github.com/nrc","followers_url":"https://api.github.com/users/nrc/followers","following_url":"https://api.github.com/users/nrc/following{/other_user}","gists_url":"https://api.github.com/users/nrc/gists{/gist_id}","starred_url":"https://api.github.com/users/nrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrc/subscriptions","organizations_url":"https://api.github.com/users/nrc/orgs","repos_url":"https://api.github.com/users/nrc/repos","events_url":"https://api.github.com/users/nrc/events{/privacy}","received_events_url":"https://api.github.com/users/nrc/received_events","type":"User","site_admin":false},"labels":[{"id":235791,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102","default":false},{"id":37544,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102","default":false},{"id":67766349,"url":"https://api.github.com/repos/rust-lang/rust/labels/E-mentor","name":"E-mentor","color":"02E10C","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-17T21:34:41Z","updated_at":"2016-11-04T14:04:55Z","closed_at":null,"body":"e.g.,\n\n```\nunable to infer enough type information about `_`\n```\n\nand inline:\n\n```\ncannot infer type for `_`\n```\n\nThis is when calling a function with a generic type parameter. The actual type parameter is inferred, so we can't name it, but there is a corresponding formal parameter we could name.\n\nE.g., if calling `foo<T>(...)` we have `foo(...)` and so get a type error for `_`, but we could mention `T` here, something like\n\n```\ncannot infer type for `_`, the inferred type corresponding to `T` in this call to `foo`\n```\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/258439752","html_url":"https://github.com/rust-lang/rust/issues/36554#issuecomment-258439752","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/36554","id":258439752,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.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":"2016-11-04T14:04:55Z","updated_at":"2016-11-04T14:04:55Z","body":"**Step 2.** Augment the \"unable to infer enough type information about `{}`\" message.\r\n\r\n- This message is emitted [here](https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L783-L790); the `self` in this case is an `InferCtxt`, which is perfect.\r\n- You would want to check whether the variable `ty` corresponds to just a type variable.\r\n- Probably a good idea to be defensive and start with `let ty = self.resolve_type_vars_if_possible(&ty);` (I am intentionally just shadowing the old `ty`); this will get the most up-to-date inference information.\r\n- Something like `match ty.sty { ty::TyInfer(ty::InferTy(ty_vid)) => ... /* new code */, _ => /* existing code */ }`\r\n- In the new code case, we now have a `ty_vid` (of type `TyVid`):\r\n    - We can use the `var_origin()` helper we added to learn about it's origin\r\n        - something like `self.type_variables.borrow().var_origin(ty_vid)`\r\n    - We can then print a message like:\r\n\r\n```\r\nself.sess.span_err(var_origin.span, \"cannot infer value for type parameter `{}`\", var_origin.name)\r\n        .emit()\r\n```\r\n\r\nNote that we only have the name of the variable available, not the name of the method or fn where the variable was declared. As I said, we can refactor to support that later -- it's a relatively small delta on this other plumbing."}}
{"actor":{"display_login":"nikomatsakis"}}