about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-08-12 17:02:14 -0400
committerAaron Hill <aa1ronham@gmail.com>2020-08-22 18:41:49 -0400
commite3cd43eb0093a59c4ba98e44c13a8dacc9f4f9b1 (patch)
tree06280830e2fdd857ced4a7b9174a56b06d0a3ef2 /src
parent663d2f5cd3163f17eddb74ee1e028d542255f21a (diff)
downloadrust-e3cd43eb0093a59c4ba98e44c13a8dacc9f4f9b1.tar.gz
rust-e3cd43eb0093a59c4ba98e44c13a8dacc9f4f9b1.zip
Use smaller def span for functions
Currently, the def span of a funtion encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.
* The 'unconditional recursion' lint uses the full span to show
  additional context for the recursive call.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_ast/ast.rs1
-rw-r--r--src/librustc_ast/mut_visit.rs3
-rw-r--r--src/librustc_ast_lowering/item.rs15
-rw-r--r--src/librustc_builtin_macros/deriving/generic/mod.rs1
-rw-r--r--src/librustc_builtin_macros/global_allocator.rs2
-rw-r--r--src/librustc_builtin_macros/test_harness.rs2
-rw-r--r--src/librustc_hir/hir.rs1
-rw-r--r--src/librustc_middle/hir/map/mod.rs29
-rw-r--r--src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs2
-rw-r--r--src/librustc_mir_build/build/mod.rs27
-rw-r--r--src/librustc_mir_build/lints.rs2
-rw-r--r--src/librustc_parse/parser/item.rs18
-rw-r--r--src/librustc_save_analysis/sig.rs2
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/mod.rs19
-rw-r--r--src/librustc_typeck/collect.rs2
-rw-r--r--src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr2
-rw-r--r--src/test/ui/associated-types/bound-lifetime-in-return-only.ok.stderr2
-rw-r--r--src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr2
-rw-r--r--src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr2
-rw-r--r--src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr2
-rw-r--r--src/test/ui/associated-types/higher-ranked-projection.good.stderr7
-rw-r--r--src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-no-fg.stderr20
-rw-r--r--src/test/ui/block-result/issue-20862.stderr15
-rw-r--r--src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr4
-rw-r--r--src/test/ui/codemap_tests/overlapping_inherent_impls.stderr12
-rw-r--r--src/test/ui/coherence/coherence-inherited-subtyping.old.stderr4
-rw-r--r--src/test/ui/coherence/coherence-inherited-subtyping.re.stderr4
-rw-r--r--src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr8
-rw-r--r--src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr4
-rw-r--r--src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr4
-rw-r--r--src/test/ui/duplicate/dupe-symbols-1.stderr6
-rw-r--r--src/test/ui/duplicate/dupe-symbols-2.stderr6
-rw-r--r--src/test/ui/duplicate/dupe-symbols-3.stderr6
-rw-r--r--src/test/ui/duplicate/dupe-symbols-4.stderr2
-rw-r--r--src/test/ui/duplicate/dupe-symbols-5.stderr6
-rw-r--r--src/test/ui/duplicate/dupe-symbols-7.stderr2
-rw-r--r--src/test/ui/duplicate/dupe-symbols-8.stderr9
-rw-r--r--src/test/ui/duplicate_entry_error.stderr7
-rw-r--r--src/test/ui/error-codes/E0445.stderr2
-rw-r--r--src/test/ui/error-codes/E0446.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr10
-rw-r--r--src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr10
-rw-r--r--src/test/ui/hrtb/issue-58451.stderr3
-rw-r--r--src/test/ui/infinite/infinite-instantiation.stderr9
-rw-r--r--src/test/ui/issues/issue-16683.stderr6
-rw-r--r--src/test/ui/issues/issue-17740.stderr20
-rw-r--r--src/test/ui/issues/issue-17758.stderr7
-rw-r--r--src/test/ui/issues/issue-17905-2.stderr16
-rw-r--r--src/test/ui/issues/issue-20831-debruijn.stderr40
-rw-r--r--src/test/ui/issues/issue-22638.stderr8
-rw-r--r--src/test/ui/issues/issue-30079.stderr2
-rw-r--r--src/test/ui/issues/issue-33140.stderr12
-rw-r--r--src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr6
-rw-r--r--src/test/ui/issues/issue-37884.stderr9
-rw-r--r--src/test/ui/issues/issue-67552.stderr6
-rw-r--r--src/test/ui/issues/issue-8727.stderr6
-rw-r--r--src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr2
-rw-r--r--src/test/ui/nll/issue-52742.stderr7
-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/panic-handler/panic-handler-bad-signature-4.stderr7
-rw-r--r--src/test/ui/panic-handler/panic-handler-duplicate.stderr12
-rw-r--r--src/test/ui/panic-handler/panic-handler-std.stderr6
-rw-r--r--src/test/ui/privacy/private-in-public-lint.stderr4
-rw-r--r--src/test/ui/privacy/private-in-public-non-principal.stderr2
-rw-r--r--src/test/ui/privacy/private-in-public-warn.stderr10
-rw-r--r--src/test/ui/privacy/private-in-public.stderr42
-rw-r--r--src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr2
-rw-r--r--src/test/ui/privacy/restricted/private-in-public.stderr4
-rw-r--r--src/test/ui/proc-macro/no-macro-use-attr.stderr2
-rw-r--r--src/test/ui/recursion/recursion.stderr9
-rw-r--r--src/test/ui/regions/regions-infer-paramd-indirect.stderr10
-rw-r--r--src/test/ui/regions/regions-normalize-in-where-clause-list.stderr16
-rw-r--r--src/test/ui/regions/regions-trait-1.stderr6
-rw-r--r--src/test/ui/rfc-2091-track-caller/error-with-main.stderr10
-rw-r--r--src/test/ui/rfc-2091-track-caller/error-with-start.stderr10
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr2
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr2
-rw-r--r--src/test/ui/rfc1445/feature-gate.with_gate.stderr10
-rw-r--r--src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr2
-rw-r--r--src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr2
-rw-r--r--src/test/ui/rustc-error.stderr6
-rw-r--r--src/test/ui/specialization/specialization-overlap-hygiene.stderr4
-rw-r--r--src/test/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr2
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr24
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr19
-rw-r--r--src/test/ui/target-feature/invalid-attribute.stderr4
-rw-r--r--src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr24
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr13
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr13
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr13
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr13
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr13
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr12
-rw-r--r--src/test/ui/ufcs/ufcs-explicit-self-bad.stderr8
107 files changed, 345 insertions, 576 deletions
diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs
index e06881711c4..127a53cad2b 100644
--- a/src/librustc_ast/ast.rs
+++ b/src/librustc_ast/ast.rs
@@ -1671,6 +1671,7 @@ pub struct MutTy {
 pub struct FnSig {
     pub header: FnHeader,
     pub decl: P<FnDecl>,
+    pub span: Span,
 }
 
 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
diff --git a/src/librustc_ast/mut_visit.rs b/src/librustc_ast/mut_visit.rs
index 1e922d3415f..965571aaa54 100644
--- a/src/librustc_ast/mut_visit.rs
+++ b/src/librustc_ast/mut_visit.rs
@@ -363,9 +363,10 @@ pub fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) {
 }
 
 // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
-pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl }: &mut FnSig, vis: &mut T) {
+pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) {
     vis.visit_fn_header(header);
     vis.visit_fn_decl(decl);
+    vis.visit_span(span);
 }
 
 // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs
index 473fb7ccc70..f3309afec7d 100644
--- a/src/librustc_ast_lowering/item.rs
+++ b/src/librustc_ast_lowering/item.rs
@@ -263,7 +263,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
                 let (ty, body_id) = self.lower_const_item(t, span, e.as_deref());
                 hir::ItemKind::Const(ty, body_id)
             }
-            ItemKind::Fn(_, FnSig { ref decl, header }, ref generics, ref body) => {
+            ItemKind::Fn(
+                _,
+                FnSig { ref decl, header, span: fn_sig_span },
+                ref generics,
+                ref body,
+            ) => {
                 let fn_def_id = self.resolver.local_def_id(id);
                 self.with_new_scopes(|this| {
                     this.current_item = Some(ident.span);
@@ -290,7 +295,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
                             )
                         },
                     );
-                    let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
+                    let sig = hir::FnSig {
+                        decl,
+                        header: this.lower_fn_header(header),
+                        span: fn_sig_span,
+                    };
                     hir::ItemKind::Fn(sig, generics, body_id)
                 })
             }
@@ -1243,7 +1252,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
                 )
             },
         );
-        (generics, hir::FnSig { header, decl })
+        (generics, hir::FnSig { header, decl, span: sig.span })
     }
 
     fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs
index accb0b3c949..849e8b136e1 100644
--- a/src/librustc_builtin_macros/deriving/generic/mod.rs
+++ b/src/librustc_builtin_macros/deriving/generic/mod.rs
@@ -924,6 +924,7 @@ impl<'a> MethodDef<'a> {
         let sig = ast::FnSig {
             header: ast::FnHeader { unsafety, ext: ast::Extern::None, ..ast::FnHeader::default() },
             decl: fn_decl,
+            span: trait_.span,
         };
         let def = ast::Defaultness::Final;
 
diff --git a/src/librustc_builtin_macros/global_allocator.rs b/src/librustc_builtin_macros/global_allocator.rs
index c37adb7baa0..8478fcfbf09 100644
--- a/src/librustc_builtin_macros/global_allocator.rs
+++ b/src/librustc_builtin_macros/global_allocator.rs
@@ -67,7 +67,7 @@ impl AllocFnFactory<'_, '_> {
         let (output_ty, output_expr) = self.ret_ty(&method.output, result);
         let decl = self.cx.fn_decl(abi_args, ast::FnRetTy::Ty(output_ty));
         let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() };
-        let sig = FnSig { decl, header };
+        let sig = FnSig { decl, header, span: self.span };
         let block = Some(self.cx.block_expr(output_expr));
         let kind = ItemKind::Fn(ast::Defaultness::Final, sig, Generics::default(), block);
         let item = self.cx.item(
diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs
index 277cd8389e3..0ea60665d67 100644
--- a/src/librustc_builtin_macros/test_harness.rs
+++ b/src/librustc_builtin_macros/test_harness.rs
@@ -318,7 +318,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
     };
 
     let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty));
