Auto merge of #2350 - RalfJung:remove-deprecated, r=oli-obk

remove deprecated options

These have been deprecated a month ago and nobody said they need them. Is that enough time? We can also let this PR sit a little.

Cc https://github.com/rust-lang/miri/issues/2187 https://github.com/rust-lang/miri/issues/2188
(keeping them open to track removing their supporting infrastructure in the core interpreter)
This commit is contained in:
bors 2022-07-19 12:29:29 +00:00
commit 8757d866ab
11 changed files with 11 additions and 354 deletions

View File

@ -329,17 +329,6 @@ The remaining flags are for advanced use only, and more likely to change or be r
Some of these are **unsound**, which means they can lead
to Miri failing to detect cases of undefined behavior in a program.
* `-Zmiri-allow-uninit-numbers` disables the check to ensure that number types (integer and float
types) always hold initialized data. (They must still be initialized when any actual operation,
such as arithmetic, is performed.) Using this flag is **unsound** and
[deprecated](https://github.com/rust-lang/miri/issues/2187). This has no effect when
`-Zmiri-disable-validation` is present.
* `-Zmiri-allow-ptr-int-transmute` makes Miri more accepting of transmutation between pointers and
integers via `mem::transmute` or union/pointer type punning. This has two effects: it disables the
check against integers storing a pointer (i.e., data with provenance), thus allowing
pointer-to-integer transmutation, and it treats integer-to-pointer transmutation as equivalent to
a cast. Implies `-Zmiri-permissive-provenance`. Using this flag is **unsound** and
[deprecated](https://github.com/rust-lang/miri/issues/2188).
* `-Zmiri-disable-abi-check` disables checking [function ABI]. Using this flag
is **unsound**.
* `-Zmiri-disable-alignment-check` disables checking pointer alignment, so you

View File

@ -328,19 +328,6 @@ fn main() {
"WARNING: the flag `-Zmiri-check-number-validity` no longer has any effect \
since it is now enabled by default"
);
} else if arg == "-Zmiri-allow-uninit-numbers" {
eprintln!(
"WARNING: `-Zmiri-allow-uninit-numbers` is deprecated and planned to be removed. \
Please let us know at <https://github.com/rust-lang/miri/issues/2187> if you rely on this flag."
);
miri_config.allow_uninit_numbers = true;
} else if arg == "-Zmiri-allow-ptr-int-transmute" {
eprintln!(
"WARNING: `-Zmiri-allow-ptr-int-transmute` is deprecated and planned to be removed. \
Please let us know at <https://github.com/rust-lang/miri/issues/2188> if you rely on this flag."
);
miri_config.allow_ptr_int_transmute = true;
miri_config.provenance_mode = ProvenanceMode::Permissive;
} else if arg == "-Zmiri-disable-abi-check" {
miri_config.check_abi = false;
} else if arg == "-Zmiri-disable-isolation" {
@ -378,7 +365,6 @@ fn main() {
eprintln!("WARNING: `-Zmiri-tag-raw-pointers` has no effect; it is enabled by default");
} else if arg == "-Zmiri-strict-provenance" {
miri_config.provenance_mode = ProvenanceMode::Strict;
miri_config.allow_ptr_int_transmute = false;
} else if arg == "-Zmiri-permissive-provenance" {
miri_config.provenance_mode = ProvenanceMode::Permissive;
} else if arg == "-Zmiri-mute-stdout-stderr" {

View File

@ -77,10 +77,6 @@ pub struct MiriConfig {
pub stacked_borrows: bool,
/// Controls alignment checking.
pub check_alignment: AlignmentCheck,
/// Controls integer and float validity initialization checking.
pub allow_uninit_numbers: bool,
/// Controls how we treat ptr2int and int2ptr transmutes.
pub allow_ptr_int_transmute: bool,
/// Controls function [ABI](Abi) checking.
pub check_abi: bool,
/// Action for an op requiring communication with the host.
@ -134,8 +130,6 @@ impl Default for MiriConfig {
validate: true,
stacked_borrows: true,
check_alignment: AlignmentCheck::Int,
allow_uninit_numbers: false,
allow_ptr_int_transmute: false,
check_abi: true,
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
ignore_leaks: false,

View File

@ -107,19 +107,13 @@ impl<'mir, 'tcx> GlobalStateInner {
}
pub fn ptr_from_addr_transmute(
ecx: &MiriEvalContext<'mir, 'tcx>,
_ecx: &MiriEvalContext<'mir, 'tcx>,
addr: u64,
) -> Pointer<Option<Tag>> {
trace!("Transmuting {:#x} to a pointer", addr);
let provenance = if ecx.machine.allow_ptr_int_transmute {
// When we allow transmutes, treat them like casts: generating a wildcard pointer.
Some(Tag::Wildcard)
} else {
// Usually, we consider transmuted pointers to be "invalid" (`None` provenance).
None
};
Pointer::new(provenance, Size::from_bytes(addr))
// We consider transmuted pointers to be "invalid" (`None` provenance).
Pointer::new(None, Size::from_bytes(addr))
}
pub fn ptr_from_addr_cast(

View File

@ -259,13 +259,6 @@ pub struct Evaluator<'mir, 'tcx> {
/// Whether to enforce the validity invariant.
pub(crate) validate: bool,
/// Whether to allow uninitialized numbers (integers and floats).
pub(crate) allow_uninit_numbers: bool,
/// Whether to allow ptr2int transmutes, and whether to allow *dereferencing* the result of an
/// int2ptr transmute.
pub(crate) allow_ptr_int_transmute: bool,
/// Whether to enforce [ABI](Abi) of function calls.
pub(crate) enforce_abi: bool,
@ -372,8 +365,6 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
tls: TlsData::default(),
isolated_op: config.isolated_op,
validate: config.validate,
allow_uninit_numbers: config.allow_uninit_numbers,
allow_ptr_int_transmute: config.allow_ptr_int_transmute,
enforce_abi: config.check_abi,
file_handler: FileHandler::new(config.mute_stdout_stderr),
dir_handler: Default::default(),
@ -526,13 +517,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
}
#[inline(always)]
fn enforce_number_init(ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
!ecx.machine.allow_uninit_numbers
fn enforce_number_init(_ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
true
}
#[inline(always)]
fn enforce_number_no_provenance(ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
!ecx.machine.allow_ptr_int_transmute
fn enforce_number_no_provenance(_ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
true
}
#[inline(always)]

View File

@ -1,272 +0,0 @@
// Even when uninit numbers are allowed, this enum is not.
//@compile-flags: -Zmiri-allow-uninit-numbers
#![allow(unused, deprecated, invalid_value)]
#[derive(Copy, Clone)]
enum A {
A0,
A1,
A2,
A3,
A4,
A5,
A6,
A7,
A8,
A9,
A10,
A11,
A12,
A13,
A14,
A15,
A16,
A17,
A18,
A19,
A20,
A21,
A22,
A23,
A24,
A25,
A26,
A27,
A28,
A29,
A30,
A31,
A32,
A33,
A34,
A35,
A36,
A37,
A38,
A39,
A40,
A41,
A42,
A43,
A44,
A45,
A46,
A47,
A48,
A49,
A50,
A51,
A52,
A53,
A54,
A55,
A56,
A57,
A58,
A59,
A60,
A61,
A62,
A63,
A64,
A65,
A66,
A67,
A68,
A69,
A70,
A71,
A72,
A73,
A74,
A75,
A76,
A77,
A78,
A79,
A80,
A81,
A82,
A83,
A84,
A85,
A86,
A87,
A88,
A89,
A90,
A91,
A92,
A93,
A94,
A95,
A96,
A97,
A98,
A99,
A100,
A101,
A102,
A103,
A104,
A105,
A106,
A107,
A108,
A109,
A110,
A111,
A112,
A113,
A114,
A115,
A116,
A117,
A118,
A119,
A120,
A121,
A122,
A123,
A124,
A125,
A126,
A127,
A128,
A129,
A130,
A131,
A132,
A133,
A134,
A135,
A136,
A137,
A138,
A139,
A140,
A141,
A142,
A143,
A144,
A145,
A146,
A147,
A148,
A149,
A150,
A151,
A152,
A153,
A154,
A155,
A156,
A157,
A158,
A159,
A160,
A161,
A162,
A163,
A164,
A165,
A166,
A167,
A168,
A169,
A170,
A171,
A172,
A173,
A174,
A175,
A176,
A177,
A178,
A179,
A180,
A181,
A182,
A183,
A184,
A185,
A186,
A187,
A188,
A189,
A190,
A191,
A192,
A193,
A194,
A195,
A196,
A197,
A198,
A199,
A200,
A201,
A202,
A203,
A204,
A205,
A206,
A207,
A208,
A209,
A210,
A211,
A212,
A213,
A214,
A215,
A216,
A217,
A218,
A219,
A220,
A221,
A222,
A223,
A224,
A225,
A226,
A227,
A228,
A229,
A230,
A231,
A232,
A233,
A234,
A235,
A236,
A237,
A238,
A239,
A240,
A241,
A242,
A243,
A244,
A245,
A246,
A247,
A248,
A249,
A250,
A251,
A252,
A253,
A254,
A255,
}
union MyUninit {
init: (),
uninit: A,
}
fn main() {
let _a = unsafe { MyUninit { init: () }.uninit }; //~ ERROR: constructing invalid value at .<enum-tag>: encountered uninitialized bytes, but expected a valid enum tag
}

View File

@ -1,16 +0,0 @@
WARNING: `-Zmiri-allow-uninit-numbers` is deprecated and planned to be removed. Please let us know at <https://github.com/rust-lang/miri/issues/2187> if you rely on this flag.
error: Undefined Behavior: constructing invalid value at .<enum-tag>: encountered uninitialized bytes, but expected a valid enum tag
--> $DIR/invalid_enum_tag_256variants_uninit.rs:LL:CC
|
LL | let _a = unsafe { MyUninit { init: () }.uninit };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered uninitialized bytes, but expected a valid enum tag
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: backtrace:
= note: inside `main` at $DIR/invalid_enum_tag_256variants_uninit.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error

View File

@ -1,13 +1,14 @@
//@compile-flags: -Zmiri-allow-uninit-numbers
#![allow(deprecated)]
use std::mem;
struct Foo {
_inner: i32,
_inner: mem::MaybeUninit<i32>,
}
fn main() {
unsafe {
let foo = Foo { _inner: std::mem::uninitialized() };
let foo = Foo { _inner: mem::uninitialized() };
let _bar = foo;
}
}

View File

@ -1 +0,0 @@
WARNING: `-Zmiri-allow-uninit-numbers` is deprecated and planned to be removed. Please let us know at <https://github.com/rust-lang/miri/issues/2187> if you rely on this flag.

View File

@ -1,8 +0,0 @@
//@compile-flags: -Zmiri-allow-uninit-numbers
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312.
fn main() {
let _val1 = unsafe { std::mem::MaybeUninit::<usize>::uninit().assume_init() };
let _val2 = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
let _val3 = unsafe { std::mem::MaybeUninit::<f32>::uninit().assume_init() };
}

View File

@ -1 +0,0 @@
WARNING: `-Zmiri-allow-uninit-numbers` is deprecated and planned to be removed. Please let us know at <https://github.com/rust-lang/miri/issues/2187> if you rely on this flag.