about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_interface/src/passes.rs6
-rw-r--r--compiler/rustc_interface/src/tests.rs2
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs4
-rw-r--r--compiler/rustc_middle/src/query/mod.rs9
-rw-r--r--compiler/rustc_mir_build/src/check_unsafety.rs9
-rw-r--r--compiler/rustc_mir_build/src/lib.rs2
-rw-r--r--compiler/rustc_mir_transform/src/check_unsafety.rs11
-rw-r--r--compiler/rustc_mir_transform/src/lib.rs4
-rw-r--r--compiler/rustc_session/src/options.rs4
-rw-r--r--src/tools/tidy/src/ui_tests.rs2
-rw-r--r--tests/ui/async-await/async-unsafe-fn-call-in-safe.rs8
-rw-r--r--tests/ui/async-await/async-unsafe-fn-call-in-safe.stderr8
-rw-r--r--tests/ui/binding/issue-53114-safety-checks.stderr144
-rw-r--r--tests/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr2
-rw-r--r--tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs8
-rw-r--r--tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr8
-rw-r--r--tests/ui/consts/issue-16538.stderr18
-rw-r--r--tests/ui/coroutine/issue-45729-unsafe-in-coroutine.stderr2
-rw-r--r--tests/ui/error-codes/E0133.stderr2
-rw-r--r--tests/ui/extern/issue-28324.stderr4
-rw-r--r--tests/ui/inline-const/expr-unsafe-err.stderr2
-rw-r--r--tests/ui/intrinsics/unchecked_math_unsafe.stderr6
-rw-r--r--tests/ui/issues/issue-28776.stderr2
-rw-r--r--tests/ui/issues/issue-5844.stderr2
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.rs5
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr25
-rw-r--r--tests/ui/pattern/usefulness/issue-57472.rs12
-rw-r--r--tests/ui/pattern/usefulness/issue-57472.stderr6
-rw-r--r--tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs24
-rw-r--r--tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr24
-rw-r--r--tests/ui/static/safe-extern-statics-mut.stderr8
-rw-r--r--tests/ui/static/safe-extern-statics.stderr8
-rw-r--r--tests/ui/static/static-mut-foreign-requires-unsafe.stderr4
-rw-r--r--tests/ui/static/static-mut-requires-unsafe.stderr4
-rw-r--r--tests/ui/thread-local/thread-local-static.stderr16
-rw-r--r--tests/ui/threads-sendsync/issue-43733.rs4
-rw-r--r--tests/ui/threads-sendsync/issue-43733.stderr4
-rw-r--r--tests/ui/traits/safety-fn-body.stderr2
-rw-r--r--tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr5
-rw-r--r--tests/ui/union/union-unsafe.stderr12
-rw-r--r--tests/ui/union/union-unsized.stderr14
-rw-r--r--tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.rs2
-rw-r--r--tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr2
-rw-r--r--tests/ui/unsafe/foreign-unsafe-fn-called.rs2
-rw-r--r--tests/ui/unsafe/foreign-unsafe-fn-called.stderr2
-rw-r--r--tests/ui/unsafe/issue-3080.stderr2
-rw-r--r--tests/ui/unsafe/issue-45087-unreachable-unsafe.stderr6
-rw-r--r--tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.stderr6
-rw-r--r--tests/ui/unsafe/ranged_ints2_const.stderr16
-rw-r--r--tests/ui/unsafe/ranged_ints3_const.stderr16
-rw-r--r--tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs8
-rw-r--r--tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr12
-rw-r--r--tests/ui/unsafe/union-assignop.stderr2
-rw-r--r--tests/ui/unsafe/union.rs9
-rw-r--r--tests/ui/unsafe/union.stderr27
-rw-r--r--tests/ui/unsafe/union_destructure.rs12
-rw-r--r--tests/ui/unsafe/union_destructure.stderr16
-rw-r--r--tests/ui/unsafe/unsafe-const-fn.stderr2
-rw-r--r--tests/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr2
-rw-r--r--tests/ui/unsafe/unsafe-fn-called-from-safe.rs6
-rw-r--r--tests/ui/unsafe/unsafe-fn-called-from-safe.stderr4
-rw-r--r--tests/ui/unsafe/unsafe-fn-used-as-value.rs6
-rw-r--r--tests/ui/unsafe/unsafe-fn-used-as-value.stderr4
-rw-r--r--tests/ui/unsafe/unsafe-not-inherited.stderr2
-rw-r--r--tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed8
-rw-r--r--tests/ui/unsafe/wrapping-unsafe-block-sugg.rs8
-rw-r--r--tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr8
67 files changed, 307 insertions, 329 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 559874641c3..ce76c2cba93 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -735,9 +735,9 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
 
     sess.time("MIR_borrow_checking", || {
         tcx.hir().par_body_owners(|def_id| {
-            // Run THIR unsafety check because it's responsible for stealing
-            // and deallocating THIR when enabled.
-            tcx.ensure().thir_check_unsafety(def_id);
+            // Run unsafety check because it's responsible for stealing and
+            // deallocating THIR.
+            tcx.ensure().check_unsafety(def_id);
             tcx.ensure().mir_borrowck(def_id)
         });
     });
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs
index c4a1f3a0e51..75410db1e36 100644
--- a/compiler/rustc_interface/src/tests.rs
+++ b/compiler/rustc_interface/src/tests.rs
@@ -822,7 +822,7 @@ fn test_unstable_options_tracking_hash() {
     tracked!(stack_protector, StackProtector::All);
     tracked!(teach, true);
     tracked!(thinlto, Some(true));
-    tracked!(thir_unsafeck, true);
+    tracked!(thir_unsafeck, false);
     tracked!(tiny_const_eval_limit, true);
     tracked!(tls_model, Some(TlsModel::GeneralDynamic));
     tracked!(translate_remapped_path_to_local_path, false);
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 5c425fef27e..0a1a72b442a 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -720,7 +720,7 @@ pub struct SourceInfo {
     pub span: Span,
 
     /// The source scope, keeping track of which bindings can be
-    /// seen by debuginfo, active lint levels, `unsafe {...}`, etc.
+    /// seen by debuginfo, active lint levels, etc.
     pub scope: SourceScope,
 }
 
@@ -942,7 +942,7 @@ pub struct LocalDecl<'tcx> {
 
 /// Extra information about a some locals that's used for diagnostics and for
 /// classifying variables into local variables, statics, etc, which is needed e.g.
-/// for unsafety checking.
+/// for borrow checking.
 ///
 /// Not used for non-StaticRef temporaries, the return place, or anonymous
 /// function parameters.
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 2810182c0a0..bf5e59ba78d 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -869,15 +869,14 @@ rustc_queries! {
         desc { |tcx| "collecting all inherent impls for `{:?}`", key }
     }
 
-    /// The result of unsafety-checking this `LocalDefId`.
-    query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
+    /// The result of unsafety-checking this `LocalDefId` with the old checker.
+    query mir_unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
         desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
         cache_on_disk_if { true }
     }
 
-    /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
-    /// used with `-Zthir-unsafeck`.
-    query thir_check_unsafety(key: LocalDefId) {
+    /// Unsafety-check this `LocalDefId`.
+    query check_unsafety(key: LocalDefId) {
         desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
         cache_on_disk_if { true }
     }
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
index 2e8b6c19ec7..7d0ce53997a 100644
--- a/compiler/rustc_mir_build/src/check_unsafety.rs
+++ b/compiler/rustc_mir_build/src/check_unsafety.rs
@@ -14,7 +14,7 @@ use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
 use rustc_session::lint::Level;
 use rustc_span::def_id::{DefId, LocalDefId};
 use rustc_span::symbol::Symbol;
-use rustc_span::Span;
+use rustc_span::{sym, Span};
 
 use std::mem;
 use std::ops::Bound;
@@ -886,14 +886,15 @@ impl UnsafeOpKind {
     }
 }
 
