]> git.lizzy.rs Git - rust.git/commitdiff
Point at return type obligations instead of at `fn` ident
authorEsteban Küber <esteban@kuber.com.ar>
Wed, 29 Jan 2020 22:16:31 +0000 (14:16 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 2 Feb 2020 19:52:34 +0000 (11:52 -0800)
src/librustc_typeck/check/wfcheck.rs
src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr

index 214e7d066eabc9714f656edd7ce528adb0061f49..3a4a015c14a5005323fa63cd9f887ed6aaa46ddd 100644 (file)
@@ -530,7 +530,7 @@ fn check_where_clauses<'tcx, 'fcx>(
     fcx: &FnCtxt<'fcx, 'tcx>,
     span: Span,
     def_id: DefId,
-    return_ty: Option<Ty<'tcx>>,
+    return_ty: Option<(Ty<'tcx>, Span)>,
 ) {
     debug!("check_where_clauses(def_id={:?}, return_ty={:?})", def_id, return_ty);
 
@@ -664,7 +664,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
 
     let mut predicates = predicates.instantiate_identity(fcx.tcx);
 
-    if let Some(return_ty) = return_ty {
+    if let Some((return_ty, span)) = return_ty {
         predicates.predicates.extend(check_opaque_types(tcx, fcx, def_id, span, return_ty));
     }
 
@@ -708,7 +708,7 @@ fn check_fn_or_method<'fcx, 'tcx>(
     // FIXME(#25759) return types should not be implied bounds
     implied_bounds.push(sig.output());
 
-    check_where_clauses(tcx, fcx, span, def_id, Some(sig.output()));
+    check_where_clauses(tcx, fcx, span, def_id, Some((sig.output(), hir_sig.decl.output.span())));
 }
 
 /// Checks "defining uses" of opaque `impl Trait` types to ensure that they meet the restrictions
index 8cc6f7c3037871f7670528090e0445c24f10beff..08b26b8fc1307de927f4d60bccb3e2675ce23791 100644 (file)
@@ -1,8 +1,8 @@
 error: non-defining opaque type use in defining scope
-  --> $DIR/generic_duplicate_lifetime_param.rs:7:4
+  --> $DIR/generic_duplicate_lifetime_param.rs:7:26
    |
 LL | fn one<'a>(t: &'a ()) -> Two<'a, 'a> {
-   |    ^^^
+   |                          ^^^^^^^^^^^
    |
 note: lifetime used multiple times
   --> $DIR/generic_duplicate_lifetime_param.rs:5:10