Stabilize THIR unsafeck
This commit is contained in:
parent
982b49494e
commit
26f48b4cba
67 changed files with 331 additions and 353 deletions
|
@ -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)
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] = &[
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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); };
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
4
tests/ui/extern/issue-28324.stderr
vendored
4
tests/ui/extern/issue-28324.stderr
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
| ^^^^^^
|
||||
|
@ -46,18 +46,6 @@ help: the `Box` type always has a statically known size and allocates its conten
|
|||
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
|
||||
|
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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: _ } => {}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()) }
|
||||
|
|
Loading…
Add table
Reference in a new issue