about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-02-27 02:34:22 +0100
committerGitHub <noreply@github.com>2021-02-27 02:34:22 +0100
commitf0c98b15cc82ac711432e038166fb2a8c5f32f10 (patch)
tree24958c7630b16fb498596522e9b4003c4210a975
parentcabe97272d782294e0d642135f3d8b13579b2929 (diff)
parent75d1e303af04758c26e1aee63f2f0afd53dfd6f8 (diff)
downloadrust-f0c98b15cc82ac711432e038166fb2a8c5f32f10.tar.gz
rust-f0c98b15cc82ac711432e038166fb2a8c5f32f10.zip
Rollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank
Improve anonymous lifetime note to indicate the target span

Improvement for  #81650
Cc #81995

Message after this improvement:
(Improve note in the middle)

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40...
  --> src/main.rs:24:40
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |                                        ^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```

r? ``````@estebank``````
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs10
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs5
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs114
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs2
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs3
-rw-r--r--src/test/ui/issues/issue-16683.stderr6
-rw-r--r--src/test/ui/issues/issue-17740.stderr12
-rw-r--r--src/test/ui/issues/issue-17758.stderr6
-rw-r--r--src/test/ui/issues/issue-17905-2.stderr12
-rw-r--r--src/test/ui/issues/issue-20831-debruijn.stderr6
-rw-r--r--src/test/ui/issues/issue-27942.stderr12
-rw-r--r--src/test/ui/nll/issue-52742.stderr6
-rw-r--r--src/test/ui/nll/issue-55394.stderr6
-rw-r--r--src/test/ui/nll/type-alias-free-regions.stderr12
-rw-r--r--src/test/ui/regions/regions-infer-paramd-indirect.stderr6
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr6
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr6
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr41
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr30
-rw-r--r--src/test/ui/ufcs/ufcs-explicit-self-bad.stderr24
20 files changed, 158 insertions, 167 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 2d5f43e5890..eeff48a6395 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -50,6 +50,7 @@ use super::region_constraints::GenericKind;
 use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs};
 
 use crate::infer;
+use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
 use crate::traits::error_reporting::report_object_safety_error;
 use crate::traits::{
     IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
@@ -179,7 +180,14 @@ fn msg_span_from_early_bound_and_free_regions(
         }
         ty::ReFree(ref fr) => match fr.bound_region {
             ty::BrAnon(idx) => {
-                (format!("the anonymous lifetime #{} defined on", idx + 1), tcx.hir().span(node))
+                if let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region) {
+                    ("the anonymous lifetime defined on".to_string(), ty.span)
+                } else {
+                    (
+                        format!("the anonymous lifetime #{} defined on", idx + 1),
+                        tcx.hir().span(node),
+                    )
+                }
             }
             _ => (
                 format!("the lifetime `{}` as defined on", region),
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
index cdd68d83f22..1b35c4032f4 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
@@ -1,6 +1,7 @@
 //! Error Reporting for Anonymous Region Lifetime Errors
 //! where both the regions are anonymous.
 
+use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
 use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
 use crate::infer::error_reporting::nice_region_error::NiceRegionError;
 use crate::infer::lexical_region_resolve::RegionResolutionError;
@@ -66,9 +67,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
         let scope_def_id_sub = anon_reg_sub.def_id;
         let bregion_sub = anon_reg_sub.boundregion;
 
-        let ty_sup = self.find_anon_type(sup, &bregion_sup)?;
+        let ty_sup = find_anon_type(self.tcx(), sup, &bregion_sup)?;
 
-        let ty_sub = self.find_anon_type(sub, &bregion_sub)?;
+        let ty_sub = find_anon_type(self.tcx(), sub, &bregion_sub)?;
 
         debug!(
             "try_report_anon_anon_conflict: found_param1={:?} sup={:?} br1={:?}",
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs
index b014b9832e7..ffdaedf8666 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs
@@ -1,4 +1,3 @@
-use crate::infer::error_reporting::nice_region_error::NiceRegionError;
 use rustc_hir as hir;
 use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
 use rustc_hir::Node;
@@ -6,67 +5,64 @@ use rustc_middle::hir::map::Map;
 use rustc_middle::middle::resolve_lifetime as rl;
 use rustc_middle::ty::{self, Region, TyCtxt};
 
-impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
-    /// This function calls the `visit_ty` method for the parameters
-    /// corresponding to the anonymous regions. The `nested_visitor.found_type`
-    /// contains the anonymous type.
-    ///
-    /// # Arguments
-    /// region - the anonymous region corresponding to the anon_anon conflict
-    /// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
-    ///
-    /// # Example
-    /// ```
-    /// fn foo(x: &mut Vec<&u8>, y: &u8)
-    ///    { x.push(y); }
-    /// ```
-    /// The function returns the nested type corresponding to the anonymous region
-    /// for e.g., `&u8` and Vec<`&u8`.
-    pub(super) fn find_anon_type(
-        &self,
-        region: Region<'tcx>,
-        br: &ty::BoundRegionKind,
-    ) -> Option<(&hir::Ty<'tcx>, &hir::FnDecl<'tcx>)> {
-        if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
-            let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
-            let fndecl = match self.tcx().hir().get(hir_id) {
-                Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
-                | Node::TraitItem(&hir::TraitItem {
-                    kind: hir::TraitItemKind::Fn(ref m, ..),
-                    ..
-                })
-                | Node::ImplItem(&hir::ImplItem {
-                    kind: hir::ImplItemKind::Fn(ref m, ..), ..
-                }) => &m.decl,
-                _ => return None,
-            };
+/// This function calls the `visit_ty` method for the parameters
+/// corresponding to the anonymous regions. The `nested_visitor.found_type`
+/// contains the anonymous type.
+///
+/// # Arguments
+/// region - the anonymous region corresponding to the anon_anon conflict
+/// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
+///
+/// # Example
+/// ```
+/// fn foo(x: &mut Vec<&u8>, y: &u8)
+///    { x.push(y); }
+/// ```
+/// The function returns the nested type corresponding to the anonymous region
+/// for e.g., `&u8` and Vec<`&u8`.
+pub(crate) fn find_anon_type(
+    tcx: TyCtxt<'tcx>,
+    region: Region<'tcx>,
+    br: &ty::BoundRegionKind,
+) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnDecl<'tcx>)> {
+    if let Some(anon_reg) = tcx.is_suitable_region(region) {
+        let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
+        let fndecl = match tcx.hir().get(hir_id) {
+            Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
+            | Node::TraitItem(&hir::TraitItem {
+                kind: hir::TraitItemKind::Fn(ref m, ..), ..
+            })
+            | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(ref m, ..), .. }) => {
+                &m.decl
+            }
+            _ => return None,
+        };
 