-    let sig = ast::FnSig { decl, header: ast::FnHeader::default() };
+    let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp };
     let def = ast::Defaultness::Final;
     let main = ast::ItemKind::Fn(def, sig, ast::Generics::default(), Some(main_body));
 
diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs
index cf356763130..cd4185226dc 100644
--- a/src/librustc_hir/hir.rs
+++ b/src/librustc_hir/hir.rs
@@ -1851,6 +1851,7 @@ pub struct MutTy<'hir> {
 pub struct FnSig<'hir> {
     pub header: FnHeader,
     pub decl: &'hir FnDecl<'hir>,
+    pub span: Span,
 }
 
 // The bodies for items are stored "out of line", in a separate
diff --git a/src/librustc_middle/hir/map/mod.rs b/src/librustc_middle/hir/map/mod.rs
index a6cc7cbc920..1e57411f9c5 100644
--- a/src/librustc_middle/hir/map/mod.rs
+++ b/src/librustc_middle/hir/map/mod.rs
@@ -828,13 +828,24 @@ impl<'hir> Map<'hir> {
         attrs.unwrap_or(&[])
     }
 
+    /// Gets the span of the definition of the specified HIR node.
+    /// This is used by `tcx.get_span`
     pub fn span(&self, hir_id: HirId) -> Span {
         match self.find_entry(hir_id).map(|entry| entry.node) {
             Some(Node::Param(param)) => param.span,
-            Some(Node::Item(item)) => item.span,
+            Some(Node::Item(item)) => match &item.kind {
+                ItemKind::Fn(sig, _, _) => sig.span,
+                _ => item.span,
+            },
             Some(Node::ForeignItem(foreign_item)) => foreign_item.span,
-            Some(Node::TraitItem(trait_method)) => trait_method.span,
-            Some(Node::ImplItem(impl_item)) => impl_item.span,
+            Some(Node::TraitItem(trait_item)) => match &trait_item.kind {
+                TraitItemKind::Fn(sig, _) => sig.span,
+                _ => trait_item.span,
+            },
+            Some(Node::ImplItem(impl_item)) => match &impl_item.kind {
+                ImplItemKind::Fn(sig, _) => sig.span,
+                _ => impl_item.span,
+            },
             Some(Node::Variant(variant)) => variant.span,
             Some(Node::Field(field)) => field.span,
             Some(Node::AnonConst(constant)) => self.body(constant.body).value.span,
@@ -866,6 +877,18 @@ impl<'hir> Map<'hir> {
         }
     }
 
+    /// Like `hir.span()`, but includes the body of function items
+    /// (instead of just the function header)
+    pub fn span_with_body(&self, hir_id: HirId) -> Span {
+        match self.find_entry(hir_id).map(|entry| entry.node) {
+            Some(Node::TraitItem(item)) => item.span,
+            Some(Node::ImplItem(impl_item)) => impl_item.span,
+            Some(Node::Item(item)) => item.span,
+            Some(_) => self.span(hir_id),
+            _ => bug!("hir::map::Map::span_with_body: id not in map: {:?}", hir_id),
+        }
+    }
+
     pub fn span_if_local(&self, id: DefId) -> Option<Span> {
         id.as_local().map(|id| self.span(self.local_def_id_to_hir_id(id)))
     }
diff --git a/src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs b/src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs
index 9197a83cdd0..a775fa59c1b 100644
--- a/src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs
+++ b/src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs
@@ -257,7 +257,7 @@ impl OutlivesSuggestionBuilder {
         };
 
         // We want this message to appear after other messages on the mir def.
-        let mir_span = mbcx.infcx.tcx.def_span(mbcx.mir_def_id);
+        let mir_span = mbcx.body.span;
         diag.sort_span = mir_span.shrink_to_hi();
 
         // Buffer the diagnostic
diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs
index 0c3f6fee665..d3c1aa50400 100644
--- a/src/librustc_mir_build/build/mod.rs
+++ b/src/librustc_mir_build/build/mod.rs
@@ -37,22 +37,29 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
     let id = tcx.hir().local_def_id_to_hir_id(def.did);
 
     // Figure out what primary body this item has.
-    let (body_id, return_ty_span) = match tcx.hir().get(id) {
+    let (body_id, return_ty_span, span_with_body) = match tcx.hir().get(id) {
         Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) => {
-            (*body_id, decl.output.span())
+            (*body_id, decl.output.span(), None)
         }
         Node::Item(hir::Item {
             kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
+            span,
             ..
         })
         | Node::ImplItem(hir::ImplItem {
             kind: hir::ImplItemKind::Fn(hir::FnSig { decl, .. }, body_id),
+            span,
             ..
         })
         | Node::TraitItem(hir::TraitItem {
             kind: hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)),
+            span,
             ..
-        }) => (*body_id, decl.output.span()),
+        }) => {
+            // Use the `Span` of the `Item/ImplItem/TraitItem` as the body span,
+            // since the def span of a function does not include the body
+            (*body_id, decl.output.span(), Some(*span))
+        }
         Node::Item(hir::Item {
             kind: hir::ItemKind::Static(ty, _, body_id) | hir::ItemKind::Const(ty, body_id),
             ..
@@ -61,12 +68,16 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
         | Node::TraitItem(hir::TraitItem {
             kind: hir::TraitItemKind::Const(ty, Some(body_id)),
             ..
-        }) => (*body_id, ty.span),
-        Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => (*body, tcx.hir().span(*hir_id)),
+        }) => (*body_id, ty.span, None),
+        Node::AnonConst(hir::AnonConst { body, hir_id, .. }) => (*body, tcx.hir().span(*hir_id), None),
 
         _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def.did),
     };
 
