about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_infer/infer/error_reporting/mod.rs11
-rw-r--r--src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs15
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs4
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr43
-rw-r--r--src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr7
-rw-r--r--src/test/ui/underscore-lifetime/dyn-trait-underscore.rs2
-rw-r--r--src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr31
7 files changed, 37 insertions, 76 deletions
diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs
index 3b98d47778f..a7b40d39215 100644
--- a/src/librustc_infer/infer/error_reporting/mod.rs
+++ b/src/librustc_infer/infer/error_reporting/mod.rs
@@ -1917,14 +1917,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
             "...",
         );
 
+        debug!("report_sub_sup_conflict: var_origin={:?}", var_origin);
+        debug!("report_sub_sup_conflict: sub_region={:?}", sub_region);
+        debug!("report_sub_sup_conflict: sub_origin={:?}", sub_origin);
+        debug!("report_sub_sup_conflict: sup_region={:?}", sup_region);
+        debug!("report_sub_sup_conflict: sup_origin={:?}", sup_origin);
+
         if let (&infer::Subtype(ref sup_trace), &infer::Subtype(ref sub_trace)) =
             (&sup_origin, &sub_origin)
         {
-            debug!("report_sub_sup_conflict: var_origin={:?}", var_origin);
-            debug!("report_sub_sup_conflict: sub_region={:?}", sub_region);
-            debug!("report_sub_sup_conflict: sub_origin={:?}", sub_origin);
-            debug!("report_sub_sup_conflict: sup_region={:?}", sup_region);
-            debug!("report_sub_sup_conflict: sup_origin={:?}", sup_origin);
             debug!("report_sub_sup_conflict: sup_trace={:?}", sup_trace);
             debug!("report_sub_sup_conflict: sub_trace={:?}", sub_trace);
             debug!("report_sub_sup_conflict: sup_trace.values={:?}", sup_trace.values);
diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index b85a4cae2e4..9da24138eeb 100644
--- a/src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -74,13 +74,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
         }
 
         if let Some((_, fndecl)) = self.find_anon_type(anon, &br) {
-            if self.is_return_type_anon(scope_def_id, br, fndecl).is_some()
-                || self.is_self_anon(is_first, scope_def_id)
-            {
+            let return_type_anon = self.is_return_type_anon(scope_def_id, br, fndecl);
+            let is_self_anon = self.is_self_anon(is_first, scope_def_id);
+            debug!(
+                "try_report_named_anon_conflict: fndecl {:?} {:?} {}",
+                fndecl, return_type_anon, is_self_anon
+            );
+            if is_self_anon {
+                // We used to check for `return_type_anon.is_some()` here. Removing that improves
+                // some diagnostics, but we might have to readd the check if there are regressions
+                // in the wild.
                 return None;
             }
             if let FnRetTy::Return(ty) = &fndecl.output {
+                debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
                 if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.kind, sub) {
+                    debug!("try_report_named_anon_conflict: impl Trait + 'static");
                     // This is an impl Trait return that evaluates de need of 'static.
                     // We handle this case better in `static_impl_trait`.
                     return None;
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs
index b5f6fdeaa4e..589d04c9b19 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs
@@ -55,12 +55,12 @@ where
 }
 
 // After applying suggestion for `qux`:
-// FIXME: we should suggest be suggesting to change `dest` to `&'a mut T`.
 fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
+//~^ ERROR explicit lifetime required in the type of `dest`
 where
     G: Get<T>
 {
-    move || { //~ ERROR cannot infer an appropriate lifetime
+    move || {
         *dest = g.get();
     }
 }
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
index d69db90f3ba..0326616337d 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -87,44 +87,13 @@ help: consider introducing an explicit lifetime bound to unify the type paramete
 LL | fn qux<'b, 'a, G: 'b + 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'b
    |        ^^^     ^^^^^^^                                                  ^^^^
 
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
-  --> $DIR/missing-lifetimes-in-signature.rs:63:5
-   |
-LL | /     move || {
-LL | |         *dest = g.get();
-LL | |     }
-   | |_____^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 59:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:59:1
-   |
-LL | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
-LL | | where
-LL | |     G: Get<T>
-LL | | {
-...  |
-LL | |     }
-LL | | }
-   | |_^
-note: ...so that the types are compatible
-  --> $DIR/missing-lifetimes-in-signature.rs:63:5
-   |
-LL | /     move || {
-LL | |         *dest = g.get();
-LL | |     }
-   | |_____^
-   = note: expected  `&mut T`
-              found  `&mut T`
-note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 59:8...
-  --> $DIR/missing-lifetimes-in-signature.rs:59:8
-   |
-LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
-   |        ^^
-note: ...so that return value is valid for the call
-  --> $DIR/missing-lifetimes-in-signature.rs:59:45
+error[E0621]: explicit lifetime required in the type of `dest`
+  --> $DIR/missing-lifetimes-in-signature.rs:58:45
    |
 LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
-   |                                             ^^^^^^^^^^^^^^^^^^^^^^^
+   |                                  ------     ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+   |                                  |
+   |                                  help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T`
 
 error[E0309]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:69:44
@@ -142,5 +111,5 @@ LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a
 
 error: aborting due to 6 previous errors
 
-Some errors have detailed explanations: E0261, E0309, E0495.
+Some errors have detailed explanations: E0261, E0309, E0621.
 For more information about an error, try `rustc --explain E0261`.
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr
index 8ed48bda26e..a1f6c5386ae 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr
@@ -1,11 +1,12 @@
-error: lifetime may not live long enough
+error[E0621]: explicit lifetime required in the type of `items`
   --> $DIR/dyn-trait-underscore.rs:8:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
-   |                - let's call the lifetime of this reference `'1`
+   |                ---- help: add explicit lifetime `'static` to the type of `items`: `&'static [T]`
 LL |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
 LL |     Box::new(items.iter())
-   |     ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
+   |     ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0621`.
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs
index d5aa18eb0f4..cd4781b8640 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs
@@ -5,7 +5,7 @@
 
 fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
-    Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
+    Box::new(items.iter()) //~ ERROR explicit lifetime required in the type of `items`
 }
 
 fn b<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
index e3c9d50dfe5..a1f6c5386ae 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
@@ -1,31 +1,12 @@
-error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
-  --> $DIR/dyn-trait-underscore.rs:8:20
-   |
-LL |     Box::new(items.iter())
-   |                    ^^^^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 6:1...
-  --> $DIR/dyn-trait-underscore.rs:6:1
-   |
-LL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
-LL | |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
-LL | |     Box::new(items.iter())
-LL | | }
-   | |_^
-note: ...so that reference does not outlive borrowed content
-  --> $DIR/dyn-trait-underscore.rs:8:14
-   |
-LL |     Box::new(items.iter())
-   |              ^^^^^
-   = note: but, the lifetime must be valid for the static lifetime...
-note: ...so that the expression is assignable
+error[E0621]: explicit lifetime required in the type of `items`
   --> $DIR/dyn-trait-underscore.rs:8:5
    |
+LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
+   |                ---- help: add explicit lifetime `'static` to the type of `items`: `&'static [T]`
+LL |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
 LL |     Box::new(items.iter())
-   |     ^^^^^^^^^^^^^^^^^^^^^^
-   = note: expected `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
-              found `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
+   |     ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
+For more information about this error, try `rustc --explain E0621`.