From: Mazdak Farrokhzad Date: Fri, 20 Dec 2019 11:17:23 +0000 (+0100) Subject: Rollup merge of #67285 - ohadravid:indicate-origin-of-where-type-parameter, r=estebank X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=403bb097fce6f1d1fbb3b7b12d024f20ce845900;hp=-c;p=rust.git Rollup merge of #67285 - ohadravid:indicate-origin-of-where-type-parameter, r=estebank Indicate origin of where type parameter for uninferred types Based on #65951 (which is not merge yet), fixes #67277. This PR improves a little the diagnostic for code like: ``` async fn foo() { bar().await; } async fn bar() -> () {} ``` by showing: ``` error[E0698]: type inside `async fn` body must be known in this context --> unresolved_type_param.rs:9:5 | 9 | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | ... ``` (The ``` declared on the function `bar` ``` part is new) A small side note: `Vec` and `slice` seem to resist this change, because querying `item_name()` panics, and `get_opt_name()` returns `None`. r? @estebank --- 403bb097fce6f1d1fbb3b7b12d024f20ce845900 diff --combined src/librustc/traits/error_reporting.rs index 701c19085be,018bed96664..4839974d625 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@@ -2113,7 -2113,7 +2113,7 @@@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> self.var_map.entry(ty).or_insert_with(|| infcx.next_ty_var( TypeVariableOrigin { - kind: TypeVariableOriginKind::TypeParameterDefinition(name), + kind: TypeVariableOriginKind::TypeParameterDefinition(name, None), span: DUMMY_SP, } ) @@@ -2404,7 -2404,7 +2404,7 @@@ let message = if let Some(name) = last_generator .and_then(|generator_did| self.tcx.parent(generator_did)) .and_then(|parent_did| self.tcx.hir().as_local_hir_id(parent_did)) - .map(|parent_hir_id| self.tcx.hir().name(parent_hir_id)) + .and_then(|parent_hir_id| self.tcx.hir().opt_name(parent_hir_id)) { format!("future returned by `{}` is not {}", name, trait_name) } else {