-pub fn thir_check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
-    // THIR unsafeck is gated under `-Z thir-unsafeck`
+pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
+    // THIR unsafeck can be disabled with `-Z thir-unsafeck=off`
     if !tcx.sess.opts.unstable_opts.thir_unsafeck {
         return;
     }
 
     // Closures and inline consts are handled by their owner, if it has a body
-    if tcx.is_typeck_child(def.to_def_id()) {
+    // Also, don't safety check custom MIR
+    if tcx.is_typeck_child(def.to_def_id()) || tcx.has_attr(def, sym::custom_mir) {
         return;
     }
 
diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs
index a776e917de5..430c4ee3da7 100644
--- a/compiler/rustc_mir_build/src/lib.rs
+++ b/compiler/rustc_mir_build/src/lib.rs
@@ -31,7 +31,7 @@ pub fn provide(providers: &mut Providers) {
     providers.mir_built = build::mir_built;
     providers.closure_saved_names_of_captured_variables =
         build::closure_saved_names_of_captured_variables;
-    providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
+    providers.check_unsafety = check_unsafety::check_unsafety;
     providers.thir_body = thir::cx::thir_body;
     providers.thir_tree = thir::print::thir_tree;
     providers.thir_flat = thir::print::thir_flat;
diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs
index d94d96c1115..582c2c0c6b6 100644
--- a/compiler/rustc_mir_transform/src/check_unsafety.rs
+++ b/compiler/rustc_mir_transform/src/check_unsafety.rs
@@ -131,7 +131,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
                 &AggregateKind::Closure(def_id, _) | &AggregateKind::Coroutine(def_id, _) => {
                     let def_id = def_id.expect_local();
                     let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
-                        self.tcx.unsafety_check_result(def_id);
+                        self.tcx.mir_unsafety_check_result(def_id);
                     self.register_violations(violations, used_unsafe_blocks.items().copied());
                 }
             },
@@ -153,7 +153,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
                     if self.tcx.def_kind(def_id) == DefKind::InlineConst {
                         let local_def_id = def_id.expect_local();
                         let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
-                            self.tcx.unsafety_check_result(local_def_id);
+                            self.tcx.mir_unsafety_check_result(local_def_id);
                         self.register_violations(violations, used_unsafe_blocks.items().copied());
                     }
                 }
@@ -390,7 +390,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
 }
 
 pub(crate) fn provide(providers: &mut Providers) {
-    *providers = Providers { unsafety_check_result, ..*providers };
+    *providers = Providers { mir_unsafety_check_result, ..*providers };
 }
 
 /// Context information for [`UnusedUnsafeVisitor`] traversal,
@@ -490,7 +490,7 @@ fn check_unused_unsafe(
     unused_unsafes
 }
 
-fn unsafety_check_result(tcx: TyCtxt<'_>, def: LocalDefId) -> &UnsafetyCheckResult {
+fn mir_unsafety_check_result(tcx: TyCtxt<'_>, def: LocalDefId) -> &UnsafetyCheckResult {
     debug!("unsafety_violations({:?})", def);
 
     // N.B., this borrow is valid because all the consumers of
@@ -538,7 +538,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
         return;
     }
 
-    let UnsafetyCheckResult { violations, unused_unsafes, .. } = tcx.unsafety_check_result(def_id);
+    let UnsafetyCheckResult { violations, unused_unsafes, .. } =
+        tcx.mir_unsafety_check_result(def_id);
     // Only suggest wrapping the entire function body in an unsafe block once
     let mut suggest_unsafe_block = true;
 
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index 5562ae7f3bd..164b6b9c4f5 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -285,9 +285,9 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
 /// FIXME(oli-obk): it's unclear whether we still need this phase (and its corresponding query).
 /// We used to have this for pre-miri MIR based const eval.
 fn mir_const(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal<Body<'_>> {
-    // Unsafety check uses the raw mir, so make sure it is run.
+    // MIR unsafety check uses the raw mir, so make sure it is run.
     if !tcx.sess.opts.unstable_opts.thir_unsafeck {
-        tcx.ensure_with_value().unsafety_check_result(def);
+        tcx.ensure_with_value().mir_unsafety_check_result(def);
     }
 
     // has_ffi_unwind_calls query uses the raw mir, so make sure it is run.
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 8274fd05bc0..0b0b67ef890 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1919,8 +1919,8 @@ written to standard error output)"),
     #[rustc_lint_opt_deny_field_access("use `Session::lto` instead of this field")]
     thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "enable ThinLTO when possible"),
-    thir_unsafeck: bool = (false, parse_bool, [TRACKED],
-        "use the THIR unsafety checker (default: no)"),
+    thir_unsafeck: bool = (true, parse_bool, [TRACKED],
+        "use the THIR unsafety checker (default: yes)"),
     /// We default to 1 here since we want to behave like
     /// a sequential compiler for now. This'll likely be adjusted
     /// in the future. Note that -Zthreads=0 is the way to get
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index dfa386b49de..b4745d4883c 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
 
 const ENTRY_LIMIT: usize = 900;
 // FIXME: The following limits should be reduced eventually.
-const ISSUES_ENTRY_LIMIT: usize = 1852;
+const ISSUES_ENTRY_LIMIT: usize = 1849;
 const ROOT_ENTRY_LIMIT: usize = 867;
 
 const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
diff --git a/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs b/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
index f7e9e96bff7..7695853000d 100644
--- a/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
+++ b/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
@@ -10,14 +10,14 @@ async unsafe fn f() {}
 
 async fn g() {
     S::f();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `S::f` is unsafe
     f();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `f` is unsafe
 }
 
 fn main() {
     S::f();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `S::f` is unsafe
     f();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `f` is unsafe
 }
diff --git a/tests/ui/async-await/async-unsafe-fn-call-in-safe.stderr b/tests/ui/async-await/async-unsafe-fn-call-in-safe.stderr
index 89c496c598d..b25794c0892 100644
--- a/tests/ui/async-await/async-unsafe-fn-call-in-safe.stderr
+++ b/tests/ui/async-await/async-unsafe-fn-call-in-safe.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
   --> $DIR/async-unsafe-fn-call-in-safe.rs:12:5
    |
 LL |     S::f();
@@ -6,7 +6,7 @@ LL |     S::f();
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
   --> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
    |
 LL |     f();
@@ -14,7 +14,7 @@ LL |     f();
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
   --> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
    |
 LL |     S::f();
@@ -22,7 +22,7 @@ LL |     S::f();
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
   --> $DIR/async-unsafe-fn-call-in-safe.rs:21:5
    |
 LL |     f();
diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr
index 349c4639a9e..b7d805d9171 100644
--- a/tests/ui/binding/issue-53114-safety-checks.stderr
+++ b/tests/ui/binding/issue-53114-safety-checks.stderr
@@ -1,63 +1,3 @@
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:23:13
-   |
-LL |     let _ = &p.b;
-   |             ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:28:17
-   |
-LL |     let (_,) = (&p.b,);
-   |                 ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:37:16
-   |
-LL |     let _: _ = &p.b;
-   |                ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:42:20
-   |
-LL |     let (_,): _ = (&p.b,);
-   |                    ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:51:11
-   |
-LL |     match &p.b  { _ => { } }
-   |           ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
-error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:56:12
-   |
-LL |     match (&p.b,)  { (_,) => { } }
-   |            ^^^^
-   |
-   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
-   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
-
 error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:24:13
    |