-            fndecl
-                .inputs
-                .iter()
-                .find_map(|arg| self.find_component_for_bound_region(arg, br))
-                .map(|ty| (ty, &**fndecl))
-        } else {
-            None
-        }
+        fndecl
+            .inputs
+            .iter()
+            .find_map(|arg| find_component_for_bound_region(tcx, arg, br))
+            .map(|ty| (ty, &**fndecl))
+    } else {
+        None
     }
+}
 
-    // This method creates a FindNestedTypeVisitor which returns the type corresponding
-    // to the anonymous region.
-    fn find_component_for_bound_region(
-        &self,
-        arg: &'tcx hir::Ty<'tcx>,
-        br: &ty::BoundRegionKind,
-    ) -> Option<&'tcx hir::Ty<'tcx>> {
-        let mut nested_visitor = FindNestedTypeVisitor {
-            tcx: self.tcx(),
-            bound_region: *br,
-            found_type: None,
-            current_index: ty::INNERMOST,
-        };
-        nested_visitor.visit_ty(arg);
-        nested_visitor.found_type
-    }
+// This method creates a FindNestedTypeVisitor which returns the type corresponding
+// to the anonymous region.
+fn find_component_for_bound_region(
+    tcx: TyCtxt<'tcx>,
+    arg: &'tcx hir::Ty<'tcx>,
+    br: &ty::BoundRegionKind,
+) -> Option<&'tcx hir::Ty<'tcx>> {
+    let mut nested_visitor = FindNestedTypeVisitor {
+        tcx,
+        bound_region: *br,
+        found_type: None,
+        current_index: ty::INNERMOST,
+    };
+    nested_visitor.visit_ty(arg);
+    nested_visitor.found_type
 }
 
 // The FindNestedTypeVisitor captures the corresponding `hir::Ty` of the
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs
index 0599c78ebfd..e20436690b3 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs
@@ -6,7 +6,7 @@ use rustc_middle::ty::{self, TyCtxt};
 use rustc_span::source_map::Span;
 
 mod different_lifetimes;
