Auto merge of #117673 - matthewjasper:thir-unsafeck-stabilization, r=cjgillot

Stabilize THIR unsafeck

- Removes `-Zthir-unsafeck`, stabilizing the behaviour of `-Zthir-unsafeck=on`.
- Removes MIR unsafeck.
- Union patterns are now unsafe unless the field is matched to a wildcard pattern.

Opening for a crater run in case we need a compatibility lint.
This commit is contained in:
bors 2024-01-05 12:34:00 +00:00
commit 6bc08a725f
284 changed files with 903 additions and 4868 deletions

View File

@ -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)
});
});

View File

@ -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);

View File

@ -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.

View File

@ -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 }
}

View File

@ -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;
@ -144,11 +144,17 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
let hir_context = self.tcx.local_def_id_to_hir_id(def);
let safety_context = mem::replace(&mut self.safety_context, SafetyContext::Safe);
let mut inner_visitor = UnsafetyVisitor {
tcx: self.tcx,
thir: inner_thir,
hir_context,
safety_context,
body_target_features: self.body_target_features,
assignment_info: self.assignment_info,
in_union_destructure: false,
param_env: self.param_env,
inside_adt: false,
warnings: self.warnings,
..*self
suggest_unsafe_block: self.suggest_unsafe_block,
};
inner_visitor.visit_expr(&inner_thir[expr]);
// Unsafe blocks can be used in the inner body, make sure to take it into account
@ -886,14 +892,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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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

View File

@ -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] = &[

View File

@ -1,8 +1,6 @@
// only-aarch64
// run-pass
// needs-asm-support
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![feature(asm_const)]

View File

@ -1,7 +1,5 @@
// compile-flags: --target sparc-unknown-linux-gnu
// needs-llvm-components: sparc
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]

View File

@ -1,11 +1,11 @@
error[E0472]: inline assembly is unsupported on this target
--> $DIR/bad-arch.rs:22:9
--> $DIR/bad-arch.rs:20:9
|
LL | asm!("");
| ^^^^^^^^
error[E0472]: inline assembly is unsupported on this target
--> $DIR/bad-arch.rs:27:1
--> $DIR/bad-arch.rs:25:1
|
LL | global_asm!("");
| ^^^^^^^^^^^^^^^

View File

@ -1,17 +0,0 @@
error[E0472]: inline assembly is unsupported on this target
--> $DIR/bad-arch.rs:22:9
|
LL | asm!("");
| ^^^^^^^^
error[E0472]: inline assembly is unsupported on this target
--> $DIR/bad-arch.rs:27:1
|
LL | global_asm!("");
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0472`.

View File

@ -1,5 +1,5 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:31:15
--> $DIR/bad-template.rs:27:15
|
LL | asm!("{}");
| ^^ from here
@ -7,7 +7,7 @@ LL | asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:33:15
--> $DIR/bad-template.rs:29:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:33:21
--> $DIR/bad-template.rs:29:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:36:16
--> $DIR/bad-template.rs:32:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:38:15
--> $DIR/bad-template.rs:34:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:38:20
--> $DIR/bad-template.rs:34:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:38:20
--> $DIR/bad-template.rs:34:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:41:15
--> $DIR/bad-template.rs:37:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:41:21
--> $DIR/bad-template.rs:37:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:48:15
--> $DIR/bad-template.rs:44:15
|
LL | asm!("{}", in("x0") foo);
| ^^ ------------ explicit register argument
@ -77,24 +77,24 @@ LL | asm!("{}", in("x0") foo);
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:48:20
--> $DIR/bad-template.rs:44:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:48:20
--> $DIR/bad-template.rs:44:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:50:17
--> $DIR/bad-template.rs:46:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:53:18
--> $DIR/bad-template.rs:49:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:59:14
--> $DIR/bad-template.rs:55:14
|
LL | global_asm!("{}");
| ^^ from here
@ -112,7 +112,7 @@ LL | global_asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:61:14
--> $DIR/bad-template.rs:57:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:61:20
--> $DIR/bad-template.rs:57:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:64:15
--> $DIR/bad-template.rs:60:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:66:14
--> $DIR/bad-template.rs:62:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:66:19
--> $DIR/bad-template.rs:62:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:66:19
--> $DIR/bad-template.rs:62:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:69:14
--> $DIR/bad-template.rs:65:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:69:20
--> $DIR/bad-template.rs:65:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:72:16
--> $DIR/bad-template.rs:68:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:74:17
--> $DIR/bad-template.rs:70:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:50:15
--> $DIR/bad-template.rs:46:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument

View File

@ -1,202 +0,0 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:31:15
|
LL | asm!("{}");
| ^^ from here
|
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:33:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
|
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:33:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:36:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:38:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
| |
| from here
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:38:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:38:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:41:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
|
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:41:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:48:15
|
LL | asm!("{}", in("x0") foo);
| ^^ ------------ explicit register argument
| |
| from here
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:48:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:48:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:50:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:53:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
| |
| argument never used
|
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:59:14
|
LL | global_asm!("{}");
| ^^ from here
|
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:61:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
|
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:61:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:64:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:66:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
| |
| from here
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:66:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:66:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:69:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
|
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:69:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:72:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:74:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
| |
| argument never used
|
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:50:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument
|
= help: use `{0:w}` to have the register formatted as `w0`
= help: or use `{0:x}` to keep the default formatting of `x0`
= note: `#[warn(asm_sub_register)]` on by default
error: aborting due to 21 previous errors; 1 warning emitted