+    // If we don't have a specialized span for the body, just use the
+    // normal def span.
+    let span_with_body = span_with_body.unwrap_or_else(|| tcx.hir().span(id));
+
     tcx.infer_ctxt().enter(|infcx| {
         let cx = Cx::new(&infcx, def, id);
         let body = if let Some(ErrorReported) = cx.typeck_results().tainted_by_errors {
@@ -167,6 +178,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
                 return_ty,
                 return_ty_span,
                 body,
+                span_with_body
             );
             mir.yield_ty = yield_ty;
             mir
@@ -571,6 +583,7 @@ fn construct_fn<'a, 'tcx, A>(
     return_ty: Ty<'tcx>,
     return_ty_span: Span,
     body: &'tcx hir::Body<'tcx>,
+    span_with_body: Span
 ) -> Body<'tcx>
 where
     A: Iterator<Item = ArgInfo<'tcx>>,
@@ -585,7 +598,7 @@ where
 
     let mut builder = Builder::new(
         hir,
-        span,
+        span_with_body,
         arguments.len(),
         safety,
         return_ty,
@@ -628,7 +641,7 @@ where
                 )
             );
             // Attribute epilogue to function's closing brace
-            let fn_end = span.shrink_to_hi();
+            let fn_end = span_with_body.shrink_to_hi();
             let source_info = builder.source_info(fn_end);
             let return_block = builder.return_block();
             builder.cfg.goto(block, source_info, return_block);
diff --git a/src/librustc_mir_build/lints.rs b/src/librustc_mir_build/lints.rs
index 662b6c77357..fd2d5a4abd4 100644
--- a/src/librustc_mir_build/lints.rs
+++ b/src/librustc_mir_build/lints.rs
@@ -38,7 +38,7 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: LocalDefId) {
         vis.reachable_recursive_calls.sort();
 
         let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
-        let sp = tcx.sess.source_map().guess_head_span(tcx.hir().span(hir_id));
+        let sp = tcx.sess.source_map().guess_head_span(tcx.hir().span_with_body(hir_id));
         tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION, hir_id, sp, |lint| {
             let mut db = lint.build("function cannot return without recursing");
             db.span_label(sp, "cannot return without recursing");
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs
index 64479bc36e0..9143af651df 100644
--- a/src/librustc_parse/parser/item.rs
+++ b/src/librustc_parse/parser/item.rs
@@ -227,7 +227,7 @@ impl<'a> Parser<'a> {
             (Ident::invalid(), ItemKind::Use(P(tree)))
         } else if self.check_fn_front_matter() {
             // FUNCTION ITEM
-            let (ident, sig, generics, body) = self.parse_fn(attrs, req_name)?;
+            let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
             (ident, ItemKind::Fn(def(), sig, generics, body))
         } else if self.eat_keyword(kw::Extern) {
             if self.eat_keyword(kw::Crate) {
@@ -1492,21 +1492,31 @@ impl<'a> Parser<'a> {
         &mut self,
         attrs: &mut Vec<Attribute>,
         req_name: ReqName,
+        sig_lo: Span,
     ) -> PResult<'a, (Ident, FnSig, Generics, Option<P<Block>>)> {
         let header = self.parse_fn_front_matter()?; // `const ... fn`
         let ident = self.parse_ident()?; // `foo`
         let mut generics = self.parse_generics()?; // `<'a, T, ...>`
         let decl = self.parse_fn_decl(req_name, AllowPlus::Yes)?; // `(p: u8, ...)`
         generics.where_clause = self.parse_where_clause()?; // `where T: Ord`
-        let body = self.parse_fn_body(attrs)?; // `;` or `{ ... }`.
-        Ok((ident, FnSig { header, decl }, generics, body))
+
+        let mut sig_hi = self.prev_token.span;
+        let body = self.parse_fn_body(attrs, &mut sig_hi)?; // `;` or `{ ... }`.
+        let fn_sig_span = sig_lo.to(sig_hi);
+        Ok((ident, FnSig { header, decl, span: fn_sig_span }, generics, body))
     }
 
     /// Parse the "body" of a function.
     /// This can either be `;` when there's no body,
     /// or e.g. a block when the function is a provided one.
-    fn parse_fn_body(&mut self, attrs: &mut Vec<Attribute>) -> PResult<'a, Option<P<Block>>> {
+    fn parse_fn_body(
+        &mut self,
+        attrs: &mut Vec<Attribute>,
+        sig_hi: &mut Span,
+    ) -> PResult<'a, Option<P<Block>>> {
         let (inner_attrs, body) = if self.check(&token::Semi) {
+            // Include the trailing semicolon in the span of the signature
+            *sig_hi = self.token.span;
             self.bump(); // `;`
             (Vec::new(), None)
         } else if self.check(&token::OpenDelim(token::Brace)) || self.token.is_whole_block() {
diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs
index b3003cc63d3..6dd7f89d594 100644
--- a/src/librustc_save_analysis/sig.rs
+++ b/src/librustc_save_analysis/sig.rs
@@ -377,7 +377,7 @@ impl<'hir> Sig for hir::Item<'hir> {
 
                 Ok(extend_sig(ty, text, defs, vec![]))
             }
-            hir::ItemKind::Fn(hir::FnSig { ref decl, header }, ref generics, _) => {
+            hir::ItemKind::Fn(hir::FnSig { ref decl, header, span: _ }, ref generics, _) => {
                 let mut text = String::new();
                 if let hir::Constness::Const = header.constness {
                     text.push_str("const ");
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs
index e597843e6ce..28542d4b12e 100644
--- a/src/librustc_trait_selection/traits/error_reporting/mod.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs
@@ -399,16 +399,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                             err.note(s.as_str());
                         }
                         if let Some(ref s) = enclosing_scope {
-                            let enclosing_scope_span = tcx.def_span(
-                                tcx.hir()
-                                    .opt_local_def_id(obligation.cause.body_id)
-                                    .unwrap_or_else(|| {
-                                        tcx.hir().body_owner_def_id(hir::BodyId {
-                                            hir_id: obligation.cause.body_id,
-                                        })
+                            let body = tcx
+                                .hir()
+                                .opt_local_def_id(obligation.cause.body_id)
+                                .unwrap_or_else(|| {
+                                    tcx.hir().body_owner_def_id(hir::BodyId {
+                                        hir_id: obligation.cause.body_id,
                                     })
-                                    .to_def_id(),
-                            );
+                                });
+
+                            let enclosing_scope_span =
+                                tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(body));
 
                             err.span_label(enclosing_scope_span, s.as_str());
                         }
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 9afac60bb5b..1b472810ccf 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1543,7 +1543,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
         }
 
         TraitItem(hir::TraitItem {
-            kind: TraitItemKind::Fn(FnSig { header, decl }, _),
+            kind: TraitItemKind::Fn(FnSig { header, decl, span: _ }, _),
             ident,
             generics,
             ..
diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr
index 5ece425196c..b709fae5a8e 100644
--- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr
+++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/bound-lifetime-in-binding-only.rs:71:1
    |
 LL | fn main() { }
-   | ^^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/associated-types/bound-lifetime-in-return-only.ok.stderr b/src/test/ui/associated-types/bound-lifetime-in-return-only.ok.stderr
index 8c098098311..1c0d3ac1058 100644
--- a/src/test/ui/associated-types/bound-lifetime-in-return-only.ok.stderr
+++ b/src/test/ui/associated-types/bound-lifetime-in-return-only.ok.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/bound-lifetime-in-return-only.rs:49:1
    |
 LL | fn main() { }
-   | ^^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr
index baa8e6f82f6..ed900079cfc 100644
--- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr
+++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/project-fn-ret-contravariant.rs:50:1
    |
 LL | fn main() { }
-   | ^^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr
index baa8e6f82f6..ed900079cfc 100644
--- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr
+++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/project-fn-ret-contravariant.rs:50:1
    |
 LL | fn main() { }
-   | ^^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr
index 2156ecb1739..c3408500948 100644
--- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr
+++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/project-fn-ret-invariant.rs:60:1
    |
 LL | fn main() {}
-   | ^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/associated-types/higher-ranked-projection.good.stderr b/src/test/ui/associated-types/higher-ranked-projection.good.stderr
index 63d88543607..1dc41a2165f 100644
--- a/src/test/ui/associated-types/higher-ranked-projection.good.stderr
+++ b/src/test/ui/associated-types/higher-ranked-projection.good.stderr
@@ -1,11 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/higher-ranked-projection.rs:24:1
    |
-LL | / fn main() {
-LL | |     foo(());
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-no-fg.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-no-fg.stderr
index da584e8ad4e..f65bbeaa31a 100644
--- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-no-fg.stderr
+++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-no-fg.stderr
@@ -25,28 +25,16 @@ LL | async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'
 error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
   --> $DIR/ret-impl-trait-no-fg.rs:9:1
    |
-LL | / async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |     (a, b)
-LL | | }
-   | |_^
+LL | async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: hidden type `(&u8, &u8)` captures lifetime '_#5r
 
 error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
   --> $DIR/ret-impl-trait-no-fg.rs:9:1
    |
-LL | / async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |     (a, b)
-LL | | }
-   | |_^
+LL | async fn async_ret_impl_trait<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a, 'b> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: hidden type `(&u8, &u8)` captures lifetime '_#6r
 
diff --git a/src/test/ui/block-result/issue-20862.stderr b/src/test/ui/block-result/issue-20862.stderr
index f9c890b0ed8..560c9c2fbef 100644
--- a/src/test/ui/block-result/issue-20862.stderr
+++ b/src/test/ui/block-result/issue-20862.stderr
@@ -12,16 +12,13 @@ LL |     |y| x + y
 error[E0618]: expected function, found `()`
   --> $DIR/issue-20862.rs:7:13
    |
-LL | / fn foo(x: i32) {
-LL | |     |y| x + y
-LL | |
-LL | | }
-   | |_- `foo` defined here returns `()`
+LL | fn foo(x: i32) {
+   | -------------- `foo` defined here returns `()`
 ...
-LL |       let x = foo(5)(2);
-   |               ^^^^^^---
-   |               |
-   |               call expression requires function
+LL |     let x = foo(5)(2);
+   |             ^^^^^^---
+   |             |
+   |             call expression requires function
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
index a60be6f23c4..2c1c3c2dc96 100644
--- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
+++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr
@@ -2,9 +2,9 @@ error[E0592]: duplicate definitions with name `f`
   --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:14
    |
 LL | impl dyn C { fn f() {} }
-   |              ^^^^^^^^^ duplicate definitions for `f`
+   |              ^^^^^^ duplicate definitions for `f`
 LL | impl dyn C { fn f() {} }
-   |              --------- other definition for `f`
+   |              ------ other definition for `f`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr b/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
index 8fe24bae7c6..6fca12e1823 100644
--- a/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
+++ b/src/test/ui/codemap_tests/overlapping_inherent_impls.stderr
@@ -2,28 +2,28 @@ error[E0592]: duplicate definitions with name `id`
   --> $DIR/overlapping_inherent_impls.rs:9:5
    |
 LL |     fn id() {}
-   |     ^^^^^^^^^^ duplicate definitions for `id`
+   |     ^^^^^^^ duplicate definitions for `id`
 ...
 LL |     fn id() {}
-   |     ---------- other definition for `id`
+   |     ------- other definition for `id`
 
 error[E0592]: duplicate definitions with name `bar`
   --> $DIR/overlapping_inherent_impls.rs:19:5
    |
 LL |     fn bar(&self) {}
-   |     ^^^^^^^^^^^^^^^^ duplicate definitions for `bar`
+   |     ^^^^^^^^^^^^^ duplicate definitions for `bar`
 ...
 LL |     fn bar(&self) {}
-   |     ---------------- other definition for `bar`
+   |     ------------- other definition for `bar`
 
 error[E0592]: duplicate definitions with name `baz`
   --> $DIR/overlapping_inherent_impls.rs:29:5
    |
 LL |     fn baz(&self) {}
-   |     ^^^^^^^^^^^^^^^^ duplicate definitions for `baz`
+   |     ^^^^^^^^^^^^^ duplicate definitions for `baz`
 ...
 LL |     fn baz(&self) {}
-   |     ---------------- other definition for `baz`
+   |     ------------- other definition for `baz`
    |
    = note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::vec::Vec<_>` in future versions
 
diff --git a/src/test/ui/coherence/coherence-inherited-subtyping.old.stderr b/src/test/ui/coherence/coherence-inherited-subtyping.old.stderr
index 6ea0b89be74..4701bc0b139 100644
--- a/src/test/ui/coherence/coherence-inherited-subtyping.old.stderr
+++ b/src/test/ui/coherence/coherence-inherited-subtyping.old.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `method1`
   --> $DIR/coherence-inherited-subtyping.rs:14:5
    |
 LL |     fn method1(&self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`
+   |     ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`
 ...
 LL |     fn method1(&self) {}
-   |     -------------------- other definition for `method1`
+   |     ----------------- other definition for `method1`
    |
    = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
 
diff --git a/src/test/ui/coherence/coherence-inherited-subtyping.re.stderr b/src/test/ui/coherence/coherence-inherited-subtyping.re.stderr
index 6ea0b89be74..4701bc0b139 100644
--- a/src/test/ui/coherence/coherence-inherited-subtyping.re.stderr
+++ b/src/test/ui/coherence/coherence-inherited-subtyping.re.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `method1`
   --> $DIR/coherence-inherited-subtyping.rs:14:5
    |
 LL |     fn method1(&self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`
+   |     ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`
 ...
 LL |     fn method1(&self) {}
-   |     -------------------- other definition for `method1`
+   |     ----------------- other definition for `method1`
    |
    = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
 
diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr
index 4cb7390453c..bbce4b530b4 100644
--- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr
+++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr
@@ -2,19 +2,19 @@ error[E0592]: duplicate definitions with name `dummy`
   --> $DIR/coherence-overlap-downstream-inherent.rs:7:26
    |
 LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
-   |                          ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
+   |                          ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
 LL |
 LL | impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
-   |                          ------------------- other definition for `dummy`
+   |                          --------------- other definition for `dummy`
 
 error[E0592]: duplicate definitions with name `f`
   --> $DIR/coherence-overlap-downstream-inherent.rs:13:38
    |
 LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
-   |                                      ^^^^^^^^^^^^^^ duplicate definitions for `f`
+   |                                      ^^^^^^^^^^^ duplicate definitions for `f`
 LL |
 LL | impl<X> A<i32, X> { fn f(&self) {} }
-   |                     -------------- other definition for `f`
+   |                     ----------- other definition for `f`
    |
    = note: downstream crates may implement trait `Bar<_>` for type `i32`
 
diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr
index e63f8a997af..3ad818cbc36 100644
--- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr
+++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `dummy`
   --> $DIR/coherence-overlap-issue-23516-inherent.rs:9:25
    |
 LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
-   |                         ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
+   |                         ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
 LL |
 LL | impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
-   |                              ------------------- other definition for `dummy`
+   |                              --------------- other definition for `dummy`
    |
    = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>`
 
diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr
index 51316f24975..f355c6e855c 100644
--- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr
+++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `dummy`
   --> $DIR/coherence-overlap-upstream-inherent.rs:12:32
    |
 LL | impl<T> A<T> where T: Remote { fn dummy(&self) { } }
-   |                                ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
+   |                                ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
 LL |
 LL | impl A<i16> { fn dummy(&self) { } }
-   |               ------------------- other definition for `dummy`
+   |               --------------- other definition for `dummy`
    |
    = note: upstream crates may add a new impl of trait `coherence_lib::Remote` for type `i16` in future versions
 
diff --git a/src/test/ui/duplicate/dupe-symbols-1.stderr b/src/test/ui/duplicate/dupe-symbols-1.stderr
index cca8b4d25da..933ed5e89e5 100644
--- a/src/test/ui/duplicate/dupe-symbols-1.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-1.stderr
@@ -1,10 +1,8 @@
 error: symbol `fail` is already defined
   --> $DIR/dupe-symbols-1.rs:12:1
    |
-LL | / pub fn b() {
-LL | |
-LL | | }
-   | |_^
+LL | pub fn b() {
+   | ^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/duplicate/dupe-symbols-2.stderr b/src/test/ui/duplicate/dupe-symbols-2.stderr
index 017aade3129..1b29edfb655 100644
--- a/src/test/ui/duplicate/dupe-symbols-2.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-2.stderr
@@ -1,10 +1,8 @@
 error: symbol `fail` is already defined
   --> $DIR/dupe-symbols-2.rs:15:5
    |
-LL | /     pub extern fn fail() {
-LL | |
-LL | |     }
-   | |_____^
+LL |     pub extern fn fail() {
+   |     ^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/duplicate/dupe-symbols-3.stderr b/src/test/ui/duplicate/dupe-symbols-3.stderr
index 2e2ac3a98b8..6300b4908d1 100644
--- a/src/test/ui/duplicate/dupe-symbols-3.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-3.stderr
@@ -1,10 +1,8 @@
 error: symbol `fail` is already defined
   --> $DIR/dupe-symbols-3.rs:12:1
    |
-LL | / pub fn fail() {
-LL | |
-LL | | }
-   | |_^
+LL | pub fn fail() {
+   | ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/duplicate/dupe-symbols-4.stderr b/src/test/ui/duplicate/dupe-symbols-4.stderr
index 10b93891b66..1407a4883e1 100644
--- a/src/test/ui/duplicate/dupe-symbols-4.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-4.stderr
@@ -2,7 +2,7 @@ error: symbol `fail` is already defined
   --> $DIR/dupe-symbols-4.rs:23:5
    |
 LL |     fn fail(self) {}
-   |     ^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/duplicate/dupe-symbols-5.stderr b/src/test/ui/duplicate/dupe-symbols-5.stderr
index ebeb19f94f6..558f868a0c6 100644
--- a/src/test/ui/duplicate/dupe-symbols-5.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-5.stderr
@@ -1,10 +1,8 @@
 error: symbol `fail` is already defined
   --> $DIR/dupe-symbols-5.rs:11:1
    |
-LL | / pub fn b() {
-LL | |
-LL | | }
-   | |_^
+LL | pub fn b() {
+   | ^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/duplicate/dupe-symbols-7.stderr b/src/test/ui/duplicate/dupe-symbols-7.stderr
index 2ea5521e095..1455f0e75ab 100644
--- a/src/test/ui/duplicate/dupe-symbols-7.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-7.stderr
@@ -2,7 +2,7 @@ error: entry symbol `main` declared multiple times
   --> $DIR/dupe-symbols-7.rs:12:1
    |
 LL | fn main(){}
-   | ^^^^^^^^^^^
+   | ^^^^^^^^^
    |
    = help: did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
 
diff --git a/src/test/ui/duplicate/dupe-symbols-8.stderr b/src/test/ui/duplicate/dupe-symbols-8.stderr
index f001201b8d0..8d6a79e12d9 100644
--- a/src/test/ui/duplicate/dupe-symbols-8.stderr
+++ b/src/test/ui/duplicate/dupe-symbols-8.stderr
@@ -1,13 +1,8 @@
 error: entry symbol `main` declared multiple times
   --> $DIR/dupe-symbols-8.rs:7:1
    |
-LL | / fn main() {
-LL | |     extern "Rust" {
-LL | |      fn main();
-LL | |     }
-LL | |     unsafe { main(); }
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
    |
    = help: did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
 
diff --git a/src/test/ui/duplicate_entry_error.stderr b/src/test/ui/duplicate_entry_error.stderr
index 61cccf40ed8..6d078dfbd20 100644
--- a/src/test/ui/duplicate_entry_error.stderr
+++ b/src/test/ui/duplicate_entry_error.stderr
@@ -1,11 +1,8 @@
 error[E0152]: found duplicate lang item `panic_impl`
   --> $DIR/duplicate_entry_error.rs:11:1
    |
-LL | / fn panic_impl(info: &PanicInfo) -> ! {
-LL | |
-LL | |     loop {}
-LL | | }
-   | |_^
+LL | fn panic_impl(info: &PanicInfo) -> ! {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on)
    = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
diff --git a/src/test/ui/error-codes/E0445.stderr b/src/test/ui/error-codes/E0445.stderr
index d0d6ebe16c7..953a626bf95 100644
--- a/src/test/ui/error-codes/E0445.stderr
+++ b/src/test/ui/error-codes/E0445.stderr
@@ -14,7 +14,7 @@ error[E0445]: private trait `Foo` in public interface
   --> $DIR/E0445.rs:9:1
    |
 LL | pub fn foo<T: Foo> (t: T) {}
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/error-codes/E0446.stderr b/src/test/ui/error-codes/E0446.stderr
index a0f5f7079b3..bb009260979 100644
--- a/src/test/ui/error-codes/E0446.stderr
+++ b/src/test/ui/error-codes/E0446.stderr
@@ -1,13 +1,11 @@
 error[E0446]: private type `foo::Bar` in public interface
   --> $DIR/E0446.rs:4:5
    |
-LL |       struct Bar(u32);
-   |       - `foo::Bar` declared as private
+LL |     struct Bar(u32);
+   |     - `foo::Bar` declared as private
 LL | 
-LL | /     pub fn bar() -> Bar {
-LL | |         Bar(0)
-LL | |     }
-   | |_____^ can't leak private type
+LL |     pub fn bar() -> Bar {
+   |     ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr
index 94837556610..2bf78d12290 100644
--- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr
+++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/hr-subtype.rs:102:1
    |
-LL | / fn main() {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/hrtb/issue-58451.stderr b/src/test/ui/hrtb/issue-58451.stderr
index c0915808bf5..bd08fc1bfae 100644
--- a/src/test/ui/hrtb/issue-58451.stderr
+++ b/src/test/ui/hrtb/issue-58451.stderr
@@ -5,8 +5,7 @@ LL | / fn f<I>(i: I)
 LL | | where
 LL | |     I: IntoIterator,
 LL | |     I::Item: for<'a> Into<&'a ()>,
-LL | | {}
-   | |__- defined here
+   | |__________________________________- defined here
 ...
 LL |       f(&[f()]);
    |           ^-- supplied 0 arguments
diff --git a/src/test/ui/infinite/infinite-instantiation.stderr b/src/test/ui/infinite/infinite-instantiation.stderr
index 7b22393ee7c..eb07d8905d6 100644
--- a/src/test/ui/infinite/infinite-instantiation.stderr
+++ b/src/test/ui/infinite/infinite-instantiation.stderr
@@ -7,13 +7,8 @@ LL |         function(counter - 1, t.to_option());
 note: `function` defined here
   --> $DIR/infinite-instantiation.rs:19:1
    |
-LL | / fn function<T:ToOpt + Clone>(counter: usize, t: T) {
-LL | |     if counter > 0 {
-LL | |         function(counter - 1, t.to_option());
-LL | |
-LL | |     }
-LL | | }
-   | |_^
+LL | fn function<T:ToOpt + Clone>(counter: usize, t: T) {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-16683.stderr b/src/test/ui/issues/issue-16683.stderr
index 4f658330758..6efc12df8fa 100644
--- a/src/test/ui/issues/issue-16683.stderr
+++ b/src/test/ui/issues/issue-16683.stderr
@@ -7,10 +7,8 @@ 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
    |
-LL | /     fn b(&self) {
-LL | |         self.a();
-LL | |     }
-   | |_____^
+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 cd1d7f821c7..9fe80232a14 100644
--- a/src/test/ui/issues/issue-17740.stderr
+++ b/src/test/ui/issues/issue-17740.stderr
@@ -9,14 +9,8 @@ LL |     fn bar(self: &mut Foo) {
 note: the anonymous lifetime #2 defined on the method body at 6:5...
   --> $DIR/issue-17740.rs:6:5
    |
-LL | /     fn bar(self: &mut Foo) {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | |     }
-   | |_____^
+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
    |
@@ -39,14 +33,8 @@ 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
    |
-LL | /     fn bar(self: &mut Foo) {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | |     }
-   | |_____^
+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 31788cfa61c..f82e0f53a23 100644
--- a/src/test/ui/issues/issue-17758.stderr
+++ b/src/test/ui/issues/issue-17758.stderr
@@ -7,11 +7,8 @@ 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
    |
-LL | /     fn bar(&self) {
-LL | |         self.foo();
-LL | |
-LL | |     }
-   | |_____^
+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 f347c26f066..c762a4ab496 100644
--- a/src/test/ui/issues/issue-17905-2.stderr
+++ b/src/test/ui/issues/issue-17905-2.stderr
@@ -9,12 +9,8 @@ LL |     fn say(self: &Pair<&str, isize>) {
 note: the anonymous lifetime #2 defined on the method body at 8:5...
   --> $DIR/issue-17905-2.rs:8:5
    |
-LL | /     fn say(self: &Pair<&str, isize>) {
-LL | |
-LL | |
-LL | |         println!("{:?}", self);
-LL | |     }
-   | |_____^
+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
    |
@@ -37,12 +33,8 @@ 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
    |
-LL | /     fn say(self: &Pair<&str, isize>) {
-LL | |
-LL | |
-LL | |         println!("{:?}", self);
-LL | |     }
-   | |_____^
+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 e7c1dcc5d69..1ab89e818e3 100644
--- a/src/test/ui/issues/issue-20831-debruijn.stderr
+++ b/src/test/ui/issues/issue-20831-debruijn.stderr
@@ -15,14 +15,8 @@ LL | |     }
 note: the anonymous lifetime #2 defined on the method body at 28:5...
   --> $DIR/issue-20831-debruijn.rs:28:5
    |
-LL | /     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
-LL | |         // Not obvious, but there is an implicit lifetime here -------^
-LL | |
-LL | |
-...  |
-LL | |         self.sub = t;
-LL | |     }
-   | |_____^
+LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 26:6
   --> $DIR/issue-20831-debruijn.rs:26:6
    |
@@ -51,14 +45,8 @@ LL | impl<'a> Publisher<'a> for MyStruct<'a> {
 note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5
   --> $DIR/issue-20831-debruijn.rs:28:5
    |
-LL | /     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
-LL | |         // Not obvious, but there is an implicit lifetime here -------^
-LL | |
-LL | |
-...  |
-LL | |         self.sub = t;
-LL | |     }
-   | |_____^
+LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
   --> $DIR/issue-20831-debruijn.rs:28:33
@@ -69,14 +57,8 @@ LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher
 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
    |
-LL | /     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
-LL | |         // Not obvious, but there is an implicit lifetime here -------^
-LL | |
-LL | |
-...  |
-LL | |         self.sub = t;
-LL | |     }
-   | |_____^
+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
    |
@@ -99,14 +81,8 @@ LL |     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher
 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
    |
-LL | /     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
-LL | |         // Not obvious, but there is an implicit lifetime here -------^
-LL | |
-LL | |
-...  |
-LL | |         self.sub = t;
-LL | |     }
-   | |_____^
+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-22638.stderr b/src/test/ui/issues/issue-22638.stderr
index 41965d6b355..b0df46b11fa 100644
--- a/src/test/ui/issues/issue-22638.stderr
+++ b/src/test/ui/issues/issue-22638.stderr
@@ -1,12 +1,8 @@
 error: reached the type-length limit while instantiating `D::matches::$CLOSURE`
   --> $DIR/issue-22638.rs:53:5
    |
-LL | /     pub fn matches<F: Fn()>(&self, f: &F) {
-LL | |
-LL | |         let &D(ref a) = self;
-LL | |         a.matches(f)
-LL | |     }
-   | |_____^
+LL |     pub fn matches<F: Fn()>(&self, f: &F) {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: consider adding a `#![type_length_limit="30408681"]` attribute to your crate
 
diff --git a/src/test/ui/issues/issue-30079.stderr b/src/test/ui/issues/issue-30079.stderr
index f4a530124ff..e67f297ffa7 100644
--- a/src/test/ui/issues/issue-30079.stderr
+++ b/src/test/ui/issues/issue-30079.stderr
@@ -2,7 +2,7 @@ warning: private type `m1::Priv` in public interface (error E0446)
   --> $DIR/issue-30079.rs:6:9
    |
 LL |         pub fn f(_: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(private_in_public)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
diff --git a/src/test/ui/issues/issue-33140.stderr b/src/test/ui/issues/issue-33140.stderr
index 6c3ba63e6f6..9a900d2fc94 100644
--- a/src/test/ui/issues/issue-33140.stderr
+++ b/src/test/ui/issues/issue-33140.stderr
@@ -19,15 +19,11 @@ LL | impl Trait2 for dyn Sync + Send + Sync {
 error[E0592]: duplicate definitions with name `abc`
   --> $DIR/issue-33140.rs:29:5
    |
-LL | /     fn abc() -> bool {
-LL | |         false
-LL | |     }
-   | |_____^ duplicate definitions for `abc`
+LL |     fn abc() -> bool {
+   |     ^^^^^^^^^^^^^^^^ duplicate definitions for `abc`
 ...
-LL | /     fn abc() -> bool {
-LL | |         true
-LL | |     }
-   | |_____- other definition for `abc`
+LL |     fn abc() -> bool {
+   |     ---------------- other definition for `abc`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr
index 7a4b59b5633..6229d90d4b4 100644
--- a/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr
+++ b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.stderr
@@ -1,10 +1,8 @@
 error: reached the type-length limit while instantiating `<(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(...))))))))))))))) as Foo>::recurse`
   --> $DIR/issue-37311.rs:15:5
    |
-LL | /     fn recurse(&self) {
-LL | |         (self, self).recurse();
-LL | |     }
-   | |_____^
+LL |     fn recurse(&self) {
+   |     ^^^^^^^^^^^^^^^^^
    |
    = note: consider adding a `#![type_length_limit="2097149"]` attribute to your crate
 
diff --git a/src/test/ui/issues/issue-37884.stderr b/src/test/ui/issues/issue-37884.stderr
index 703cdf08548..5baa245b3cc 100644
--- a/src/test/ui/issues/issue-37884.stderr
+++ b/src/test/ui/issues/issue-37884.stderr
@@ -14,13 +14,8 @@ LL | |     }
 note: the anonymous lifetime #1 defined on the method body at 6:5...
   --> $DIR/issue-37884.rs:6:5
    |
-LL | /     fn next(&'a mut self) -> Option<Self::Item>
-LL | |
-LL | |
-LL | |     {
-LL | |         Some(&mut self.0)
-LL | |     }
-   | |_____^
+LL |     fn next(&'a mut self) -> Option<Self::Item>
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 3:6
   --> $DIR/issue-37884.rs:3:6
    |
diff --git a/src/test/ui/issues/issue-67552.stderr b/src/test/ui/issues/issue-67552.stderr
index 3bb2016f07d..8243e52039d 100644
--- a/src/test/ui/issues/issue-67552.stderr
+++ b/src/test/ui/issues/issue-67552.stderr
@@ -10,11 +10,7 @@ note: `rec` defined here
 LL | / fn rec<T>(mut it: T)
 LL | | where
 LL | |     T: Iterator,
-LL | | {
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |________________^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-8727.stderr b/src/test/ui/issues/issue-8727.stderr
index 70709fd33ac..59008151f1a 100644
--- a/src/test/ui/issues/issue-8727.stderr
+++ b/src/test/ui/issues/issue-8727.stderr
@@ -18,10 +18,8 @@ LL |     generic::<Option<T>>();
 note: `generic` defined here
   --> $DIR/issue-8727.rs:6:1
    |
-LL | / fn generic<T>() {
-LL | |     generic::<Option<T>>();
-LL | | }
-   | |_^
+LL | fn generic<T>() {
+   | ^^^^^^^^^^^^^^^
 
 error: aborting due to previous error; 1 warning emitted
 
diff --git a/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr b/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr
index 68434c13110..ae7d5a98b08 100644
--- a/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr
+++ b/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr
@@ -32,7 +32,7 @@ error[E0714]: marker traits cannot have associated items
   --> $DIR/marker-trait-with-associated-items.rs:36:5
    |
 LL |     fn foo() {}
-   |     ^^^^^^^^^^^
+   |     ^^^^^^^^
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/nll/issue-52742.stderr b/src/test/ui/nll/issue-52742.stderr
index 0cdc2d94439..7631ca61e5e 100644
--- a/src/test/ui/nll/issue-52742.stderr
+++ b/src/test/ui/nll/issue-52742.stderr
@@ -12,11 +12,8 @@ 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
    |
-LL | /     fn take_bar(&mut self, b: Bar<'_>) {
-LL | |         self.y = b.z
-LL | |
-LL | |     }
-   | |_____^
+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 ba8d91b8455..e24ef176db0 100644
--- a/src/test/ui/nll/issue-55394.stderr
+++ b/src/test/ui/nll/issue-55394.stderr
@@ -7,10 +7,8 @@ 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
    |
-LL | /     fn new(bar: &mut Bar) -> Self {
-LL | |         Foo { bar }
-LL | |     }
-   | |_____^
+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 3317aae83bb..65ce0581121 100644
--- a/src/test/ui/nll/type-alias-free-regions.stderr
+++ b/src/test/ui/nll/type-alias-free-regions.stderr
@@ -7,10 +7,8 @@ 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
    |
-LL | /     fn from_box(b: Box<B>) -> Self {
-LL | |         C { f: b }
-LL | |     }
-   | |_____^
+LL |     fn from_box(b: Box<B>) -> Self {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...so that the expression is assignable
   --> $DIR/type-alias-free-regions.rs:17:16
    |
@@ -40,10 +38,8 @@ 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
    |
-LL | /     fn from_tuple(b: (B,)) -> Self {
-LL | |         C { f: Box::new(b.0) }
-LL | |     }
-   | |_____^
+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/panic-handler/panic-handler-bad-signature-4.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr
index 3a5fc76efbb..5e46da12142 100644
--- a/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr
@@ -1,11 +1,8 @@
 error: should have no type parameters
   --> $DIR/panic-handler-bad-signature-4.rs:9:1
    |
-LL | / fn panic<T>(pi: &PanicInfo) -> ! {
-LL | |
-LL | |     loop {}
-LL | | }
-   | |_^
+LL | fn panic<T>(pi: &PanicInfo) -> ! {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/panic-handler/panic-handler-duplicate.stderr b/src/test/ui/panic-handler/panic-handler-duplicate.stderr
index 8603ef91bef..8cdc4888d02 100644
--- a/src/test/ui/panic-handler/panic-handler-duplicate.stderr
+++ b/src/test/ui/panic-handler/panic-handler-duplicate.stderr
@@ -1,18 +1,14 @@
 error[E0152]: found duplicate lang item `panic_impl`
   --> $DIR/panic-handler-duplicate.rs:15:1
    |
-LL | / fn panic2(info: &PanicInfo) -> ! {
-LL | |     loop {}
-LL | | }
-   | |_^
+LL | fn panic2(info: &PanicInfo) -> ! {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
 note: the lang item is first defined here
   --> $DIR/panic-handler-duplicate.rs:10:1
    |
-LL | / fn panic(info: &PanicInfo) -> ! {
-LL | |     loop {}
-LL | | }
-   | |_^
+LL | fn panic(info: &PanicInfo) -> ! {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/panic-handler/panic-handler-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr
index bb656089bca..e4069b196ff 100644
--- a/src/test/ui/panic-handler/panic-handler-std.stderr
+++ b/src/test/ui/panic-handler/panic-handler-std.stderr
@@ -1,10 +1,8 @@
 error[E0152]: found duplicate lang item `panic_impl`
   --> $DIR/panic-handler-std.rs:8:1
    |
-LL | / fn panic(info: PanicInfo) -> ! {
-LL | |     loop {}
-LL | | }
-   | |_^
+LL | fn panic(info: PanicInfo) -> ! {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on)
    = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
diff --git a/src/test/ui/privacy/private-in-public-lint.stderr b/src/test/ui/privacy/private-in-public-lint.stderr
index 441a4d5cffd..377bd58b54c 100644
--- a/src/test/ui/privacy/private-in-public-lint.stderr
+++ b/src/test/ui/privacy/private-in-public-lint.stderr
@@ -5,7 +5,7 @@ LL |     struct Priv;
    |     - `m1::Priv` declared as private
 ...
 LL |         pub fn f() -> Priv {Priv}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `m2::Priv` in public interface
   --> $DIR/private-in-public-lint.rs:15:9
@@ -14,7 +14,7 @@ LL |     struct Priv;
    |     - `m2::Priv` declared as private
 ...
 LL |         pub fn f() -> Priv {Priv}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/privacy/private-in-public-non-principal.stderr b/src/test/ui/privacy/private-in-public-non-principal.stderr
index 43469f74538..5b4123ea82a 100644
--- a/src/test/ui/privacy/private-in-public-non-principal.stderr
+++ b/src/test/ui/privacy/private-in-public-non-principal.stderr
@@ -2,7 +2,7 @@ warning: private trait `PrivNonPrincipal` in public interface (error E0445)
   --> $DIR/private-in-public-non-principal.rs:7:1
    |
 LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(private_in_public)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr
index 38081295e7e..4905e295195 100644
--- a/src/test/ui/privacy/private-in-public-warn.stderr
+++ b/src/test/ui/privacy/private-in-public-warn.stderr
@@ -52,7 +52,7 @@ error: private type `types::Priv` in public interface (error E0446)
   --> $DIR/private-in-public-warn.rs:27:9
    |
 LL |         fn f1(arg: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
@@ -61,7 +61,7 @@ error: private type `types::Priv` in public interface (error E0446)
   --> $DIR/private-in-public-warn.rs:29:9
    |
 LL |         fn f2() -> Priv { panic!() }
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
@@ -148,7 +148,7 @@ error: private trait `traits::PrivTr` in public interface (error E0445)
   --> $DIR/private-in-public-warn.rs:61:9
    |
 LL |         fn f<T: PrivTr>(arg: T) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
@@ -193,7 +193,7 @@ error: private trait `traits_where::PrivTr` in public interface (error E0445)
   --> $DIR/private-in-public-warn.rs:83:9
    |
 LL |         fn f<T>(arg: T) where T: PrivTr {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
@@ -265,7 +265,7 @@ error: private type `aliases_pub::Priv` in public interface (error E0446)
   --> $DIR/private-in-public-warn.rs:206:9
    |
 LL |         pub fn f(arg: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
diff --git a/src/test/ui/privacy/private-in-public.stderr b/src/test/ui/privacy/private-in-public.stderr
index e3fa4c145c3..4750fe8687e 100644
--- a/src/test/ui/privacy/private-in-public.stderr
+++ b/src/test/ui/privacy/private-in-public.stderr
@@ -23,7 +23,7 @@ LL |     struct Priv;
    |     - `types::Priv` declared as private
 ...
 LL |     pub fn f1(arg: Priv) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `types::Priv` in public interface
   --> $DIR/private-in-public.rs:16:5
@@ -32,7 +32,7 @@ LL |     struct Priv;
    |     - `types::Priv` declared as private
 ...
 LL |     pub fn f2() -> Priv { panic!() }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `types::Priv` in public interface
   --> $DIR/private-in-public.rs:17:19
@@ -68,7 +68,7 @@ LL |     struct Priv;
    |     - `types::Priv` declared as private
 ...
 LL |         pub fn f1(arg: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `types::Priv` in public interface
   --> $DIR/private-in-public.rs:22:9
@@ -77,7 +77,7 @@ LL |     struct Priv;
    |     - `types::Priv` declared as private
 ...
 LL |         pub fn f2() -> Priv { panic!() }
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0445]: private trait `traits::PrivTr` in public interface
   --> $DIR/private-in-public.rs:31:5
@@ -95,7 +95,7 @@ LL |     trait PrivTr {}
    |     - `traits::PrivTr` declared as private
 ...
 LL |     pub fn f<T: PrivTr>(arg: T) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `traits::PrivTr` in public interface
   --> $DIR/private-in-public.rs:33:5
@@ -124,7 +124,7 @@ LL |     trait PrivTr {}
    |     - `traits::PrivTr` declared as private
 ...
 LL |         pub fn f<U: PrivTr>(arg: U) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `traits_where::PrivTr` in public interface
   --> $DIR/private-in-public.rs:44:5
@@ -142,7 +142,7 @@ LL |     trait PrivTr {}
    |     - `traits_where::PrivTr` declared as private
 ...
 LL |     pub fn f<T>(arg: T) where T: PrivTr {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0445]: private trait `traits_where::PrivTr` in public interface
   --> $DIR/private-in-public.rs:48:5
@@ -173,7 +173,7 @@ LL |     trait PrivTr {}
    |     - `traits_where::PrivTr` declared as private
 ...
 LL |         pub fn f<U>(arg: U) where U: PrivTr {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0446]: private type `generics::Priv` in public interface
   --> $DIR/private-in-public.rs:63:5
@@ -182,7 +182,7 @@ LL |     struct Priv<T = u8>(T);
    |     - `generics::Priv` declared as private
 ...
 LL |     pub fn f1(arg: [Priv; 1]) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `generics::Priv` in public interface
   --> $DIR/private-in-public.rs:64:5
@@ -191,7 +191,7 @@ LL |     struct Priv<T = u8>(T);
    |     - `generics::Priv` declared as private
 ...
 LL |     pub fn f2(arg: Pub<Priv>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `generics::Priv<generics::Pub>` in public interface
   --> $DIR/private-in-public.rs:65:5
@@ -200,7 +200,7 @@ LL |     struct Priv<T = u8>(T);
    |     - `generics::Priv<generics::Pub>` declared as private
 ...
 LL |     pub fn f3(arg: Priv<Pub>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `impls::Priv` in public interface
   --> $DIR/private-in-public.rs:80:9
@@ -209,7 +209,7 @@ LL |     struct Priv;
    |     - `impls::Priv` declared as private
 ...
 LL |         pub fn f(arg: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0445]: private trait `aliases_pub::PrivTr` in public interface
   --> $DIR/private-in-public.rs:104:5
@@ -218,7 +218,7 @@ LL |     trait PrivTr {
    |     - `aliases_pub::PrivTr` declared as private
 ...
 LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
   --> $DIR/private-in-public.rs:104:5
@@ -227,7 +227,7 @@ LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
 ...
 LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_pub::Priv` in public interface
   --> $DIR/private-in-public.rs:109:9
@@ -236,7 +236,7 @@ LL |     struct Priv;
    |     - `aliases_pub::Priv` declared as private
 ...
 LL |         pub fn f(arg: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_priv::Priv1` in public interface
   --> $DIR/private-in-public.rs:131:5
@@ -245,7 +245,7 @@ LL |     struct Priv1;
    |     - `aliases_priv::Priv1` declared as private
 ...
 LL |     pub fn f1(arg: PrivUseAlias) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_priv::Priv2` in public interface
   --> $DIR/private-in-public.rs:132:5
@@ -254,7 +254,7 @@ LL |     struct Priv2;
    |     - `aliases_priv::Priv2` declared as private
 ...
 LL |     pub fn f2(arg: PrivAlias) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0445]: private trait `aliases_priv::PrivTr` in public interface
   --> $DIR/private-in-public.rs:133:5
@@ -263,7 +263,7 @@ LL |     trait PrivTr {
    |     - `aliases_priv::PrivTr` declared as private
 ...
 LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
 
 error[E0446]: private type `aliases_priv::Priv` in public interface
   --> $DIR/private-in-public.rs:133:5
@@ -272,7 +272,7 @@ LL |     struct Priv;
    |     - `aliases_priv::Priv` declared as private
 ...
 LL |     pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_params::Priv` in public interface
   --> $DIR/private-in-public.rs:143:5
@@ -281,7 +281,7 @@ LL |     struct Priv;
    |     - `aliases_params::Priv` declared as private
 ...
 LL |     pub fn f2(arg: PrivAliasGeneric) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `aliases_params::Priv` in public interface
   --> $DIR/private-in-public.rs:145:5
@@ -290,7 +290,7 @@ LL |     struct Priv;
    |     - `aliases_params::Priv` declared as private
 ...
 LL |     pub fn f3(arg: Result<u8>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: aborting due to 32 previous errors
 
diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr
index 010969c03af..727134bd51d 100644
--- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr
+++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr
@@ -14,7 +14,7 @@ error: type `priv_dep::OtherType` from private dependency 'priv_dep' in public i
   --> $DIR/pub-priv1.rs:27:5
    |
 LL |     pub fn pub_fn(param: OtherType) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface
   --> $DIR/pub-priv1.rs:33:1
diff --git a/src/test/ui/privacy/restricted/private-in-public.stderr b/src/test/ui/privacy/restricted/private-in-public.stderr
index 87c96d31f09..c597935e7f0 100644
--- a/src/test/ui/privacy/restricted/private-in-public.stderr
+++ b/src/test/ui/privacy/restricted/private-in-public.stderr
@@ -5,7 +5,7 @@ LL |     struct Priv;
    |     - `foo::Priv` declared as private
 ...
 LL |         pub(crate) fn g(_: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error[E0446]: private type `foo::Priv` in public interface
   --> $DIR/private-in-public.rs:9:9
@@ -14,7 +14,7 @@ LL |     struct Priv;
    |     - `foo::Priv` declared as private
 ...
 LL |         crate fn h(_: Priv) {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+   |         ^^^^^^^^^^^^^^^^^^^ can't leak private type
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/proc-macro/no-macro-use-attr.stderr b/src/test/ui/proc-macro/no-macro-use-attr.stderr
index 1831300a0d9..a9e5256a0a9 100644
--- a/src/test/ui/proc-macro/no-macro-use-attr.stderr
+++ b/src/test/ui/proc-macro/no-macro-use-attr.stderr
@@ -14,7 +14,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/no-macro-use-attr.rs:10:1
    |
 LL | fn main() {}
-   | ^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error; 1 warning emitted
 
diff --git a/src/test/ui/recursion/recursion.stderr b/src/test/ui/recursion/recursion.stderr
index 0c0eba68c83..db4c99eeb8b 100644
--- a/src/test/ui/recursion/recursion.stderr
+++ b/src/test/ui/recursion/recursion.stderr
@@ -7,13 +7,8 @@ LL |     _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tai
 note: `test` defined here
   --> $DIR/recursion.rs:15:1
    |
-LL | / fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
-LL | |   match n {    0 => {first.dot(second)}
-LL | |     _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
-LL | |
-LL | |   }
-LL | | }
-   | |_^
+LL | fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.stderr
index 1497c3ed925..3e196cf8f12 100644
--- a/src/test/ui/regions/regions-infer-paramd-indirect.stderr
+++ b/src/test/ui/regions/regions-infer-paramd-indirect.stderr
@@ -9,14 +9,8 @@ LL |         self.f = b;
 note: the anonymous lifetime #2 defined on the method body at 21:5...
   --> $DIR/regions-infer-paramd-indirect.rs:21:5
    |
-LL | /     fn set_f_bad(&mut self, b: Box<B>) {
-LL | |         self.f = b;
-LL | |
-LL | |
-LL | |
-LL | |
-LL | |     }
-   | |_____^
+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/regions/regions-normalize-in-where-clause-list.stderr b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
index dc93d620ca6..10ecb8d5262 100644
--- a/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
+++ b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
@@ -5,9 +5,7 @@ LL | / fn bar<'a, 'b>()
 LL | |
 LL | |
 LL | |     where <() as Project<'a, 'b>>::Item : Eq
-LL | | {
-LL | | }
-   | |_^
+   | |____________________________________________^
    |
 note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 22:8...
   --> $DIR/regions-normalize-in-where-clause-list.rs:22:8
@@ -26,9 +24,7 @@ LL | / fn bar<'a, 'b>()
 LL | |
 LL | |
 LL | |     where <() as Project<'a, 'b>>::Item : Eq
-LL | | {
-LL | | }
-   | |_^
+   | |____________________________________________^
    = note: expected `Project<'a, 'b>`
               found `Project<'_, '_>`
 
@@ -39,9 +35,7 @@ LL | / fn bar<'a, 'b>()
 LL | |
 LL | |
 LL | |     where <() as Project<'a, 'b>>::Item : Eq
-LL | | {
-LL | | }
-   | |_^
+   | |____________________________________________^
    |
 note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 22:8...
   --> $DIR/regions-normalize-in-where-clause-list.rs:22:8
@@ -60,9 +54,7 @@ LL | / fn bar<'a, 'b>()
 LL | |
 LL | |
 LL | |     where <() as Project<'a, 'b>>::Item : Eq
-LL | | {
-LL | | }
-   | |_^
+   | |____________________________________________^
    = note: expected `Project<'a, 'b>`
               found `Project<'_, '_>`
 
diff --git a/src/test/ui/regions/regions-trait-1.stderr b/src/test/ui/regions/regions-trait-1.stderr
index 60ac7c09f04..92d96a722d4 100644
--- a/src/test/ui/regions/regions-trait-1.stderr
+++ b/src/test/ui/regions/regions-trait-1.stderr
@@ -14,10 +14,8 @@ LL | impl<'a> GetCtxt for HasCtxt<'a> {
 note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 16:5
   --> $DIR/regions-trait-1.rs:16:5
    |
-LL | /     fn get_ctxt(&self) -> &'a Ctxt {
-LL | |         self.c
-LL | |     }
-   | |_____^
+LL |     fn get_ctxt(&self) -> &'a Ctxt {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfc-2091-track-caller/error-with-main.stderr b/src/test/ui/rfc-2091-track-caller/error-with-main.stderr
index f05f88e7d71..7e2ec352414 100644
--- a/src/test/ui/rfc-2091-track-caller/error-with-main.stderr
+++ b/src/test/ui/rfc-2091-track-caller/error-with-main.stderr
@@ -1,12 +1,10 @@
 error: `main` function is not allowed to be `#[track_caller]`
   --> $DIR/error-with-main.rs:1:1
    |
-LL |   #[track_caller]
-   |   ^^^^^^^^^^^^^^^
-LL | / fn main() {
-LL | |     panic!("{}: oh no", std::panic::Location::caller());
-LL | | }
-   | |_- `main` function is not allowed to be `#[track_caller]`
+LL | #[track_caller]
+   | ^^^^^^^^^^^^^^^
+LL | fn main() {
+   | --------- `main` function is not allowed to be `#[track_caller]`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfc-2091-track-caller/error-with-start.stderr b/src/test/ui/rfc-2091-track-caller/error-with-start.stderr
index 1a1f3e04491..454c98ff934 100644
--- a/src/test/ui/rfc-2091-track-caller/error-with-start.stderr
+++ b/src/test/ui/rfc-2091-track-caller/error-with-start.stderr
@@ -1,12 +1,10 @@
 error: `start` is not allowed to be `#[track_caller]`
   --> $DIR/error-with-start.rs:4:1
    |
-LL |   #[track_caller]
-   |   ^^^^^^^^^^^^^^^
-LL | / fn start(_argc: isize, _argv: *const *const u8) -> isize {
-LL | |     panic!("{}: oh no", std::panic::Location::caller());
-LL | | }
-   | |_- `start` is not allowed to be `#[track_caller]`
+LL | #[track_caller]
+   | ^^^^^^^^^^^^^^^
+LL | fn start(_argc: isize, _argv: *const *const u8) -> isize {
+   | -------------------------------------------------------- `start` is not allowed to be `#[track_caller]`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
index e4f4d4262b6..3994bd97c30 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/feature-gate.rs:16:1
    |
 LL | fn main() {}
-   | ^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr
index d1ab99e33e9..4c630d33c55 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr
@@ -2,7 +2,7 @@ error: fatal error triggered by #[rustc_error]
   --> $DIR/feature-gate.rs:14:1
    |
 LL | fn main() {}
-   | ^^^^^^^^^^^^
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfc1445/feature-gate.with_gate.stderr b/src/test/ui/rfc1445/feature-gate.with_gate.stderr
index fabbfd5c70b..623fd585acc 100644
--- a/src/test/ui/rfc1445/feature-gate.with_gate.stderr
+++ b/src/test/ui/rfc1445/feature-gate.with_gate.stderr
@@ -1,14 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/feature-gate.rs:21:1
    |
-LL | / fn main() {
-LL | |     let y = Foo { x: 1 };
-LL | |     match y {
-LL | |         FOO => { }
-LL | |         _ => { }
-LL | |     }
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr
index 413890f436d..18917fd2556 100644
--- a/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr
+++ b/src/test/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr
@@ -4,7 +4,7 @@ error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL | fn foo() {}
-   | ----------- not an `unsafe` function
+   | -------- not an `unsafe` function
    |
    = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
    = help: add `#![feature(target_feature_11)]` to the crate attributes to enable
diff --git a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr
index 3c56e0fc5c6..07d6e090059 100644
--- a/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr
+++ b/src/test/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr
@@ -5,7 +5,7 @@ LL |     #[target_feature(enable = "sse2")]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
 LL |
 LL |     fn foo(&self) {}
-   |     ---------------- not an `unsafe` function
+   |     ------------- not an `unsafe` function
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rustc-error.stderr b/src/test/ui/rustc-error.stderr
index 7dfc4449295..de27e9b8f08 100644
--- a/src/test/ui/rustc-error.stderr
+++ b/src/test/ui/rustc-error.stderr
@@ -1,10 +1,8 @@
 error: fatal error triggered by #[rustc_error]
   --> $DIR/rustc-error.rs:4:1
    |
-LL | / fn main() {
-LL | |
-LL | | }
-   | |_^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/specialization/specialization-overlap-hygiene.stderr b/src/test/ui/specialization/specialization-overlap-hygiene.stderr
index 6adf16de462..81efd46cc7f 100644
--- a/src/test/ui/specialization/specialization-overlap-hygiene.stderr
+++ b/src/test/ui/specialization/specialization-overlap-hygiene.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `f`
   --> $DIR/specialization-overlap-hygiene.rs:13:4
    |
 LL |     fn f() {}
-   |     --------- other definition for `f`
+   |     ------ other definition for `f`
 ...
 LL |    fn f() {}
-   |    ^^^^^^^^^ duplicate definitions for `f`
+   |    ^^^^^^ duplicate definitions for `f`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr b/src/test/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr
index f81c45e2f8d..6e4cee18c16 100644
--- a/src/test/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr
+++ b/src/test/ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.stderr
@@ -2,7 +2,7 @@ error[E0618]: expected function, found `bool`
   --> $DIR/issue-51055-missing-semicolon-between-call-and-tuple.rs:4:5
    |
 LL |   fn vindictive() -> bool { true }
-   |   -------------------------------- `vindictive` defined here returns `bool`
+   |   ----------------------- `vindictive` defined here returns `bool`
 ...
 LL |       vindictive()
    |       -^^^^^^^^^^^- help: try adding a semicolon: `;`
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 2072b00f7b2..1bfcdab5d86 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
@@ -32,10 +32,7 @@ LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
 LL | |
 LL | | where
 LL | |     G: Get<T>
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |_____________^
 
 error[E0311]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:47:45
@@ -50,10 +47,7 @@ LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
 LL | |
 LL | | where
 LL | |     G: Get<T>
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |_____________^
 
 error[E0311]: the parameter type `G` may not live long enough
   --> $DIR/missing-lifetimes-in-signature.rs:59:58
@@ -64,13 +58,8 @@ 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
    |
-LL | /     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
-LL | |
-LL | |         move || {
-LL | |             *dest = g.get();
-LL | |         }
-LL | |     }
-   | |_____^
+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
@@ -85,10 +74,7 @@ LL | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
 LL | |
 LL | | where
 LL | |     G: Get<T>
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |_____________^
 
 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 d7051515f11..cec01fefca8 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -40,10 +40,7 @@ LL | / fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
 LL | |
 LL | | where
 LL | |     G: Get<T>
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |_____________^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:30:5: 32:6 g:G, dest:&mut T]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:25:37
    |
@@ -67,10 +64,7 @@ LL | / fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
 LL | |
 LL | | where
 LL | |     G: Get<T>
-...  |
-LL | |     }
-LL | | }
-   | |_^
+   | |_____________^
 note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:52:5: 54:6 g:G, dest:&mut T]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:47:45
    |
@@ -90,13 +84,8 @@ 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
    |
-LL | /     fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ {
-LL | |
-LL | |         move || {
-LL | |             *dest = g.get();
-LL | |         }
-LL | |     }
-   | |_____^
+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 g:G, dest:&mut T]` will meet its required lifetime bounds
   --> $DIR/missing-lifetimes-in-signature.rs:59:58
    |
diff --git a/src/test/ui/target-feature/invalid-attribute.stderr b/src/test/ui/target-feature/invalid-attribute.stderr
index f3995f118d3..3d629afb9a6 100644
--- a/src/test/ui/target-feature/invalid-attribute.stderr
+++ b/src/test/ui/target-feature/invalid-attribute.stderr
@@ -29,7 +29,7 @@ LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL | fn bar() {}
-   | ----------- not an `unsafe` function
+   | -------- not an `unsafe` function
    |
    = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
    = help: add `#![feature(target_feature_11)]` to the crate attributes to enable
@@ -113,7 +113,7 @@ LL |     #[target_feature(enable = "sse2")]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL |     fn foo() {}
-   |     ----------- not an `unsafe` function
+   |     -------- not an `unsafe` function
    |
    = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
    = help: add `#![feature(target_feature_11)]` to the crate attributes to enable
diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
index 2570db0212a..d10e58629cc 100644
--- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
+++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
@@ -2,10 +2,10 @@ error[E0592]: duplicate definitions with name `test`
   --> $DIR/trait-object-auto-dedup-in-impl.rs:14:5
    |
 LL |     fn test(&self) { println!("one"); }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `test`
+   |     ^^^^^^^^^^^^^^ duplicate definitions for `test`
 ...
 LL |     fn test(&self) { println!("two"); }
-   |     ----------------------------------- other definition for `test`
+   |     -------------- other definition for `test`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr
index 87ed997ec59..eaa716bc71c 100644
--- a/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses.stderr
@@ -1,18 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/different_defining_uses.rs:12:1
    |
-LL | / fn bar() -> Foo {
-LL | |     42i32
-LL | | }
-   | |_^ expected `&'static str`, got `i32`
+LL | fn bar() -> Foo {
+   | ^^^^^^^^^^^^^^^ expected `&'static str`, got `i32`
    |
 note: previous use here
   --> $DIR/different_defining_uses.rs:8:1
    |
-LL | / fn foo() -> Foo {
-LL | |     ""
-LL | | }
-   | |_^
+LL | fn foo() -> Foo {
+   | ^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
index 5be656e8f44..9a587e4f06e 100644
--- a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
@@ -1,34 +1,26 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/different_defining_uses_never_type.rs:12:1
    |
-LL | / fn bar() -> Foo {
-LL | |     panic!()
-LL | | }
-   | |_^ expected `&'static str`, got `()`
+LL | fn bar() -> Foo {
+   | ^^^^^^^^^^^^^^^ expected `&'static str`, got `()`
    |
 note: previous use here
   --> $DIR/different_defining_uses_never_type.rs:8:1
    |
-LL | / fn foo() -> Foo {
-LL | |     ""
-LL | | }
-   | |_^
+LL | fn foo() -> Foo {
+   | ^^^^^^^^^^^^^^^
 
 error: concrete type differs from previous defining opaque type use
   --> $DIR/different_defining_uses_never_type.rs:16:1
    |
-LL | / fn boo() -> Foo {
-LL | |     loop {}
-LL | | }
-   | |_^ expected `&'static str`, got `()`
+LL | fn boo() -> Foo {
+   | ^^^^^^^^^^^^^^^ expected `&'static str`, got `()`
    |
 note: previous use here
   --> $DIR/different_defining_uses_never_type.rs:8:1
    |
-LL | / fn foo() -> Foo {
-LL | |     ""
-LL | | }
-   | |_^
+LL | fn foo() -> Foo {
+   | ^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
index 4bcd2e1cb12..f8a058170e3 100644
--- a/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
@@ -1,18 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_different_defining_uses.rs:11:1
    |
-LL | / fn my_iter2<T>(t: T) -> MyIter<T> {
-LL | |     Some(t).into_iter()
-LL | | }
-   | |_^ expected `std::iter::Once<T>`, got `std::option::IntoIter<T>`
+LL | fn my_iter2<T>(t: T) -> MyIter<T> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `std::iter::Once<T>`, got `std::option::IntoIter<T>`
    |
 note: previous use here
   --> $DIR/generic_different_defining_uses.rs:7:1
    |
-LL | / fn my_iter<T>(t: T) -> MyIter<T> {
-LL | |     std::iter::once(t)
-LL | | }
-   | |_^
+LL | fn my_iter<T>(t: T) -> MyIter<T> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
index 8170c671f68..7900da47ca2 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
@@ -1,19 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use2.rs:14:1
    |
-LL | / fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
-LL | |
-LL | |     t
-LL | | }
-   | |_^ expected `U`, got `T`
+LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `U`, got `T`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use2.rs:10:1
    |
-LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
-LL | |     t
-LL | | }
-   | |_^
+LL | fn one<T: Debug>(t: T) -> Two<T, T> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr
index 86dd3368400..ac5f7947d51 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr
@@ -1,19 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use3.rs:14:1
    |
-LL | / fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
-LL | |
-LL | |     t
-LL | | }
-   | |_^ expected `U`, got `T`
+LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `U`, got `T`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use3.rs:10:1
    |
-LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
-LL | |     t
-LL | | }
-   | |_^
+LL | fn one<T: Debug>(t: T) -> Two<T, T> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
index 589ea749319..1ddbc0c8d6a 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
@@ -1,19 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use5.rs:14:1
    |
-LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |
-LL | |     (u, t)
-LL | | }
-   | |_^ expected `(T, U)`, got `(U, T)`
+LL | fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, U)`, got `(U, T)`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use5.rs:10:1
    |
-LL | / fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |     (t, u)
-LL | | }
-   | |_^
+LL | fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
index 7e81d362661..ebd07b7c300 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
@@ -1,19 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use6.rs:14:1
    |
-LL | / fn three<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |
-LL | |     (u, t)
-LL | | }
-   | |_^ expected `(T, T)`, got `(U, T)`
+LL | fn three<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, T)`, got `(U, T)`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use6.rs:10:1
    |
-LL | / fn two<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |     (t, t)
-LL | | }
-   | |_^
+LL | fn two<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
index 8f4cf4c6084..4778ee5155c 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
@@ -1,19 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use8.rs:13:1
    |
-LL | / fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
-LL | |
-LL | |     (u, 4u32)
-LL | | }
-   | |_^ expected `(T, u32)`, got `(U, u32)`
+LL | fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, u32)`, got `(U, u32)`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use8.rs:9:1
    |
-LL | / fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
-LL | |     (t, 4u32)
-LL | | }
-   | |_^
+LL | fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
index 4d0b03ba5ed..247b042f61e 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
@@ -1,18 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/generic_duplicate_param_use9.rs:18:1
    |
-LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |     (t, u, 42)
-LL | | }
-   | |_^ expected `(A, B, <A as Foo>::Bar)`, got `(A, B, i32)`
+LL | fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(A, B, <A as Foo>::Bar)`, got `(A, B, i32)`
    |
 note: previous use here
   --> $DIR/generic_duplicate_param_use9.rs:14:1
    |
-LL | / fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> {
-LL | |     (t, u, T::BAR)
-LL | | }
-   | |_^
+LL | fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
index 1333b4c63d1..13069126bab 100644
--- a/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
@@ -8,7 +8,7 @@ note: previous use here
   --> $DIR/issue-52843-closure-constrain.rs:9:5
    |
 LL |     fn _unused() -> Opaque { String::new() }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
index cce861b76c9..9ce07a879f0 100644
--- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
+++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
@@ -1,18 +1,14 @@
 error: concrete type differs from previous defining opaque type use
   --> $DIR/not_a_defining_use.rs:29:1
    |
-LL | / fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> {
-LL | |     (t, <U as Bar>::FOO)
-LL | | }
-   | |_^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)`
+LL | fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)`
    |
 note: previous use here
   --> $DIR/not_a_defining_use.rs:9:1
    |
-LL | / fn two<T: Debug>(t: T) -> Two<T, u32> {
-LL | |     (t, 4i8)
-LL | | }
-   | |_^
+LL | fn two<T: Debug>(t: T) -> Two<T, u32> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
index d1232ad3f32..d7c48173571 100644
--- a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
+++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
@@ -37,7 +37,7 @@ note: the anonymous lifetime #1 defined on the method body at 37:5...
   --> $DIR/ufcs-explicit-self-bad.rs:37:5
    |
 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
    |
@@ -61,7 +61,7 @@ note: ...does not necessarily outlive the anonymous lifetime #1 defined on the m
   --> $DIR/ufcs-explicit-self-bad.rs:37:5
    |
 LL |     fn dummy2(self: &Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched `self` parameter type
   --> $DIR/ufcs-explicit-self-bad.rs:39:21
@@ -75,7 +75,7 @@ note: the anonymous lifetime #2 defined on the method body at 39:5...
   --> $DIR/ufcs-explicit-self-bad.rs:39:5
    |
 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
    |
@@ -99,7 +99,7 @@ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the m
   --> $DIR/ufcs-explicit-self-bad.rs:39:5
    |
 LL |     fn dummy3(self: &&Bar<T>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 7 previous errors