@@ -67,10 +7,10 @@ LL |     let _ = u1.a;
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:25:13
+  --> $DIR/issue-53114-safety-checks.rs:25:14
    |
 LL |     let _ = &u2.a;
-   |             ^^^^^ access to union field
+   |              ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
@@ -83,13 +23,33 @@ LL |     let (_,) = (u1.a,);
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:30:17
+  --> $DIR/issue-53114-safety-checks.rs:30:18
    |
 LL |     let (_,) = (&u2.a,);
-   |                 ^^^^^ access to union field
+   |                  ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:23:13
+   |
+LL |     let _ = &p.b;
+   |             ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:28:17
+   |
+LL |     let (_,) = (&p.b,);
+   |                 ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
 error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:38:16
    |
@@ -99,10 +59,10 @@ LL |     let _: _ = u1.a;
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:39:16
+  --> $DIR/issue-53114-safety-checks.rs:39:17
    |
 LL |     let _: _ = &u2.a;
-   |                ^^^^^ access to union field
+   |                 ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
@@ -115,13 +75,33 @@ LL |     let (_,): _ = (u1.a,);
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:44:20
+  --> $DIR/issue-53114-safety-checks.rs:44:21
    |
 LL |     let (_,): _ = (&u2.a,);
-   |                    ^^^^^ access to union field
+   |                     ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:37:16
+   |
+LL |     let _: _ = &p.b;
+   |                ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:42:20
+   |
+LL |     let (_,): _ = (&p.b,);
+   |                    ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
 error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:52:11
    |
@@ -131,10 +111,10 @@ LL |     match u1.a  { _ => { } }
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:53:11
+  --> $DIR/issue-53114-safety-checks.rs:53:12
    |
 LL |     match &u2.a { _ => { } }
-   |           ^^^^^ access to union field
+   |            ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
@@ -147,13 +127,33 @@ LL |     match (u1.a,)  { (_,) => { } }
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:58:12
+  --> $DIR/issue-53114-safety-checks.rs:58:13
    |
 LL |     match (&u2.a,) { (_,) => { } }
-   |            ^^^^^ access to union field
+   |             ^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:51:11
+   |
+LL |     match &p.b  { _ => { } }
+   |           ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
+error[E0793]: reference to packed field is unaligned
+  --> $DIR/issue-53114-safety-checks.rs:56:12
+   |
+LL |     match (&p.b,)  { (_,) => { } }
+   |            ^^^^
+   |
+   = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
+   = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
+   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
+
 error: aborting due to 18 previous errors
 
 Some errors have detailed explanations: E0133, E0793.
diff --git a/tests/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr b/tests/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr
index 75c379c88e3..f5cb3e2b5f8 100644
--- a/tests/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr
+++ b/tests/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `Pin::<P>::new_unchecked` is unsafe and requires unsafe function or block
   --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31
    |
 LL |     let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
index 896d4b376fd..95fb9ef4260 100644
--- a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
+++ b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
@@ -1,10 +1,12 @@
 #![feature(const_extern_fn)]
 
-const unsafe extern "C" fn foo() -> usize { 5 }
+const unsafe extern "C" fn foo() -> usize {
+    5
+}
 
 fn main() {
     let a: [u8; foo()];
-    //~^ call to unsafe function is unsafe and requires unsafe function or block
+    //~^ call to unsafe function `foo` is unsafe and requires unsafe function or block
     foo();
-    //~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
+    //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
 }
diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr
index 5196b8ee0a2..6f59b2f2055 100644
--- a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr
+++ b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr
@@ -1,13 +1,13 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/const-extern-fn-requires-unsafe.rs:8:5
+error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:10:5
    |
 LL |     foo();
    |     ^^^^^ call to unsafe function
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/const-extern-fn-requires-unsafe.rs:6:17
+error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:8:17
    |
 LL |     let a: [u8; foo()];
    |                 ^^^^^ call to unsafe function
diff --git a/tests/ui/consts/issue-16538.stderr b/tests/ui/consts/issue-16538.stderr
index afb344f5e85..834ffa8d3a0 100644
--- a/tests/ui/consts/issue-16538.stderr
+++ b/tests/ui/consts/issue-16538.stderr
@@ -1,11 +1,10 @@
-error[E0015]: cannot call non-const fn `Y::foo` in statics
-  --> $DIR/issue-16538.rs:11:23
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+  --> $DIR/issue-16538.rs:11:22
    |
 LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
-   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
    |
-   = note: calls in statics are limited to constant functions, tuple structs and tuple variants
-   = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
+   = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
 error[E0133]: use of extern static is unsafe and requires unsafe function or block
   --> $DIR/issue-16538.rs:11:30
@@ -15,13 +14,14 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
    |
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
-error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/issue-16538.rs:11:21
+error[E0015]: cannot call non-const fn `Y::foo` in statics
+  --> $DIR/issue-16538.rs:11:23
    |
 LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+   = note: calls in statics are limited to constant functions, tuple structs and tuple variants
+   = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.stderr b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.stderr
index d0f200b8360..19949b42939 100644
--- a/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.stderr
+++ b/tests/ui/coroutine/issue-45729-unsafe-in-coroutine.stderr
@@ -2,7 +2,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/issue-45729-unsafe-in-coroutine.rs:5:9
    |
 LL |         *(1 as *mut u32) = 42;
-   |         ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
+   |         ^^^^^^^^^^^^^^^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
diff --git a/tests/ui/error-codes/E0133.stderr b/tests/ui/error-codes/E0133.stderr
index a1ae6cb7fc9..5e3e49fb644 100644
--- a/tests/ui/error-codes/E0133.stderr
+++ b/tests/ui/error-codes/E0133.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
   --> $DIR/E0133.rs:4:5
    |
 LL |     f();
diff --git a/tests/ui/extern/issue-28324.stderr b/tests/ui/extern/issue-28324.stderr
index be748b47d4d..94ff2131993 100644
--- a/tests/ui/extern/issue-28324.stderr
+++ b/tests/ui/extern/issue-28324.stderr
@@ -1,8 +1,8 @@
 error[E0133]: use of extern static is unsafe and requires unsafe function or block
-  --> $DIR/issue-28324.rs:5:24
+  --> $DIR/issue-28324.rs:5:25
    |
 LL | pub static BAZ: u32 = *&error_message_count;
-   |                        ^^^^^^^^^^^^^^^^^^^^ use of extern static
+   |                         ^^^^^^^^^^^^^^^^^^^ use of extern static
    |
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
diff --git a/tests/ui/inline-const/expr-unsafe-err.stderr b/tests/ui/inline-const/expr-unsafe-err.stderr
index ebd18f89d9c..45f850d1f99 100644
--- a/tests/ui/inline-const/expr-unsafe-err.stderr
+++ b/tests/ui/inline-const/expr-unsafe-err.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
   --> $DIR/expr-unsafe-err.rs:8:9
    |
 LL |         require_unsafe();
diff --git a/tests/ui/intrinsics/unchecked_math_unsafe.stderr b/tests/ui/intrinsics/unchecked_math_unsafe.stderr
index 4066cf8efb8..31da1a86ca1 100644
--- a/tests/ui/intrinsics/unchecked_math_unsafe.stderr
+++ b/tests/ui/intrinsics/unchecked_math_unsafe.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `unchecked_add` is unsafe and requires unsafe function or block
   --> $DIR/unchecked_math_unsafe.rs:5:15
    |
 LL |     let add = std::intrinsics::unchecked_add(x, y);
@@ -6,7 +6,7 @@ LL |     let add = std::intrinsics::unchecked_add(x, y);
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `unchecked_sub` is unsafe and requires unsafe function or block
   --> $DIR/unchecked_math_unsafe.rs:6:15
    |
 LL |     let sub = std::intrinsics::unchecked_sub(x, y);