View File

@ -1,14 +1,10 @@
// revisions: x86_64_mirunsafeck aarch64_mirunsafeck x86_64_thirunsafeck aarch64_thirunsafeck
// revisions: x86_64 aarch64
// [x86_64_thirunsafeck] compile-flags: -Z thir-unsafeck --target x86_64-unknown-linux-gnu
// [aarch64_thirunsafeck] compile-flags: -Z thir-unsafeck --target aarch64-unknown-linux-gnu
// [x86_64_mirunsafeck] compile-flags: --target x86_64-unknown-linux-gnu
// [aarch64_mirunsafeck] compile-flags: --target aarch64-unknown-linux-gnu
// [x86_64] compile-flags: --target x86_64-unknown-linux-gnu
// [aarch64] compile-flags: --target aarch64-unknown-linux-gnu
// [x86_64_thirunsafeck] needs-llvm-components: x86
// [x86_64_mirunsafeck] needs-llvm-components: x86
// [aarch64_thirunsafeck] needs-llvm-components: aarch64
// [aarch64_mirunsafeck] needs-llvm-components: aarch64
// [x86_64] needs-llvm-components: x86
// [aarch64] needs-llvm-components: aarch64
#![feature(no_core, lang_items, rustc_attrs, asm_const)]
#![no_core]
@ -41,12 +37,12 @@ fn main() {
asm!("{1}", a = in(reg) foo);
//~^ ERROR invalid reference to argument at index 1
//~^^ ERROR named argument never used
#[cfg(any(x86_64_thirunsafeck, x86_64_mirunsafeck))]
#[cfg(any(x86_64))]
asm!("{}", in("eax") foo);
//[x86_64_thirunsafeck,x86_64_mirunsafeck]~^ ERROR invalid reference to argument at index 0
#[cfg(any(aarch64_thirunsafeck, aarch64_mirunsafeck))]
//[x86_64]~^ ERROR invalid reference to argument at index 0
#[cfg(any(aarch64))]
asm!("{}", in("x0") foo);
//[aarch64_thirunsafeck,aarch64_mirunsafeck]~^ ERROR invalid reference to argument at index 0
//[aarch64]~^ ERROR invalid reference to argument at index 0
asm!("{:foo}", in(reg) foo);
//~^ ERROR asm template modifier must be a single character
//~| WARN formatting may not be suitable for sub-register argument [asm_sub_register]

View File

@ -1,5 +1,5 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:31:15
--> $DIR/bad-template.rs:27:15
|
LL | asm!("{}");
| ^^ from here
@ -7,7 +7,7 @@ LL | asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:33:15
--> $DIR/bad-template.rs:29:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:33:21
--> $DIR/bad-template.rs:29:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:36:16
--> $DIR/bad-template.rs:32:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:38:15
--> $DIR/bad-template.rs:34:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:38:20
--> $DIR/bad-template.rs:34:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:38:20
--> $DIR/bad-template.rs:34:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:41:15
--> $DIR/bad-template.rs:37:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:41:21
--> $DIR/bad-template.rs:37:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:45:15
--> $DIR/bad-template.rs:41:15
|
LL | asm!("{}", in("eax") foo);
| ^^ ------------- explicit register argument
@ -77,24 +77,24 @@ LL | asm!("{}", in("eax") foo);
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:45:20
--> $DIR/bad-template.rs:41:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:45:20
--> $DIR/bad-template.rs:41:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:50:17
--> $DIR/bad-template.rs:46:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:53:18
--> $DIR/bad-template.rs:49:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:59:14
--> $DIR/bad-template.rs:55:14
|
LL | global_asm!("{}");
| ^^ from here
@ -112,7 +112,7 @@ LL | global_asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:61:14
--> $DIR/bad-template.rs:57:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:61:20
--> $DIR/bad-template.rs:57:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:64:15
--> $DIR/bad-template.rs:60:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:66:14
--> $DIR/bad-template.rs:62:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:66:19
--> $DIR/bad-template.rs:62:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:66:19
--> $DIR/bad-template.rs:62:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:69:14
--> $DIR/bad-template.rs:65:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:69:20
--> $DIR/bad-template.rs:65:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:72:16
--> $DIR/bad-template.rs:68:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:74:17
--> $DIR/bad-template.rs:70:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:50:15
--> $DIR/bad-template.rs:46:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument

View File

@ -1,202 +0,0 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:31:15
|
LL | asm!("{}");
| ^^ from here
|
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:33:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
|
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:33:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:36:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:38:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
| |
| from here
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:38:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:38:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:41:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
|
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:41:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:45:15
|
LL | asm!("{}", in("eax") foo);
| ^^ ------------- explicit register argument
| |
| from here
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:45:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:45:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:50:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:53:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
| |
| argument never used
|
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:59:14
|
LL | global_asm!("{}");
| ^^ from here
|
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:61:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
|
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:61:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:64:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:66:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
| |
| from here
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:66:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:66:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:69:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
|
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:69:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:72:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:74:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
| |
| argument never used
|
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:50:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument
|
= help: use `{0:e}` to have the register formatted as `eax`
= help: or use `{0:r}` to keep the default formatting of `rax`
= note: `#[warn(asm_sub_register)]` on by default
error: aborting due to 21 previous errors; 1 warning emitted

View File

@ -1,8 +1,6 @@
// only-x86_64
// run-pass
// needs-asm-support
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![feature(asm_const)]

View File

@ -1,8 +1,7 @@
// run-pass
// revisions: default nomiropt thirunsafeck
// revisions: default nomiropt
//[nomiropt]compile-flags: -Z mir-opt-level=0
//[thirunsafeck]compile-flags: -Zthir-unsafeck
#![allow(unused)]

View File

@ -1,35 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
LL | S::f();
| ^^^^^^ 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/async-unsafe-fn-call-in-safe.rs:17:5
|
LL | f();
| ^^^ 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/async-unsafe-fn-call-in-safe.rs:23:5
|
LL | S::f();
| ^^^^^^ 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/async-unsafe-fn-call-in-safe.rs:26:5
|
LL | f();
| ^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,4 @@
// edition:2018
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
struct S;
@ -12,18 +10,14 @@ async unsafe fn f() {}
async fn g() {
S::f();
//[mir]~^ ERROR call to unsafe function is unsafe
//[thir]~^^ ERROR call to unsafe function `S::f` is unsafe
//~^ ERROR call to unsafe function `S::f` is unsafe
f();
//[mir]~^ ERROR call to unsafe function is unsafe
//[thir]~^^ ERROR call to unsafe function `f` is unsafe
//~^ ERROR call to unsafe function `f` is unsafe
}
fn main() {
S::f();
//[mir]~^ ERROR call to unsafe function is unsafe
//[thir]~^^ ERROR call to unsafe function `S::f` is unsafe
//~^ ERROR call to unsafe function `S::f` is unsafe
f();
//[mir]~^ ERROR call to unsafe function is unsafe
//[thir]~^^ ERROR call to unsafe function `f` is unsafe
//~^ ERROR call to unsafe function `f` is unsafe
}

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
--> $DIR/async-unsafe-fn-call-in-safe.rs:12:5
|
LL | S::f();
| ^^^^^^ call to unsafe function
@ -7,7 +7,7 @@ LL | S::f();
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
--> $DIR/async-unsafe-fn-call-in-safe.rs:17:5
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
LL | f();
| ^^^ call to unsafe function
@ -15,7 +15,7 @@ LL | f();
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
--> $DIR/async-unsafe-fn-call-in-safe.rs:23:5
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
|
LL | S::f();
| ^^^^^^ call to unsafe function
@ -23,7 +23,7 @@ LL | S::f();
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
--> $DIR/async-unsafe-fn-call-in-safe.rs:26:5
--> $DIR/async-unsafe-fn-call-in-safe.rs:21:5
|
LL | f();
| ^^^ call to unsafe function

View File

@ -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.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// Ensure we get unsafe function after coercion
unsafe fn add(a: i32, b: i32) -> i32 {
a + b

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:12:23
|
LL | let result: i32 = foo(5, 5);
| ^^^^^^^^^ call to unsafe function
@ -7,7 +7,7 @@ LL | let result: i32 = foo(5, 5);
= 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/closure_no_cap_coerce_many_unsafe_0.rs:24:23
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:21:23
|
LL | let result: i32 = foo(5, 5);
| ^^^^^^^^^ call to unsafe function

View File

@ -1,19 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
|
LL | let result: i32 = foo(5, 5);
| ^^^^^^^^^ 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/closure_no_cap_coerce_many_unsafe_0.rs:24:23
|
LL | let result: i32 = foo(5, 5);
| ^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,11 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
|
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
fn main() {
let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
//~^ ERROR E0133

View File

@ -1,5 +1,5 @@
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:5:31
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31
|
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

View File

@ -1,6 +1,5 @@
// Tests that no ICE occurs when a closure appears inside a node
// that does not have a body when compiling with
// compile-flags: -Zthir-unsafeck=yes
// check-pass
#![allow(dead_code)]

View File

@ -1,6 +1,4 @@
// run-pass
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![allow(stable_features)]
// ignore-windows - this is a unix-specific test

View File

@ -1,15 +1,12 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![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()];
//[mir]~^ call to unsafe function is unsafe and requires unsafe function or block
//[thir]~^^ call to unsafe function `foo` is unsafe and requires unsafe function or block
//~^ call to unsafe function `foo` is unsafe and requires unsafe function or block
foo();
//[mir]~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
//[thir]~^^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
//~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
}

View File

@ -0,0 +1,19 @@
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 `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
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,29 +0,0 @@
error[E0015]: cannot call non-const fn `Y::foo` in statics
--> $DIR/issue-16538.rs:14:23
|
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-16538.rs:14:30
|
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^ 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
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
--> $DIR/issue-16538.rs:14:21
|
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
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0133.
For more information about an error, try `rustc --explain E0015`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
mod Y {
pub type X = usize;
extern "C" {

View File

@ -1,5 +1,5 @@
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
--> $DIR/issue-16538.rs:14:22
--> $DIR/issue-16538.rs:11:22
|
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
@ -7,7 +7,7 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
= 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:14:30
--> $DIR/issue-16538.rs:11:30
|
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^ use of extern static
@ -15,7 +15,7 @@ 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[E0015]: cannot call non-const fn `Y::foo` in statics
--> $DIR/issue-16538.rs:14:23
--> $DIR/issue-16538.rs:11:23
|
LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,11 +0,0 @@
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
--> $DIR/issue-45729-unsafe-in-coroutine.rs:8:9
|
LL | *(1 as *mut u32) = 42;
| ^^^^^^^^^^^^^^^^^^^^^ 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
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(coroutines)]
fn main() {

View File

@ -1,5 +1,5 @@
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
--> $DIR/issue-45729-unsafe-in-coroutine.rs:8:9
--> $DIR/issue-45729-unsafe-in-coroutine.rs:5:9
|
LL | *(1 as *mut u32) = 42;
| ^^^^^^^^^^^^^^^^ dereference of raw pointer

View File

@ -1,6 +1,4 @@
// build-pass
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![feature(coroutines)]

View File

@ -1,11 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/E0133.rs:7:5
|
LL | f();
| ^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
unsafe fn f() { return; }
fn main() {

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
--> $DIR/E0133.rs:7:5
--> $DIR/E0133.rs:4:5
|
LL | f();
| ^^^ call to unsafe function

View File

@ -1,11 +0,0 @@
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28324.rs:8:24
|
LL | pub static BAZ: u32 = *&error_message_count;
| ^^^^^^^^^^^^^^^^^^^^ 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
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
extern "C" {
static error_message_count: u32;
}

View File

@ -1,5 +1,5 @@
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28324.rs:8:25
--> $DIR/issue-28324.rs:5:25
|
LL | pub static BAZ: u32 = *&error_message_count;
| ^^^^^^^^^^^^^^^^^^^ use of extern static

View File

@ -1,11 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/expr-unsafe-err.rs:8:9
|
LL | require_unsafe();
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,7 +1,7 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(inline_const)]
const unsafe fn require_unsafe() -> usize { 1 }
const unsafe fn require_unsafe() -> usize {
1
}
fn main() {
const {

View File

@ -1,6 +1,5 @@
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![warn(unused_unsafe)]
#![feature(inline_const)]
const unsafe fn require_unsafe() -> usize { 1 }

View File

@ -1,11 +1,11 @@
warning: unnecessary `unsafe` block
--> $DIR/expr-unsafe.rs:12:13
--> $DIR/expr-unsafe.rs:11:13
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/expr-unsafe.rs:4:9
--> $DIR/expr-unsafe.rs:3:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^

View File

@ -1,14 +0,0 @@
warning: unnecessary `unsafe` block
--> $DIR/expr-unsafe.rs:12:13
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/expr-unsafe.rs:4:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^
warning: 1 warning emitted

View File

@ -1,6 +1,4 @@
// revisions: mir thir
// [mir]ignore-test This is currently broken
// [thir]compile-flags: -Z thir-unsafeck
// ignore-test This is currently broken
#![allow(incomplete_features)]
#![feature(inline_const_pat)]

View File

@ -1,19 +0,0 @@
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
--> $DIR/pat-unsafe-err.rs:15:13
|
LL | require_unsafe();
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
--> $DIR/pat-unsafe-err.rs:22:13
|
LL | require_unsafe()
| ^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,7 +1,5 @@
// check-pass
// revisions: mir thir
// [mir]ignore-test This is currently broken
// [thir]compile-flags: -Z thir-unsafeck
// ignore-test This is currently broken
#![allow(incomplete_features)]
#![warn(unused_unsafe)]

View File

@ -1,20 +0,0 @@
warning: unnecessary `unsafe` block
--> $DIR/pat-unsafe.rs:19:17
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/pat-unsafe.rs:7:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^
warning: unnecessary `unsafe` block
--> $DIR/pat-unsafe.rs:26:17
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
warning: 2 warnings emitted

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(intrinsics)]
extern "C" {

View File

@ -1,5 +1,5 @@
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28575.rs:11:5
--> $DIR/issue-28575.rs:8:5
|
LL | FOO()
| ^^^ use of extern static

View File

@ -1,11 +0,0 @@
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28575.rs:11:5
|
LL | FOO()
| ^^^ 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
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,27 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/unchecked_math_unsafe.rs:8:15
|
LL | let add = std::intrinsics::unchecked_add(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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/unchecked_math_unsafe.rs:9:15
|
LL | let sub = std::intrinsics::unchecked_sub(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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/unchecked_math_unsafe.rs:10:15
|
LL | let mul = std::intrinsics::unchecked_mul(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(core_intrinsics)]
fn main() {

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function `unchecked_add` is unsafe and requires unsafe function or block
--> $DIR/unchecked_math_unsafe.rs:8:15
--> $DIR/unchecked_math_unsafe.rs:5:15
|
LL | let add = std::intrinsics::unchecked_add(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
@ -7,7 +7,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 `unchecked_sub` is unsafe and requires unsafe function or block
--> $DIR/unchecked_math_unsafe.rs:9:15
--> $DIR/unchecked_math_unsafe.rs:6:15
|
LL | let sub = std::intrinsics::unchecked_sub(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
@ -15,7 +15,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 `unchecked_mul` is unsafe and requires unsafe function or block
--> $DIR/unchecked_math_unsafe.rs:10:15
--> $DIR/unchecked_math_unsafe.rs:7:15
|
LL | let mul = std::intrinsics::unchecked_mul(x, y);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

View File

@ -1,6 +1,4 @@
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
struct Attr {
name: String,

View File

@ -1,11 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/issue-28776.rs:7:5
|
LL | (&ptr::write)(1 as *mut _, 42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
use std::ptr;
fn main() {

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires unsafe function or block
--> $DIR/issue-28776.rs:7:5
--> $DIR/issue-28776.rs:4:5
|
LL | (&ptr::write)(1 as *mut _, 42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

View File

@ -1,6 +1,4 @@
// run-pass
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
use std::ops::Deref;

View File

@ -1,20 +0,0 @@
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:12:9
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/issue-48131.rs:6:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:23:13
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
error: aborting due to 2 previous errors

View File

@ -1,6 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// This note is annotated because the purpose of the test
// is to ensure that certain other notes are not generated.
#![deny(unused_unsafe)] //~ NOTE

View File

@ -1,17 +1,17 @@
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:12:9
--> $DIR/issue-48131.rs:9:9
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/issue-48131.rs:6:9
--> $DIR/issue-48131.rs:3:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:23:13
--> $DIR/issue-48131.rs:20:13
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block

View File

@ -1,11 +0,0 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/issue-5844.rs:8:5
|
LL | issue_5844_aux::rand();
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,9 +1,7 @@
//aux-build:issue-5844-aux.rs
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
extern crate issue_5844_aux;
fn main () {
fn main() {
issue_5844_aux::rand(); //~ ERROR: requires unsafe
}

View File

@ -1,5 +1,5 @@
error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block
--> $DIR/issue-5844.rs:8:5
--> $DIR/issue-5844.rs:6:5
|
LL | issue_5844_aux::rand();
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

View File

@ -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;

View File

@ -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`.

View File

@ -2,8 +2,6 @@
// compile-flags: -C lto
// no-prefer-dynamic
// ignore-emscripten no threads support
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
use std::thread;

View File

@ -1,14 +0,0 @@
error: `{closure@$DIR/non-structural-match-types.rs:12:17: 12:19}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:12:9
|
LL | const { || {} } => {}
| ^^^^^^^^^^^^^^^
error: `{async block@$DIR/non-structural-match-types.rs:15:17: 15:25}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:15:9
|
LL | const { async {} } => {}
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -1,6 +1,4 @@
// edition:2021
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![allow(incomplete_features)]
#![allow(unreachable_code)]

View File

@ -0,0 +1,14 @@
error: `{closure@$DIR/non-structural-match-types.rs:10:17: 10:19}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:10:9
|
LL | const { || {} } => {}
| ^^^^^^^^^^^^^^^
error: `{async block@$DIR/non-structural-match-types.rs:13:17: 13:25}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:13:9
|
LL | const { async {} } => {}
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -1,14 +0,0 @@
error: `{closure@$DIR/non-structural-match-types.rs:12:17: 12:19}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:12:9
|
LL | const { || {} } => {}
| ^^^^^^^^^^^^^^^
error: `{async block@$DIR/non-structural-match-types.rs:15:17: 15:25}` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:15:9
|
LL | const { async {} } => {}
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -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]
}
}
}
}

View File

@ -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

View File

@ -2,8 +2,6 @@
// ignore-android
// ignore-emscripten no processes
// ignore-sgx no processes
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![feature(rustc_private)]

View File

@ -8,8 +8,6 @@
// check-pass
// only-x86_64
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(target_feature_11)]

View File

@ -1,18 +1,16 @@
// Tests #73631: closures inherit `#[target_feature]` annotations
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable="avx")]
#[target_feature(enable = "avx")]
fn also_use_avx() {
println!("Hello from AVX")
}
#[target_feature(enable="avx")]
#[target_feature(enable = "avx")]
fn use_avx() -> Box<dyn Fn()> {
Box::new(|| also_use_avx())
}