-mod find_anon_type;
+pub mod find_anon_type;
 mod named_anon_conflict;
 mod placeholder_error;
 mod static_impl_trait;
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index 2f622231a08..2f3c0d6957a 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -1,5 +1,6 @@
 //! Error Reporting for Anonymous Region Lifetime Errors
 //! where one region is named and the other is anonymous.
+use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
 use crate::infer::error_reporting::nice_region_error::NiceRegionError;
 use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
 use rustc_hir::intravisit::Visitor;
@@ -74,7 +75,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
             return None;
         }
 
-        if let Some((_, fndecl)) = self.find_anon_type(anon, &br) {
+        if let Some((_, fndecl)) = find_anon_type(self.tcx(), anon, &br) {
             if self.is_self_anon(is_first, scope_def_id) {
                 return None;
             }
diff --git a/src/test/ui/issues/issue-16683.stderr b/src/test/ui/issues/issue-16683.stderr
index 6efc12df8fa..35bcf286c44 100644
--- a/src/test/ui/issues/issue-16683.stderr
+++ b/src/test/ui/issues/issue-16683.stderr
@@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflictin
 LL |         self.a();
    |              ^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 3:5...
-  --> $DIR/issue-16683.rs:3:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 3:10...
+  --> $DIR/issue-16683.rs:3:10
    |
 LL |     fn b(&self) {
-   |     ^^^^^^^^^^^
+   |          ^^^^^
 note: ...so that reference does not outlive borrowed content
   --> $DIR/issue-16683.rs:4:9
    |
diff --git a/src/test/ui/issues/issue-17740.stderr b/src/test/ui/issues/issue-17740.stderr
index 9fe80232a14..995f5f1fc3d 100644
--- a/src/test/ui/issues/issue-17740.stderr
+++ b/src/test/ui/issues/issue-17740.stderr
@@ -6,11 +6,11 @@ LL |     fn bar(self: &mut Foo) {
    |
    = note: expected struct `Foo<'a>`
               found struct `Foo<'_>`
-note: the anonymous lifetime #2 defined on the method body at 6:5...
-  --> $DIR/issue-17740.rs:6:5
+note: the anonymous lifetime defined on the method body at 6:23...
+  --> $DIR/issue-17740.rs:6:23
    |
 LL |     fn bar(self: &mut Foo) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |                       ^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 5:7
   --> $DIR/issue-17740.rs:5:7
    |
@@ -30,11 +30,11 @@ note: the lifetime `'a` as defined on the impl at 5:7...
    |
 LL | impl <'a> Foo<'a>{
    |       ^^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 6:5
-  --> $DIR/issue-17740.rs:6:5
+note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 6:23
+  --> $DIR/issue-17740.rs:6:23
    |
 LL |     fn bar(self: &mut Foo) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |                       ^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-17758.stderr b/src/test/ui/issues/issue-17758.stderr
index f82e0f53a23..846e8939b53 100644
--- a/src/test/ui/issues/issue-17758.stderr
+++ b/src/test/ui/issues/issue-17758.stderr
@@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflictin
 LL |         self.foo();
    |              ^^^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 6:5...
-  --> $DIR/issue-17758.rs:6:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 6:12...
+  --> $DIR/issue-17758.rs:6:12
    |
 LL |     fn bar(&self) {
-   |     ^^^^^^^^^^^^^
+   |            ^^^^^
 note: ...so that reference does not outlive borrowed content
   --> $DIR/issue-17758.rs:7:9
    |
diff --git a/src/test/ui/issues/issue-17905-2.stderr b/src/test/ui/issues/issue-17905-2.stderr
index c762a4ab496..3c27f705859 100644
--- a/src/test/ui/issues/issue-17905-2.stderr
+++ b/src/test/ui/issues/issue-17905-2.stderr
@@ -6,11 +6,11 @@ LL |     fn say(self: &Pair<&str, isize>) {
    |
    = note: expected struct `Pair<&str, _>`
               found struct `Pair<&str, _>`
-note: the anonymous lifetime #2 defined on the method body at 8:5...
-  --> $DIR/issue-17905-2.rs:8:5
+note: the anonymous lifetime defined on the method body at 8:24...
+  --> $DIR/issue-17905-2.rs:8:24
    |
 LL |     fn say(self: &Pair<&str, isize>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                        ^^^^
 note: ...does not necessarily outlive the lifetime `'_` as defined on the impl at 5:5
   --> $DIR/issue-17905-2.rs:5:5
    |
@@ -30,11 +30,11 @@ note: the lifetime `'_` as defined on the impl at 5:5...
    |
 LL |     &str,
    |     ^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 8:5
-  --> $DIR/issue-17905-2.rs:8:5
+note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 8:24
+  --> $DIR/issue-17905-2.rs:8:24
    |
 LL |     fn say(self: &Pair<&str, isize>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                        ^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr
index bcfb6b70b2e..e68482d1caf 100644
--- a/src/test/ui/issues/issue-20831-debruijn.stderr
+++ b/src/test/ui/issues/issue-20831-debruijn.stderr
@@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
 LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5...
-  --> $DIR/issue-20831-debruijn.rs:28:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 28:58...
+  --> $DIR/issue-20831-debruijn.rs:28:58
    |
 LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...but the lifetime must also be valid for the lifetime `'a` as defined on the impl at 26:6...
   --> $DIR/issue-20831-debruijn.rs:26:6
    |
diff --git a/src/test/ui/issues/issue-27942.stderr b/src/test/ui/issues/issue-27942.stderr
index 6ce0fa37a88..80eecb42d1c 100644
--- a/src/test/ui/issues/issue-27942.stderr
+++ b/src/test/ui/issues/issue-27942.stderr
@@ -6,11 +6,11 @@ LL |     fn select(&self) -> BufferViewHandle<R>;
    |
    = note: expected type `Resources<'_>`
               found type `Resources<'a>`
-note: the anonymous lifetime #1 defined on the method body at 5:5...
-  --> $DIR/issue-27942.rs:5:5
+note: the anonymous lifetime defined on the method body at 5:15...
+  --> $DIR/issue-27942.rs:5:15
    |
 LL |     fn select(&self) -> BufferViewHandle<R>;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |               ^^^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the trait at 3:18
   --> $DIR/issue-27942.rs:3:18
    |
@@ -30,11 +30,11 @@ note: the lifetime `'a` as defined on the trait at 3:18...
    |
 LL | pub trait Buffer<'a, R: Resources<'a>> {
    |                  ^^
-note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 5:5
-  --> $DIR/issue-27942.rs:5:5
+note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 5:15
+  --> $DIR/issue-27942.rs:5:15
    |
 LL |     fn select(&self) -> BufferViewHandle<R>;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |               ^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/nll/issue-52742.stderr b/src/test/ui/nll/issue-52742.stderr
index 7631ca61e5e..23bb12f9420 100644
--- a/src/test/ui/nll/issue-52742.stderr
+++ b/src/test/ui/nll/issue-52742.stderr
@@ -9,11 +9,11 @@ note: ...the reference is valid for the lifetime `'_` as defined on the impl at
    |
 LL | impl Foo<'_, '_> {
    |          ^^
-note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 13:5
-  --> $DIR/issue-52742.rs:13:5
+note: ...but the borrowed content is only valid for the anonymous lifetime defined on the method body at 13:31
+  --> $DIR/issue-52742.rs:13:31
    |
 LL |     fn take_bar(&mut self, b: Bar<'_>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                               ^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/nll/issue-55394.stderr b/src/test/ui/nll/issue-55394.stderr
index e24ef176db0..36721f923f7 100644
--- a/src/test/ui/nll/issue-55394.stderr
+++ b/src/test/ui/nll/issue-55394.stderr
@@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'s` d
 LL |         Foo { bar }
    |         ^^^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 8:5...
-  --> $DIR/issue-55394.rs:8:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 8:17...
+  --> $DIR/issue-55394.rs:8:17
    |
 LL |     fn new(bar: &mut Bar) -> Self {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                 ^^^^^^^^
 note: ...so that reference does not outlive borrowed content
   --> $DIR/issue-55394.rs:9:15
    |
diff --git a/src/test/ui/nll/type-alias-free-regions.stderr b/src/test/ui/nll/type-alias-free-regions.stderr
index 38e3e05d1cb..6498ecfbe6f 100644
--- a/src/test/ui/nll/type-alias-free-regions.stderr
+++ b/src/test/ui/nll/type-alias-free-regions.stderr
@@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
 LL |         C { f: b }
    |         ^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 16:5...
-  --> $DIR/type-alias-free-regions.rs:16:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 16:24...
+  --> $DIR/type-alias-free-regions.rs:16:24
    |
 LL |     fn from_box(b: Box<B>) -> Self {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                        ^
 note: ...so that the expression is assignable
   --> $DIR/type-alias-free-regions.rs:17:16
    |
@@ -35,11 +35,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen
 LL |         C { f: Box::new(b.0) }
    |                ^^^^^^^^^^^^^
    |
-note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 26:5...
-  --> $DIR/type-alias-free-regions.rs:26:5
+note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 26:23...
+  --> $DIR/type-alias-free-regions.rs:26:23
    |
 LL |     fn from_tuple(b: (B,)) -> Self {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                       ^
 note: ...so that the expression is assignable
   --> $DIR/type-alias-free-regions.rs:27:25
    |
diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.stderr
index 620b25c9e05..95eb4d1f75b 100644
--- a/src/test/ui/regions/regions-infer-paramd-indirect.stderr
+++ b/src/test/ui/regions/regions-infer-paramd-indirect.stderr
@@ -6,11 +6,11 @@ LL |         self.f = b;
    |
    = note: expected struct `Box<Box<&'a isize>>`
               found struct `Box<Box<&isize>>`
-note: the anonymous lifetime #2 defined on the method body at 21:5...
-  --> $DIR/regions-infer-paramd-indirect.rs:21:5
+note: the anonymous lifetime defined on the method body at 21:36...
+  --> $DIR/regions-infer-paramd-indirect.rs:21:36
    |
 LL |     fn set_f_bad(&mut self, b: Box<B>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                    ^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 16:6
   --> $DIR/regions-infer-paramd-indirect.rs:16:6
    |
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr
index b359826cb4a..7e07a5775bb 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr
@@ -7,11 +7,11 @@ LL | |         t.test();
 LL | |     });
    | |______^
    |
-note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
-  --> $DIR/missing-lifetimes-in-signature-2.rs:19:1
+note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
+  --> $DIR/missing-lifetimes-in-signature-2.rs:19:24
    |
 LL | fn func<T: Test>(foo: &Foo, t: T) {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                        ^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
index c7def9b668d..4e7d5297840 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
@@ -6,11 +6,11 @@ LL | fn func<T: Test>(foo: &Foo, t: T) {
 LL |     foo.bar(move |_| {
    |         ^^^
    |
-note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 19:1...
-  --> $DIR/missing-lifetimes-in-signature-2.rs:19:1
+note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 19:24...
+  --> $DIR/missing-lifetimes-in-signature-2.rs:19:24
    |
 LL | fn func<T: Test>(foo: &Foo, t: T) {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                        ^^^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature-2.rs:20:9
    |
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr
index 1bfcdab5d86..b509610b89e 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr
@@ -25,14 +25,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
    |                                     ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:25:1
-   |
-LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
-LL | |
-LL | | where
-LL | |     G: Get<T>
-   | |_____________^
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
+  --> $DIR/missing-lifetimes-in-signature.rs:25:26
+   |
+LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+   |                          ^^^^^^
 
 error[E0311]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:47:45
@@ -40,14 +37,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
    |                                             ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:47:1
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
+  --> $DIR/missing-lifetimes-in-signature.rs:47:34
    |
-LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
-LL | |
-LL | | where
-LL | |     G: Get<T>
-   | |_____________^
+LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+   |                                  ^^^^^^
 
 error[E0311]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:59:58
@@ -55,11 +49,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL |     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
    |                                                          ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
-  --> $DIR/missing-lifetimes-in-signature.rs:59:5
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
+  --> $DIR/missing-lifetimes-in-signature.rs:59:47
    |
 LL |     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                               ^^^^^^
 
 error[E0311]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:68:45
@@ -67,14 +61,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 68:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:68:1
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 68:34...
+  --> $DIR/missing-lifetimes-in-signature.rs:68:34
    |
-LL | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
-LL | |
-LL | | where
-LL | |     G: Get<T>
-   | |_____________^
+LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
+   |                                  ^^^^^^
 
 error[E0621]: explicit lifetime required in the type of `dest`
   --> $DIR/missing-lifetimes-in-signature.rs:73:5
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 69e95efa72d..789fff7acc2 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -33,14 +33,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
    |                                     ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 25:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:25:1
-   |
-LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
-LL | |
-LL | | where
-LL | |     G: Get<T>
-   | |_____________^
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 25:26...
+  --> $DIR/missing-lifetimes-in-signature.rs:25:26
+   |
+LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+   |                          ^^^^^^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:30:5: 32:6]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:25:37
    |
@@ -57,14 +54,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
    |                                             ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the function body at 47:1...
-  --> $DIR/missing-lifetimes-in-signature.rs:47:1
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the function body at 47:34...
+  --> $DIR/missing-lifetimes-in-signature.rs:47:34
    |
-LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
-LL | |
-LL | | where
-LL | |     G: Get<T>
-   | |_____________^
+LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
+   |                                  ^^^^^^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:52:5: 54:6]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:47:45
    |
@@ -81,11 +75,11 @@ error[E0311]: the parameter type `G` may not live long enough
 LL |     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
    |                                                          ^^^^^^^^^^^^^^^^^^
    |
-note: the parameter type `G` must be valid for the anonymous lifetime #1 defined on the method body at 59:5...
-  --> $DIR/missing-lifetimes-in-signature.rs:59:5
+note: the parameter type `G` must be valid for the anonymous lifetime defined on the method body at 59:47...
+  --> $DIR/missing-lifetimes-in-signature.rs:59:47
    |
 LL |     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                               ^^^^^^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:61:9: 63:10]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:59:58
    |
diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
index d7c48173571..133ecab2296 100644
--- a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
+++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
@@ -33,11 +33,11 @@ LL |     fn dummy2(self: &Bar<T>) {}
    |
    = note: expected reference `&'a Bar<T>`
               found reference `&Bar<T>`
-note: the anonymous lifetime #1 defined on the method body at 37:5...
-  --> $DIR/ufcs-explicit-self-bad.rs:37:5
+note: the anonymous lifetime defined on the method body at 37:21...
+  --> $DIR/ufcs-explicit-self-bad.rs:37:21
    |
 LL |     fn dummy2(self: &Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                     ^^^^^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 35:6
   --> $DIR/ufcs-explicit-self-bad.rs:35:6
    |
@@ -57,11 +57,11 @@ note: the lifetime `'a` as defined on the impl at 35:6...
    |
 LL | impl<'a, T> SomeTrait for &'a Bar<T> {
    |      ^^
-note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 37:5
-  --> $DIR/ufcs-explicit-self-bad.rs:37:5
+note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 37:21
+  --> $DIR/ufcs-explicit-self-bad.rs:37:21
    |
 LL |     fn dummy2(self: &Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                     ^^^^^^^
 
 error[E0308]: mismatched `self` parameter type
   --> $DIR/ufcs-explicit-self-bad.rs:39:21
@@ -71,11 +71,11 @@ LL |     fn dummy3(self: &&Bar<T>) {}
    |
    = note: expected reference `&'a Bar<T>`
               found reference `&Bar<T>`
-note: the anonymous lifetime #2 defined on the method body at 39:5...
-  --> $DIR/ufcs-explicit-self-bad.rs:39:5
+note: the anonymous lifetime defined on the method body at 39:22...
+  --> $DIR/ufcs-explicit-self-bad.rs:39:22
    |
 LL |     fn dummy3(self: &&Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                      ^^^^^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 35:6
   --> $DIR/ufcs-explicit-self-bad.rs:35:6
    |
@@ -95,11 +95,11 @@ note: the lifetime `'a` as defined on the impl at 35:6...
    |
 LL | impl<'a, T> SomeTrait for &'a Bar<T> {
    |      ^^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 39:5
-  --> $DIR/ufcs-explicit-self-bad.rs:39:5
+note: ...does not necessarily outlive the anonymous lifetime defined on the method body at 39:22
+  --> $DIR/ufcs-explicit-self-bad.rs:39:22
    |
 LL |     fn dummy3(self: &&Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                      ^^^^^^^
 
 error: aborting due to 7 previous errors