@@ -14,7 +14,7 @@ LL |     let sub = std::intrinsics::unchecked_sub(x, y);
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `unchecked_mul` is unsafe and requires unsafe function or block
   --> $DIR/unchecked_math_unsafe.rs:7:15
    |
 LL |     let mul = std::intrinsics::unchecked_mul(x, y);
diff --git a/tests/ui/issues/issue-28776.stderr b/tests/ui/issues/issue-28776.stderr
index 9f0f10335ab..3db94ee1810 100644
--- a/tests/ui/issues/issue-28776.stderr
+++ b/tests/ui/issues/issue-28776.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires unsafe function or block
   --> $DIR/issue-28776.rs:4:5
    |
 LL |     (&ptr::write)(1 as *mut _, 42);
diff --git a/tests/ui/issues/issue-5844.stderr b/tests/ui/issues/issue-5844.stderr
index af7bfb03320..bae917fa72c 100644
--- a/tests/ui/issues/issue-5844.stderr
+++ b/tests/ui/issues/issue-5844.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block
   --> $DIR/issue-5844.rs:6:5
    |
 LL |     issue_5844_aux::rand();
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
index b0b6b318d8f..782c38200a0 100644
--- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
@@ -6,10 +6,9 @@ use std::future::Future;
 async fn wrapper<F>(f: F)
 //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 where