View File

@ -1,5 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// only-x86_64
#![feature(target_feature_11)]

View File

@ -0,0 +1,23 @@
error[E0308]: mismatched types
--> $DIR/fn-ptr.rs:9:21
|
LL | #[target_feature(enable = "sse2")]
| ---------------------------------- `#[target_feature]` added here
...
LL | let foo: fn() = foo;
| ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers
| |
| expected due to this
|
= note: expected fn pointer `fn()`
found fn item `fn() {foo}`
= note: fn items are distinct from fn pointers
= note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers
help: consider casting to a fn pointer
|
LL | let foo: fn() = foo as fn();
| ~~~~~~~~~~~
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -1,8 +1,6 @@
// Tests #108655: closures in `#[target_feature]` functions can still be marked #[inline(always)]
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// only-x86_64
#![feature(target_feature_11)]

View File

@ -1,5 +1,3 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// only-x86_64
#![feature(target_feature_11)]
@ -11,7 +9,6 @@ const fn sse2() {}
#[target_feature(enable = "fxsr")]
const fn sse2_and_fxsr() {}
#[target_feature(enable = "avx")]
#[target_feature(enable = "bmi2")]
fn avx_bmi2() {}
@ -26,62 +23,50 @@ impl Quux {
fn foo() {
sse2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
avx_bmi2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
Quux.avx_bmi2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `Quux::avx_bmi2` 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();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
Quux.avx_bmi2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
}
#[target_feature(enable = "avx")]
fn baz() {
sse2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
avx_bmi2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
Quux.avx_bmi2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `Quux::avx_bmi2` 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();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
}
const _: () = sse2();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
const _: () = sse2_and_fxsr();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2_and_fxsr` 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();
//[mir]~^ ERROR call to function with `#[target_feature]` is unsafe
//[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
//~^ ERROR call to function `sse2` with `#[target_feature]` is unsafe
}
fn main() {}

