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
> {
- // 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 = (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,3 +1,35 @@
+error[E0133]: access to union field is unsafe and requires unsafe function or block
+ --> $DIR/issue-53114-safety-checks.rs:24:13
+ |
+LL | let _ = u1.a;
+ | ^^^^ 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/issue-53114-safety-checks.rs:25:14
+ |
+LL | let _ = &u2.a;
+ | ^^^^ 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/issue-53114-safety-checks.rs:29:17
+ |
+LL | let (_,) = (u1.a,);
+ | ^^^^ 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/issue-53114-safety-checks.rs:30:18
+ |
+LL | let (_,) = (&u2.a,);
+ | ^^^^ 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
|
@@ -18,6 +50,38 @@ LL | let (_,) = (&p.b,);
= 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
+ |
+LL | let _: _ = u1.a;
+ | ^^^^ 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/issue-53114-safety-checks.rs:39:17
+ |
+LL | let _: _ = &u2.a;
+ | ^^^^ 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/issue-53114-safety-checks.rs:43:20
+ |
+LL | let (_,): _ = (u1.a,);
+ | ^^^^ 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/issue-53114-safety-checks.rs:44:21
+ |
+LL | let (_,): _ = (&u2.a,);
+ | ^^^^ 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
|
@@ -38,6 +102,38 @@ LL | let (_,): _ = (&p.b,);
= 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
+ |
+LL | match u1.a { _ => { } }
+ | ^^^^ 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/issue-53114-safety-checks.rs:53:12
+ |
+LL | match &u2.a { _ => { } }
+ | ^^^^ 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/issue-53114-safety-checks.rs:57:12
+ |
+LL | match (u1.a,) { (_,) => { } }
+ | ^^^^ 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/issue-53114-safety-checks.rs:58:13
+ |
+LL | match (&u2.a,) { (_,) => { } }
+ | ^^^^ 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
|
@@ -58,102 +154,6 @@ LL | match (&p.b,) { (_,) => { } }
= 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
- |
-LL | let _ = u1.a;
- | ^^^^ 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/issue-53114-safety-checks.rs:25:13
- |
-LL | let _ = &u2.a;
- | ^^^^^ 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/issue-53114-safety-checks.rs:29:17
- |
-LL | let (_,) = (u1.a,);
- | ^^^^ 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/issue-53114-safety-checks.rs:30:17
- |
-LL | let (_,) = (&u2.a,);
- | ^^^^^ 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/issue-53114-safety-checks.rs:38:16
- |
-LL | let _: _ = u1.a;
- | ^^^^ 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/issue-53114-safety-checks.rs:39:16
- |
-LL | let _: _ = &u2.a;
- | ^^^^^ 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/issue-53114-safety-checks.rs:43:20
- |
-LL | let (_,): _ = (u1.a,);
- | ^^^^ 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/issue-53114-safety-checks.rs:44:20
- |
-LL | let (_,): _ = (&u2.a,);
- | ^^^^^ 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/issue-53114-safety-checks.rs:52:11
- |
-LL | match u1.a { _ => { } }
- | ^^^^ 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/issue-53114-safety-checks.rs:53:11
- |
-LL | match &u2.a { _ => { } }
- | ^^^^^ 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/issue-53114-safety-checks.rs:57:12
- |
-LL | match (u1.a,) { (_,) => { } }
- | ^^^^ 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/issue-53114-safety-checks.rs:58:12
- |
-LL | match (&u2.a,) { (_,) => { } }
- | ^^^^^ access to union field
- |
- = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
-
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::::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)
//~^ 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> >::Output: Future