@@ -1754,10 +1754,17 @@ pub enum StatementKind<'tcx> {
17541754 inputs : Box < [ Operand < ' tcx > ] > ,
17551755 } ,
17561756
1757- /// Assert the given places to be valid inhabitants of their type. These statements are
1758- /// currently only interpreted by miri and only generated when "-Z mir-emit-validate" is passed.
1759- /// See <https://internals.rust-lang.org/t/types-as-contracts/5562/73> for more details.
1760- Validate ( ValidationOp , Vec < ValidationOperand < ' tcx , Place < ' tcx > > > ) ,
1757+ /// Retag references in the given place, ensuring they got fresh tags. This is
1758+ /// part of the Stacked Borrows model. These statements are currently only interpreted
1759+ /// by miri and only generated when "-Z mir-emit-retag" is passed.
1760+ /// See <https://internals.rust-lang.org/t/stacked-borrows-an-aliasing-model-for-rust/8153/>
1761+ /// for more details.
1762+ Retag {
1763+ /// `fn_entry` indicates whether this is the initial retag that happens in the
1764+ /// function prolog.
1765+ fn_entry : bool ,
1766+ place : Place < ' tcx > ,
1767+ } ,
17611768
17621769 /// Mark one terminating point of a region scope (i.e. static region).
17631770 /// (The starting point(s) arise implicitly from borrows.)
@@ -1810,57 +1817,6 @@ pub enum FakeReadCause {
18101817 ForLet ,
18111818}
18121819
1813- /// The `ValidationOp` describes what happens with each of the operands of a
1814- /// `Validate` statement.
1815- #[ derive( Copy , Clone , RustcEncodable , RustcDecodable , PartialEq , Eq ) ]
1816- pub enum ValidationOp {
1817- /// Recursively traverse the place following the type and validate that all type
1818- /// invariants are maintained. Furthermore, acquire exclusive/read-only access to the
1819- /// memory reachable from the place.
1820- Acquire ,
1821- /// Recursive traverse the *mutable* part of the type and relinquish all exclusive
1822- /// access.
1823- Release ,
1824- /// Recursive traverse the *mutable* part of the type and relinquish all exclusive
1825- /// access *until* the given region ends. Then, access will be recovered.
1826- Suspend ( region:: Scope ) ,
1827- }
1828-
1829- impl Debug for ValidationOp {
1830- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1831- use self :: ValidationOp :: * ;
1832- match * self {
1833- Acquire => write ! ( fmt, "Acquire" ) ,
1834- Release => write ! ( fmt, "Release" ) ,
1835- // (reuse lifetime rendering policy from ppaux.)
1836- Suspend ( ref ce) => write ! ( fmt, "Suspend({})" , ty:: ReScope ( * ce) ) ,
1837- }
1838- }
1839- }
1840-
1841- // This is generic so that it can be reused by miri
1842- #[ derive( Clone , Hash , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
1843- pub struct ValidationOperand < ' tcx , T > {
1844- pub place : T ,
1845- pub ty : Ty < ' tcx > ,
1846- pub re : Option < region:: Scope > ,
1847- pub mutbl : hir:: Mutability ,
1848- }
1849-
1850- impl < ' tcx , T : Debug > Debug for ValidationOperand < ' tcx , T > {
1851- fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1852- write ! ( fmt, "{:?}: {:?}" , self . place, self . ty) ?;
1853- if let Some ( ce) = self . re {
1854- // (reuse lifetime rendering policy from ppaux.)
1855- write ! ( fmt, "/{}" , ty:: ReScope ( ce) ) ?;
1856- }
1857- if let hir:: MutImmutable = self . mutbl {
1858- write ! ( fmt, " (imm)" ) ?;
1859- }
1860- Ok ( ( ) )
1861- }
1862- }
1863-
18641820impl < ' tcx > Debug for Statement < ' tcx > {
18651821 fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
18661822 use self :: StatementKind :: * ;
@@ -1869,7 +1825,8 @@ impl<'tcx> Debug for Statement<'tcx> {
18691825 FakeRead ( ref cause, ref place) => write ! ( fmt, "FakeRead({:?}, {:?})" , cause, place) ,
18701826 // (reuse lifetime rendering policy from ppaux.)
18711827 EndRegion ( ref ce) => write ! ( fmt, "EndRegion({})" , ty:: ReScope ( * ce) ) ,
1872- Validate ( ref op, ref places) => write ! ( fmt, "Validate({:?}, {:?})" , op, places) ,
1828+ Retag { fn_entry, ref place } =>
1829+ write ! ( fmt, "Retag({}{:?})" , if fn_entry { "[fn entry] " } else { "" } , place) ,
18731830 StorageLive ( ref place) => write ! ( fmt, "StorageLive({:?})" , place) ,
18741831 StorageDead ( ref place) => write ! ( fmt, "StorageDead({:?})" , place) ,
18751832 SetDiscriminant {
@@ -2944,7 +2901,6 @@ CloneTypeFoldableAndLiftImpls! {
29442901 SourceInfo ,
29452902 UpvarDecl ,
29462903 FakeReadCause ,
2947- ValidationOp ,
29482904 SourceScope ,
29492905 SourceScopeData ,
29502906 SourceScopeLocalData ,
@@ -2997,12 +2953,6 @@ BraceStructTypeFoldableImpl! {
29972953 }
29982954}
29992955
3000- BraceStructTypeFoldableImpl ! {
3001- impl <' tcx> TypeFoldable <' tcx> for ValidationOperand <' tcx, Place <' tcx>> {
3002- place, ty, re, mutbl
3003- }
3004- }
3005-
30062956BraceStructTypeFoldableImpl ! {
30072957 impl <' tcx> TypeFoldable <' tcx> for Statement <' tcx> {
30082958 source_info, kind
@@ -3017,7 +2967,7 @@ EnumTypeFoldableImpl! {
30172967 ( StatementKind :: StorageLive ) ( a) ,
30182968 ( StatementKind :: StorageDead ) ( a) ,
30192969 ( StatementKind :: InlineAsm ) { asm, outputs, inputs } ,
3020- ( StatementKind :: Validate ) ( a , b ) ,
2970+ ( StatementKind :: Retag ) { fn_entry , place } ,
30212971 ( StatementKind :: EndRegion ) ( a) ,
30222972 ( StatementKind :: AscribeUserType ) ( a, v, b) ,
30232973 ( StatementKind :: Nop ) ,
0 commit comments