View File

@ -0,0 +1,115 @@
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();
| ^^^^^^ call to function with `#[target_feature]`
|
= 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 `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:27:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= 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 `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:29:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= 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 `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:35:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= 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 `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:37:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= 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 `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:43:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= 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 `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:45:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
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();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
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();
| ^^^^^^ call to function with `#[target_feature]`
|
= 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 `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:58:15
|
LL | const _: () = sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= 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 `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();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= 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 `sse2` with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
--> $DIR/safe-calls.rs:68:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
|
= 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]`
note: an unsafe function restricts its caller, but its body is safe by default
--> $DIR/safe-calls.rs:67:1
|
LL | unsafe fn needs_unsafe_block() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/safe-calls.rs:64:8
|
LL | #[deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,8 +1,6 @@
// run-pass
// ignore-emscripten spawning processes is not supported
// ignore-sgx no processes
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![feature(start)]

View File

@ -1,7 +1,5 @@
// run-pass
// ignore-emscripten FIXME(#45351) hits an LLVM assert
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![feature(repr_simd, platform_intrinsics, concat_idents)]
#![allow(non_camel_case_types)]

View File

@ -3,9 +3,6 @@
// edition:2018
// revisions: mir thir
// [thir]compile-flags: -Zthir-unsafeck
#![allow(dead_code)]
#![deny(unused_unsafe)]

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +0,0 @@
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
--> $DIR/safe-extern-statics-mut.rs:13:13
|
LL | let b = B;
| ^ use of mutable static
|
= 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:14
|
LL | let rb = &B;
| ^^ use of mutable static
|
= 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:15:14
|
LL | let xb = XB;
| ^^ use of mutable static
|
= 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:16:15
|
LL | let xrb = &XB;
| ^^^ 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 4 previous errors
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,6 +1,4 @@
// aux-build:extern-statics.rs
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
extern crate extern_statics;
use extern_statics::*;

View File

@ -1,5 +1,5 @@
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
--> $DIR/safe-extern-statics-mut.rs:13:13
--> $DIR/safe-extern-statics-mut.rs:11:13
|
LL | let b = B;
| ^ use of mutable static
@ -7,7 +7,7 @@ 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:14:15
--> $DIR/safe-extern-statics-mut.rs:12:15
|
LL | let rb = &B;
| ^ use of mutable static
@ -15,7 +15,7 @@ LL | let rb = &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:15:14
--> $DIR/safe-extern-statics-mut.rs:13:14
|
LL | let xb = XB;
| ^^ use of mutable static
@ -23,7 +23,7 @@ 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:16:16
--> $DIR/safe-extern-statics-mut.rs:14:16
|
LL | let xrb = &XB;
| ^^ use of mutable static

Some files were not shown because too many files have changed in this diff Show More