-    F:,
-    for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+F:,
+for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
 {
     //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
     let mut i = 41;
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
index 5b77051dc88..89ebdb57f3c 100644
--- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
@@ -4,11 +4,10 @@ error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 LL | / async fn wrapper<F>(f: F)
 LL | |
 LL | |
-LL | |
 LL | | where
-LL | |     F:,
-LL | |     for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
-   | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+LL | | F:,
+LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+   | |__________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
    |
    = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
 
@@ -21,7 +20,7 @@ LL | async fn wrapper<F>(f: F)
    = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
 
 error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-  --> $DIR/issue-76168-hr-outlives-3.rs:13:1
+  --> $DIR/issue-76168-hr-outlives-3.rs:12:1
    |
 LL | / {
 LL | |
@@ -32,20 +31,6 @@ LL | | }
    |
    = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
 
-error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-  --> $DIR/issue-76168-hr-outlives-3.rs:6:1
-   |
-LL | / async fn wrapper<F>(f: F)
-LL | |
-LL | |
-LL | |
-LL | | where
-LL | |     F:,
-LL | |     for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
-   | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
-   |
-   = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/pattern/usefulness/issue-57472.rs b/tests/ui/pattern/usefulness/issue-57472.rs
index 1131006374c..17c252de2be 100644
--- a/tests/ui/pattern/usefulness/issue-57472.rs
+++ b/tests/ui/pattern/usefulness/issue-57472.rs
@@ -1,4 +1,4 @@
-#![crate_type="lib"]
+#![crate_type = "lib"]
 #![deny(unreachable_patterns)]
 
 mod test_struct {
@@ -26,10 +26,12 @@ mod test_union {
     }
 
     pub fn test(punned: Punned) {
-        match punned {
-            Punned { foo: [_] } => println!("foo"),
-            Punned { bar: [_] } => println!("bar"),
-            //~^ ERROR unreachable pattern [unreachable_patterns]
+        unsafe {
+            match punned {
+                Punned { foo: [_] } => println!("foo"),
+                Punned { bar: [_] } => println!("bar"),
+                //~^ ERROR unreachable pattern [unreachable_patterns]
+            }
         }
     }
 }
diff --git a/tests/ui/pattern/usefulness/issue-57472.stderr b/tests/ui/pattern/usefulness/issue-57472.stderr
index 26efdf6dbaf..c814eaec0d1 100644
--- a/tests/ui/pattern/usefulness/issue-57472.stderr
+++ b/tests/ui/pattern/usefulness/issue-57472.stderr
@@ -11,10 +11,10 @@ LL | #![deny(unreachable_patterns)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/issue-57472.rs:31:13
+  --> $DIR/issue-57472.rs:32:17
    |
-LL |             Punned { bar: [_] } => println!("bar"),
-   |             ^^^^^^^^^^^^^^^^^^^
+LL |                 Punned { bar: [_] } => println!("bar"),
+   |                 ^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs
index b420d14d1e1..788c79adc1f 100644
--- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs
+++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs
@@ -23,50 +23,50 @@ impl Quux {
 
 fn foo() {
     sse2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
     avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
     Quux.avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
 }
 
 #[target_feature(enable = "sse2")]
 fn bar() {
     avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
     Quux.avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
 }
 
 #[target_feature(enable = "avx")]
 fn baz() {
     sse2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
     avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
     Quux.avx_bmi2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
 }
 
 #[target_feature(enable = "avx")]
 #[target_feature(enable = "bmi2")]
 fn qux() {
     sse2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
 }
 
 const _: () = sse2();
-//~^ ERROR call to function with `#[target_feature]` is unsafe
+//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
 
 const _: () = sse2_and_fxsr();
-//~^ ERROR call to function with `#[target_feature]` is unsafe
+//~^ ERROR call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe
 
 #[deny(unsafe_op_in_unsafe_fn)]
 #[target_feature(enable = "avx")]
 #[target_feature(enable = "bmi2")]
 unsafe fn needs_unsafe_block() {
     sse2();
-    //~^ ERROR call to function with `#[target_feature]` is unsafe
+    //~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
 }
 
 fn main() {}
diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr
index 3897f09b576..e17859eb40f 100644
--- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr
+++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:25:5
    |
 LL |     sse2();
@@ -7,7 +7,7 @@ LL |     sse2();
    = help: in order for the call to be safe, the context requires the following additional target feature: sse2
    = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:27:5
    |
 LL |     avx_bmi2();
@@ -15,7 +15,7 @@ LL |     avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:29:5
    |
 LL |     Quux.avx_bmi2();
@@ -23,7 +23,7 @@ LL |     Quux.avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:35:5
    |
 LL |     avx_bmi2();
@@ -31,7 +31,7 @@ LL |     avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:37:5
    |
 LL |     Quux.avx_bmi2();
@@ -39,7 +39,7 @@ LL |     Quux.avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:43:5
    |
 LL |     sse2();
@@ -48,7 +48,7 @@ LL |     sse2();
    = help: in order for the call to be safe, the context requires the following additional target feature: sse2
    = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:45:5
    |
 LL |     avx_bmi2();
@@ -56,7 +56,7 @@ LL |     avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target feature: bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:47:5
    |
 LL |     Quux.avx_bmi2();
@@ -64,7 +64,7 @@ LL |     Quux.avx_bmi2();
    |
    = help: in order for the call to be safe, the context requires the following additional target feature: bmi2
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:54:5
    |
 LL |     sse2();
@@ -73,7 +73,7 @@ LL |     sse2();
    = help: in order for the call to be safe, the context requires the following additional target feature: sse2
    = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:58:15
    |
 LL | const _: () = sse2();
@@ -82,7 +82,7 @@ LL | const _: () = sse2();
    = help: in order for the call to be safe, the context requires the following additional target feature: sse2
    = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
 
-error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
+error[E0133]: call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe and requires unsafe function or block
   --> $DIR/safe-calls.rs:61:15
    |
 LL | const _: () = sse2_and_fxsr();
@@ -91,7 +91,7 @@ LL | const _: () = sse2_and_fxsr();
    = help: in order for the call to be safe, the context requires the following additional target features: sse2 and fxsr
    = note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
 
-error: call to function with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
+error: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
   --> $DIR/safe-calls.rs:68:5
    |
 LL |     sse2();
diff --git a/tests/ui/static/safe-extern-statics-mut.stderr b/tests/ui/static/safe-extern-statics-mut.stderr
index 38803883414..e390625f20a 100644
--- a/tests/ui/static/safe-extern-statics-mut.stderr
+++ b/tests/ui/static/safe-extern-statics-mut.stderr
@@ -7,10 +7,10 @@ LL |     let b = B;
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
 error[E0133]: use of mutable static is unsafe and requires unsafe function or block
-  --> $DIR/safe-extern-statics-mut.rs:12:14
+  --> $DIR/safe-extern-statics-mut.rs:12:15
    |
 LL |     let rb = &B;
-   |              ^^ use of mutable static
+   |               ^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
@@ -23,10 +23,10 @@ LL |     let xb = XB;
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
 error[E0133]: use of mutable static is unsafe and requires unsafe function or block
-  --> $DIR/safe-extern-statics-mut.rs:14:15
+  --> $DIR/safe-extern-statics-mut.rs:14:16
    |
 LL |     let xrb = &XB;
-   |               ^^^ use of mutable static
+   |                ^^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
diff --git a/tests/ui/static/safe-extern-statics.stderr b/tests/ui/static/safe-extern-statics.stderr
index b42572ea3ee..6be6c074c26 100644
--- a/tests/ui/static/safe-extern-statics.stderr
+++ b/tests/ui/static/safe-extern-statics.stderr
@@ -7,10 +7,10 @@ LL |     let a = A;
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
 error[E0133]: use of extern static is unsafe and requires unsafe function or block
-  --> $DIR/safe-extern-statics.rs:12:14
+  --> $DIR/safe-extern-statics.rs:12:15
    |
 LL |     let ra = &A;
-   |              ^^ use of extern static
+   |               ^ use of extern static
    |
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
@@ -23,10 +23,10 @@ LL |     let xa = XA;
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
 error[E0133]: use of extern static is unsafe and requires unsafe function or block
-  --> $DIR/safe-extern-statics.rs:14:15
+  --> $DIR/safe-extern-statics.rs:14:16
    |
 LL |     let xra = &XA;
-   |               ^^^ use of extern static
+   |                ^^ use of extern static
    |
    = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
 
diff --git a/tests/ui/static/static-mut-foreign-requires-unsafe.stderr b/tests/ui/static/static-mut-foreign-requires-unsafe.stderr
index e7ed0b710b2..022f7e9fb16 100644
--- a/tests/ui/static/static-mut-foreign-requires-unsafe.stderr
+++ b/tests/ui/static/static-mut-foreign-requires-unsafe.stderr
@@ -2,7 +2,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or bl
   --> $DIR/static-mut-foreign-requires-unsafe.rs:6:5
    |
 LL |     a += 3;
-   |     ^^^^^^ use of mutable static
+   |     ^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
@@ -10,7 +10,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or bl
   --> $DIR/static-mut-foreign-requires-unsafe.rs:7:5
    |
 LL |     a = 4;
-   |     ^^^^^ use of mutable static
+   |     ^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
diff --git a/tests/ui/static/static-mut-requires-unsafe.stderr b/tests/ui/static/static-mut-requires-unsafe.stderr
index 85e468b333c..30be0220cf6 100644
--- a/tests/ui/static/static-mut-requires-unsafe.stderr
+++ b/tests/ui/static/static-mut-requires-unsafe.stderr
@@ -2,7 +2,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or bl
   --> $DIR/static-mut-requires-unsafe.rs:4:5
    |
 LL |     a += 3;
-   |     ^^^^^^ use of mutable static
+   |     ^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
@@ -10,7 +10,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or bl
   --> $DIR/static-mut-requires-unsafe.rs:5:5
    |
 LL |     a = 4;
-   |     ^^^^^ use of mutable static
+   |     ^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
diff --git a/tests/ui/thread-local/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr
index f37fd9db36d..c1777dd60db 100644
--- a/tests/ui/thread-local/thread-local-static.stderr
+++ b/tests/ui/thread-local/thread-local-static.stderr
@@ -1,3 +1,11 @@
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+  --> $DIR/thread-local-static.rs:10:28
+   |
+LL |     std::mem::swap(x, &mut STATIC_VAR_2)
+   |                            ^^^^^^^^^^^^ use of mutable static
+   |
+   = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
 error[E0658]: mutable references are not allowed in constant functions
   --> $DIR/thread-local-static.rs:8:12
    |
@@ -30,14 +38,6 @@ LL |     std::mem::swap(x, &mut STATIC_VAR_2)
    = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
-  --> $DIR/thread-local-static.rs:10:23
-   |
-LL |     std::mem::swap(x, &mut STATIC_VAR_2)
-   |                       ^^^^^^^^^^^^^^^^^ use of mutable static
-   |
-   = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
 error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0013, E0133, E0625, E0658.
diff --git a/tests/ui/threads-sendsync/issue-43733.rs b/tests/ui/threads-sendsync/issue-43733.rs
index 996abb4809a..671b45e777f 100644
--- a/tests/ui/threads-sendsync/issue-43733.rs
+++ b/tests/ui/threads-sendsync/issue-43733.rs
@@ -15,11 +15,11 @@ static __KEY: std::thread::local_impl::Key<Foo> = std::thread::local_impl::Key::
 
 fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> {
     __KEY.get(Default::default)
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `Key::<T>::get` is unsafe
 }
 
 static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
-//~^ ERROR call to unsafe function is unsafe
+//~^ ERROR call to unsafe function `LocalKey::<T>::new` is unsafe
 
 fn main() {
     FOO.with(|foo| println!("{}", foo.borrow()));
diff --git a/tests/ui/threads-sendsync/issue-43733.stderr b/tests/ui/threads-sendsync/issue-43733.stderr
index 9090fd0a4a6..9b13646a228 100644
--- a/tests/ui/threads-sendsync/issue-43733.stderr
+++ b/tests/ui/threads-sendsync/issue-43733.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `Key::<T>::get` is unsafe and requires unsafe function or block
   --> $DIR/issue-43733.rs:17:5
    |
 LL |     __KEY.get(Default::default)
@@ -6,7 +6,7 @@ LL |     __KEY.get(Default::default)
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `LocalKey::<T>::new` is unsafe and requires unsafe function or block
   --> $DIR/issue-43733.rs:21:42
    |
 LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
diff --git a/tests/ui/traits/safety-fn-body.stderr b/tests/ui/traits/safety-fn-body.stderr
index 284e73f572d..7a8e6c81a22 100644
--- a/tests/ui/traits/safety-fn-body.stderr
+++ b/tests/ui/traits/safety-fn-body.stderr
@@ -2,7 +2,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/safety-fn-body.rs:11:9
    |
 LL |         *self += 1;
-   |         ^^^^^^^^^^ dereference of raw pointer
+   |         ^^^^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
diff --git a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr
index 404e376e364..94113b336c3 100644
--- a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr
+++ b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr
@@ -44,11 +44,6 @@ note: ...which requires preparing `Alpha::V3::{constant#0}` for borrow checking.
    |
 LL |     V3 = Self::V1 {} as u8 + 2,
    |          ^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `Alpha::V3::{constant#0}`...
-  --> $DIR/self-in-enum-definition.rs:5:10
-   |
-LL |     V3 = Self::V1 {} as u8 + 2,
-   |          ^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires building MIR for `Alpha::V3::{constant#0}`...
   --> $DIR/self-in-enum-definition.rs:5:10
    |
diff --git a/tests/ui/union/union-unsafe.stderr b/tests/ui/union/union-unsafe.stderr
index 4d3408a89af..82b3f897167 100644
--- a/tests/ui/union/union-unsafe.stderr
+++ b/tests/ui/union/union-unsafe.stderr
@@ -1,8 +1,8 @@
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/union-unsafe.rs:31:5
+  --> $DIR/union-unsafe.rs:31:6
    |
 LL |     *(u.p) = 13;
-   |     ^^^^^^^^^^^ access to union field
+   |      ^^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
@@ -39,18 +39,18 @@ LL |     let U1 { a } = u1;
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/union-unsafe.rs:61:12
+  --> $DIR/union-unsafe.rs:61:20
    |
 LL |     if let U1 { a: 12 } = u1 {}
-   |            ^^^^^^^^^^^^ access to union field
+   |                    ^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/union-unsafe.rs:62:12
+  --> $DIR/union-unsafe.rs:62:25
    |
 LL |     if let Some(U1 { a: 13 }) = Some(u1) {}
-   |            ^^^^^^^^^^^^^^^^^^ access to union field
+   |                         ^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
diff --git a/tests/ui/union/union-unsized.stderr b/tests/ui/union/union-unsized.stderr
index 3d2e699f630..851ad8939d4 100644
--- a/tests/ui/union/union-unsized.stderr
+++ b/tests/ui/union/union-unsized.stderr
@@ -17,7 +17,7 @@ LL |     a: Box<str>,
    |        ++++   +
 
 error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
-  --> $DIR/union-unsized.rs:5:5
+  --> $DIR/union-unsized.rs:2:5
    |
 LL |     a: str,
    |     ^^^^^^
@@ -47,18 +47,6 @@ LL |     b: Box<str>,
    |        ++++   +
 
 error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
-  --> $DIR/union-unsized.rs:2:5
-   |
-LL |     a: str,
-   |     ^^^^^^
-   |
-   = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
-help: wrap the field type in `ManuallyDrop<...>`
-   |
-LL |     a: std::mem::ManuallyDrop<str>,
-   |        +++++++++++++++++++++++   +
-
-error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
   --> $DIR/union-unsized.rs:11:5
    |
 LL |     b: str,
diff --git a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.rs b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.rs
index 9e150326f0b..f84f12c8301 100644
--- a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.rs
+++ b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.rs
@@ -8,7 +8,7 @@ unsafe fn unsf() {}
 
 unsafe fn foo() {
     unsf();
-    //~^ WARN call to unsafe function is unsafe and requires unsafe block
+    //~^ WARN call to unsafe function `unsf` is unsafe and requires unsafe block
 
     // no unused_unsafe
     unsafe {
diff --git a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr
index 9ca10b05090..1187c2d80f3 100644
--- a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr
+++ b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr
@@ -1,4 +1,4 @@
-warning: call to unsafe function is unsafe and requires unsafe block (error E0133)
+warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:10:5
    |
 LL |     unsf();
diff --git a/tests/ui/unsafe/foreign-unsafe-fn-called.rs b/tests/ui/unsafe/foreign-unsafe-fn-called.rs
index abbe462021e..b5065beb5fc 100644
--- a/tests/ui/unsafe/foreign-unsafe-fn-called.rs
+++ b/tests/ui/unsafe/foreign-unsafe-fn-called.rs
@@ -6,5 +6,5 @@ mod test {
 
 fn main() {
     test::free();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `test::free` is unsafe
 }
diff --git a/tests/ui/unsafe/foreign-unsafe-fn-called.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.stderr
index b55e6130230..cf2d4c493a1 100644
--- a/tests/ui/unsafe/foreign-unsafe-fn-called.stderr
+++ b/tests/ui/unsafe/foreign-unsafe-fn-called.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe function or block
   --> $DIR/foreign-unsafe-fn-called.rs:8:5
    |
 LL |     test::free();
diff --git a/tests/ui/unsafe/issue-3080.stderr b/tests/ui/unsafe/issue-3080.stderr
index f84ba204639..913a601049e 100644
--- a/tests/ui/unsafe/issue-3080.stderr
+++ b/tests/ui/unsafe/issue-3080.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `X::with` is unsafe and requires unsafe function or block
   --> $DIR/issue-3080.rs:7:5
    |
 LL |     X(()).with();
diff --git a/tests/ui/unsafe/issue-45087-unreachable-unsafe.stderr b/tests/ui/unsafe/issue-45087-unreachable-unsafe.stderr
index cc1e73bb932..d6cc5fd2e08 100644
--- a/tests/ui/unsafe/issue-45087-unreachable-unsafe.stderr
+++ b/tests/ui/unsafe/issue-45087-unreachable-unsafe.stderr
@@ -2,7 +2,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/issue-45087-unreachable-unsafe.rs:5:5
    |
 LL |     *(1 as *mut u32) = 42;
-   |     ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
+   |     ^^^^^^^^^^^^^^^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
@@ -10,7 +10,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/issue-45087-unreachable-unsafe.rs:15:5
    |
 LL |     *a = 1;
-   |     ^^^^^^ dereference of raw pointer
+   |     ^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
@@ -18,7 +18,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/issue-45087-unreachable-unsafe.rs:27:5
    |
 LL |     *b = 1;
-   |     ^^^^^^ dereference of raw pointer
+   |     ^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
diff --git a/tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.stderr b/tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.stderr
index 321698e7636..b23c002dc65 100644
--- a/tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.stderr
+++ b/tests/ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.stderr
@@ -16,9 +16,9 @@ LL | #[deny(unused_unsafe)]
 error: unnecessary `unsafe` block
   --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:9:38
    |
-LL |     unsafe {
-   |     ------ because it's nested under this `unsafe` block
-...
+LL |             unsafe {
+   |             ------ because it's nested under this `unsafe` block
+LL |                 v.set_len(24);
 LL |                 |w: &mut Vec<u32>| { unsafe {
    |                                      ^^^^^^ unnecessary `unsafe` block
 
diff --git a/tests/ui/unsafe/ranged_ints2_const.stderr b/tests/ui/unsafe/ranged_ints2_const.stderr
index a0dc950e76d..f267dc6e23e 100644
--- a/tests/ui/unsafe/ranged_ints2_const.stderr
+++ b/tests/ui/unsafe/ranged_ints2_const.stderr
@@ -1,3 +1,11 @@
+error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block
+  --> $DIR/ranged_ints2_const.rs:11:13
+   |
+LL |     let y = &mut x.0;
+   |             ^^^^^^^^ mutation of layout constrained field
+   |
+   = note: mutating layout constrained fields cannot statically be checked for valid values
+
 error[E0658]: mutable references are not allowed in constant functions
   --> $DIR/ranged_ints2_const.rs:11:13
    |
@@ -25,14 +33,6 @@ LL |     unsafe { let y = &mut x.0; }
    = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
-error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block
-  --> $DIR/ranged_ints2_const.rs:11:13
-   |
-LL |     let y = &mut x.0;
-   |             ^^^^^^^^ mutation of layout constrained field
-   |
-   = note: mutating layout constrained fields cannot statically be checked for valid values
-
 error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0133, E0658.
diff --git a/tests/ui/unsafe/ranged_ints3_const.stderr b/tests/ui/unsafe/ranged_ints3_const.stderr
index 215005571f6..75b36cdf94b 100644
--- a/tests/ui/unsafe/ranged_ints3_const.stderr
+++ b/tests/ui/unsafe/ranged_ints3_const.stderr
@@ -1,3 +1,11 @@
+error[E0133]: borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block
+  --> $DIR/ranged_ints3_const.rs:12:13
+   |
+LL |     let y = &x.0;
+   |             ^^^^ borrow of layout constrained field with interior mutability
+   |
+   = note: references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values
+
 error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
   --> $DIR/ranged_ints3_const.rs:12:13
    |
@@ -16,14 +24,6 @@ LL |     let y = unsafe { &x.0 };
    = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information
    = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
 
-error[E0133]: borrow of layout constrained field with interior mutability is unsafe and requires unsafe function or block
-  --> $DIR/ranged_ints3_const.rs:12:13
-   |
-LL |     let y = &x.0;
-   |             ^^^^ borrow of layout constrained field with interior mutability
-   |
-   = note: references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values
-
 error: aborting due to 3 previous errors
 
 Some errors have detailed explanations: E0133, E0658.
diff --git a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs
index eceac115edd..658d14da829 100644
--- a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs
+++ b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.rs
@@ -7,7 +7,7 @@ static mut VOID: () = ();
 
 unsafe fn deny_level() {
     unsf();
-    //~^ ERROR call to unsafe function is unsafe and requires unsafe block
+    //~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
     *PTR;
     //~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
     VOID = ();
@@ -22,7 +22,7 @@ unsafe fn deny_level() {
 #[deny(warnings)]
 unsafe fn warning_level() {
     unsf();
-    //~^ ERROR call to unsafe function is unsafe and requires unsafe block
+    //~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
     *PTR;
     //~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
     VOID = ();
@@ -69,10 +69,10 @@ unsafe fn nested_allow_level() {
 
 fn main() {
     unsf();
-    //~^ ERROR call to unsafe function is unsafe and requires unsafe block
+    //~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
     #[allow(unsafe_op_in_unsafe_fn)]
     {
         unsf();
-        //~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
+        //~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe function or block
     }
 }
diff --git a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr
index d61d87cd001..ea0659b2e10 100644
--- a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr
+++ b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.stderr
@@ -1,4 +1,4 @@
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:9:5
    |
 LL |     unsf();
@@ -28,7 +28,7 @@ error: use of mutable static is unsafe and requires unsafe block (error E0133)
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5
    |
 LL |     VOID = ();
-   |     ^^^^^^^^^ use of mutable static
+   |     ^^^^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
@@ -44,7 +44,7 @@ note: the lint level is defined here
 LL | #![deny(unused_unsafe)]
    |         ^^^^^^^^^^^^^
 
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:24:5
    |
 LL |     unsf();
@@ -75,7 +75,7 @@ error: use of mutable static is unsafe and requires unsafe block (error E0133)
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5
    |
 LL |     VOID = ();
-   |     ^^^^^^^^^ use of mutable static
+   |     ^^^^ use of mutable static
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
@@ -91,7 +91,7 @@ error: unnecessary `unsafe` block
 LL |     unsafe { unsafe { unsf() } }
    |     ^^^^^^ unnecessary `unsafe` block
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe block
+error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:71:5
    |
 LL |     unsf();
@@ -99,7 +99,7 @@ LL |     unsf();
    |
    = note: consult the function's documentation for information on how to avoid undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe function or block
   --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:75:9
    |
 LL |         unsf();
diff --git a/tests/ui/unsafe/union-assignop.stderr b/tests/ui/unsafe/union-assignop.stderr
index e3a673ee1ff..6b2ebfb5099 100644
--- a/tests/ui/unsafe/union-assignop.stderr
+++ b/tests/ui/unsafe/union-assignop.stderr
@@ -2,7 +2,7 @@ error[E0133]: access to union field is unsafe and requires unsafe function or bl
   --> $DIR/union-assignop.rs:16:5
    |
 LL |     foo.a += 5;
-   |     ^^^^^^^^^^ access to union field
+   |     ^^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
diff --git a/tests/ui/unsafe/union.rs b/tests/ui/unsafe/union.rs
index 83ec1c3cd6c..ae81708aa19 100644
--- a/tests/ui/unsafe/union.rs
+++ b/tests/ui/unsafe/union.rs
@@ -26,20 +26,19 @@ pub fn main() {
     match foo {
         Foo { bar: _a } => {}, //~ ERROR access to union field is unsafe
     }
-    match foo { //~ ERROR access to union field is unsafe
+    match foo {
         Foo {
-            pizza: Pizza {
+            pizza: Pizza { //~ ERROR access to union field is unsafe
                 topping: Some(PizzaTopping::Cheese) | Some(PizzaTopping::Pineapple) | None
             }
         } => {},
     }
 
-    // MIR unsafeck incorrectly thinks that no unsafe block is needed to do these
     match foo {
-        Foo { zst: () } => {},
+        Foo { zst: () } => {} //~ ERROR access to union field is unsafe
     }
     match foo {
-        Foo { pizza: Pizza { .. } } => {},
+        Foo { pizza: Pizza { .. } } => {} //~ ERROR access to union field is unsafe
     }
 
     // binding to wildcard is okay
diff --git a/tests/ui/unsafe/union.stderr b/tests/ui/unsafe/union.stderr
index fe814462412..1506bdb919b 100644
--- a/tests/ui/unsafe/union.stderr
+++ b/tests/ui/unsafe/union.stderr
@@ -7,13 +7,32 @@ LL |         Foo { bar: _a } => {},
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/union.rs:29:11
+  --> $DIR/union.rs:31:20
    |
-LL |     match foo {
-   |           ^^^ access to union field
+LL |               pizza: Pizza {
+   |  ____________________^
+LL | |                 topping: Some(PizzaTopping::Cheese) | Some(PizzaTopping::Pineapple) | None
+LL | |             }
+   | |_____________^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
-error: aborting due to 2 previous errors
+error[E0133]: access to union field is unsafe and requires unsafe function or block
+  --> $DIR/union.rs:38:20
+   |
+LL |         Foo { zst: () } => {}
+   |                    ^^ access to union field
+   |
+   = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
+
+error[E0133]: access to union field is unsafe and requires unsafe function or block
+  --> $DIR/union.rs:41:22
+   |
+LL |         Foo { pizza: Pizza { .. } } => {}
+   |                      ^^^^^^^^^^^^ access to union field
+   |
+   = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0133`.
diff --git a/tests/ui/unsafe/union_destructure.rs b/tests/ui/unsafe/union_destructure.rs
index 85fd54c8145..d0cf8640eaa 100644
--- a/tests/ui/unsafe/union_destructure.rs
+++ b/tests/ui/unsafe/union_destructure.rs
@@ -10,7 +10,7 @@ struct Pie {
 union Foo {
     #[allow(dead_code)]
     bar: i8,
-    baz: Pie
+    baz: Pie,
 }
 
 fn main() {
@@ -30,20 +30,20 @@ fn main() {
     };
 
     let u = Foo { bar: 9 };
-    unsafe { //~ WARNING unnecessary `unsafe` block
+    unsafe {
         match u {
-            Foo { baz: Pie { .. } } => {},
+            Foo { baz: Pie { .. } } => {}
         };
     }
     let u = Foo { bar: 10 };
-    unsafe { //~ WARNING unnecessary `unsafe` block
+    unsafe {
         match u {
-            Foo { baz: Pie { slices: _, size: _ } } => {},
+            Foo { baz: Pie { slices: _, size: _ } } => {}
         };
     }
 
     let u = Foo { bar: 11 };
     match u {
-        Foo { baz: _ } => {},
+        Foo { baz: _ } => {}
     };
 }
diff --git a/tests/ui/unsafe/union_destructure.stderr b/tests/ui/unsafe/union_destructure.stderr
deleted file mode 100644
index 431521472e8..00000000000
--- a/tests/ui/unsafe/union_destructure.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-warning: unnecessary `unsafe` block
-  --> $DIR/union_destructure.rs:33:5
-   |
-LL |     unsafe {
-   |     ^^^^^^ unnecessary `unsafe` block
-   |
-   = note: `#[warn(unused_unsafe)]` on by default
-
-warning: unnecessary `unsafe` block
-  --> $DIR/union_destructure.rs:39:5
-   |
-LL |     unsafe {
-   |     ^^^^^^ unnecessary `unsafe` block
-
-warning: 2 warnings emitted
-
diff --git a/tests/ui/unsafe/unsafe-const-fn.stderr b/tests/ui/unsafe/unsafe-const-fn.stderr
index 8d7f09a1edb..5a6e6b7ce59 100644
--- a/tests/ui/unsafe/unsafe-const-fn.stderr
+++ b/tests/ui/unsafe/unsafe-const-fn.stderr
@@ -1,4 +1,4 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `dummy` is unsafe and requires unsafe function or block
   --> $DIR/unsafe-const-fn.rs:7:18
    |
 LL | const VAL: u32 = dummy(0xFFFF);
diff --git a/tests/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr b/tests/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr
index d79cbd466c2..3a0874f32c0 100644
--- a/tests/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr
+++ b/tests/ui/unsafe/unsafe-fn-assign-deref-ptr.stderr
@@ -2,7 +2,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function
   --> $DIR/unsafe-fn-assign-deref-ptr.rs:2:5
    |
 LL |     *p = 0;
-   |     ^^^^^^ dereference of raw pointer
+   |     ^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
diff --git a/tests/ui/unsafe/unsafe-fn-called-from-safe.rs b/tests/ui/unsafe/unsafe-fn-called-from-safe.rs
index 1836629958a..758b80097f7 100644
--- a/tests/ui/unsafe/unsafe-fn-called-from-safe.rs
+++ b/tests/ui/unsafe/unsafe-fn-called-from-safe.rs
@@ -1,6 +1,8 @@
-unsafe fn f() { return; }
+unsafe fn f() {
+    return;
+}
 
 fn main() {
     f();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `f` is unsafe
 }
diff --git a/tests/ui/unsafe/unsafe-fn-called-from-safe.stderr b/tests/ui/unsafe/unsafe-fn-called-from-safe.stderr
index 51aba0ba6d7..1b1c92f0546 100644
--- a/tests/ui/unsafe/unsafe-fn-called-from-safe.stderr
+++ b/tests/ui/unsafe/unsafe-fn-called-from-safe.stderr
@@ -1,5 +1,5 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-called-from-safe.rs:4:5
+error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-called-from-safe.rs:6:5
    |
 LL |     f();
    |     ^^^ call to unsafe function
diff --git a/tests/ui/unsafe/unsafe-fn-used-as-value.rs b/tests/ui/unsafe/unsafe-fn-used-as-value.rs
index a47189d265f..99506ea047c 100644
--- a/tests/ui/unsafe/unsafe-fn-used-as-value.rs
+++ b/tests/ui/unsafe/unsafe-fn-used-as-value.rs
@@ -1,7 +1,9 @@
-unsafe fn f() { return; }
+unsafe fn f() {
+    return;
+}
 
 fn main() {
     let x = f;
     x();
-    //~^ ERROR call to unsafe function is unsafe
+    //~^ ERROR call to unsafe function `f` is unsafe
 }
diff --git a/tests/ui/unsafe/unsafe-fn-used-as-value.stderr b/tests/ui/unsafe/unsafe-fn-used-as-value.stderr
index 1625de184d2..0542b87b5e6 100644
--- a/tests/ui/unsafe/unsafe-fn-used-as-value.stderr
+++ b/tests/ui/unsafe/unsafe-fn-used-as-value.stderr
@@ -1,5 +1,5 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-used-as-value.rs:5:5
+error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-used-as-value.rs:7:5
    |
 LL |     x();
    |     ^^^ call to unsafe function
diff --git a/tests/ui/unsafe/unsafe-not-inherited.stderr b/tests/ui/unsafe/unsafe-not-inherited.stderr
index 3bc5ca5c9d1..8b699127312 100644
--- a/tests/ui/unsafe/unsafe-not-inherited.stderr
+++ b/tests/ui/unsafe/unsafe-not-inherited.stderr
@@ -8,7 +8,7 @@ LL |     unsafe {static BAR: u64 = FOO;}
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `unsafe_call` is unsafe and requires unsafe function or block
   --> $DIR/unsafe-not-inherited.rs:18:13
    |
 LL |     unsafe {
diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed b/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed
index f776cffed59..20f4fe847da 100644
--- a/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed
+++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed
@@ -10,10 +10,10 @@ unsafe fn unsf() {}
 
 pub unsafe fn foo() { unsafe {
     //~^ NOTE an unsafe function restricts its caller, but its body is safe by default
-    unsf(); //~ ERROR call to unsafe function is unsafe
+    unsf(); //~ ERROR call to unsafe function `unsf` is unsafe
     //~^ NOTE
     //~| NOTE
-    unsf(); //~ ERROR call to unsafe function is unsafe
+    unsf(); //~ ERROR call to unsafe function `unsf` is unsafe
     //~^ NOTE
     //~| NOTE
 }}
@@ -40,10 +40,10 @@ pub unsafe fn baz() -> i32 { unsafe {
 }}
 
 macro_rules! unsafe_macro { () => (unsf()) }
-//~^ ERROR call to unsafe function is unsafe
+//~^ ERROR call to unsafe function `unsf` is unsafe
 //~| NOTE
 //~| NOTE
-//~| ERROR call to unsafe function is unsafe
+//~| ERROR call to unsafe function `unsf` is unsafe
 //~| NOTE
 //~| NOTE
 
diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs b/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs
index 13ab51ef432..13a446d2d24 100644
--- a/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs
+++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs
@@ -10,10 +10,10 @@ unsafe fn unsf() {}
 
 pub unsafe fn foo() {
     //~^ NOTE an unsafe function restricts its caller, but its body is safe by default
-    unsf(); //~ ERROR call to unsafe function is unsafe
+    unsf(); //~ ERROR call to unsafe function `unsf` is unsafe
     //~^ NOTE
     //~| NOTE
-    unsf(); //~ ERROR call to unsafe function is unsafe
+    unsf(); //~ ERROR call to unsafe function `unsf` is unsafe
     //~^ NOTE
     //~| NOTE
 }
@@ -40,10 +40,10 @@ pub unsafe fn baz() -> i32 {
 }
 
 macro_rules! unsafe_macro { () => (unsf()) }
-//~^ ERROR call to unsafe function is unsafe
+//~^ ERROR call to unsafe function `unsf` is unsafe
 //~| NOTE
 //~| NOTE
-//~| ERROR call to unsafe function is unsafe
+//~| ERROR call to unsafe function `unsf` is unsafe
 //~| NOTE
 //~| NOTE
 
diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr b/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr
index 9ae238d5a79..84b58bc0288 100644
--- a/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr
+++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr
@@ -1,4 +1,4 @@
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/wrapping-unsafe-block-sugg.rs:13:5
    |
 LL |     unsf();
@@ -16,7 +16,7 @@ note: the lint level is defined here
 LL | #![deny(unsafe_op_in_unsafe_fn)]
    |         ^^^^^^^^^^^^^^^^^^^^^^
 
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/wrapping-unsafe-block-sugg.rs:16:5
    |
 LL |     unsf();
@@ -66,7 +66,7 @@ LL |     y + BAZ
    |
    = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
 
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/wrapping-unsafe-block-sugg.rs:42:36
    |
 LL | macro_rules! unsafe_macro { () => (unsf()) }
@@ -83,7 +83,7 @@ LL | pub unsafe fn unsafe_in_macro() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: call to unsafe function is unsafe and requires unsafe block (error E0133)
+error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
   --> $DIR/wrapping-unsafe-block-sugg.rs:42:36
    |
 LL | macro_rules! unsafe_macro { () => (unsf()) }