Skip to content

Add MIR Validate statement #43403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Aug 4, 2017
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5264103
add new instructions for asserting when values are valid, and to desc…
RalfJung Jul 11, 2017
735ace9
add a pass for validation commands; for now just emit the initial Acq…
RalfJung Jul 11, 2017
33585f4
CleanEndRegions: do not clean regions that occur in types in validati…
RalfJung Jul 11, 2017
82786b2
emit validation for function calls and Ref
RalfJung Jul 11, 2017
24a2ac9
add_validation: handle drop
RalfJung Jul 14, 2017
511b88c
only emit Suspend validation for mutable paths
RalfJung Jul 20, 2017
a233afa
respect lifetime rendering when rendering Suspend validation op
RalfJung Jul 20, 2017
60096b9
when suspending, we need to specify for which lifetime to recover
RalfJung Jul 21, 2017
e869cf2
make ValidationOperand generic so that we can reuse it in miri with a…
RalfJung Jul 21, 2017
23cd90e
add -Z flag for AddValidation pass
RalfJung Jul 22, 2017
b6816b2
please the tidy
RalfJung Jul 22, 2017
04f962a
after a Ref, only acquire the Deref'd destination
RalfJung Jul 25, 2017
b934506
Reorder passes so that AddValidation can run after ElaborateDrops
RalfJung Jul 25, 2017
7ec50df
also release/validate around non-Misc casts
RalfJung Jul 27, 2017
57958d1
Add tests for emitting validation statements
RalfJung Jul 28, 2017
29ed317
silence tidy
RalfJung Jul 28, 2017
6641415
do not use doc comments inside functions
RalfJung Jul 30, 2017
6ff7c8f
more documentation
RalfJung Jul 31, 2017
6135461
CleanEndRegions: use default impl where possible
RalfJung Jul 31, 2017
5e426e1
optionally only emit basic validation for functions containing unsafe…
RalfJung Jul 31, 2017
09cbe58
more readable printing of validation operands
RalfJung Jul 31, 2017
26ca0d1
tidy
RalfJung Jul 31, 2017
e73d314
fix AddValidation on methods
RalfJung Aug 1, 2017
584d823
Handle closures. Add some more tests.
RalfJung Aug 1, 2017
4310edb
handle tuple struct ctors
RalfJung Aug 1, 2017
8f910bc
handle trait items as well
RalfJung Aug 1, 2017
c5154d0
use FnLike to recognize functions for us
RalfJung Aug 1, 2017
a8129d1
add a closure inside an unsafe fn to the tests
RalfJung Aug 1, 2017
321a72c
closure unsafety check: stop moving up when we hit an item
RalfJung Aug 2, 2017
7d8dc7a
also release-validate return value before a call
RalfJung Aug 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more documentation
  • Loading branch information
RalfJung committed Jul 31, 2017
commit 6ff7c8fa047f98bfc6f1d7c9abdd64bc557add32
13 changes: 12 additions & 1 deletion src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,9 @@ pub enum StatementKind<'tcx> {
inputs: Vec<Operand<'tcx>>
},

/// Assert the given lvalues to be valid inhabitants of their type.
/// Assert the given lvalues to be valid inhabitants of their type. These statements are
/// currently only interpreted by miri and only generated when "-Z mir-emit-validate" is passed.
/// See <https://internals.rust-lang.org/t/types-as-contracts/5562/73> for more details.
Validate(ValidationOp, Vec<ValidationOperand<'tcx, Lvalue<'tcx>>>),

/// Mark one terminating point of an extent (i.e. static region).
Expand All @@ -836,10 +838,19 @@ pub enum StatementKind<'tcx> {
Nop,
}

/// The `ValidationOp` describes what happens with each of the operands of a
/// `Validate` statement.
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, PartialEq, Eq)]
pub enum ValidationOp {
/// Recursively traverse the lvalue following the type and validate that all type
/// invariants are maintained. Furthermore, acquire exclusive/read-only access to the
/// memory reachable from the lvalue.
Acquire,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document at least a bit the semantics of each of these operations in doc comment form?

/// Recursive traverse the *mutable* part of the type and relinquish all exclusive
/// access.
Release,
/// Recursive traverse the *mutable* part of the type and relinquish all exclusive
/// access *until* the given region ends. Then, access will be recovered.
Suspend(CodeExtent),
}

Expand Down