@@ -1754,10 +1754,17 @@ pub enum StatementKind<'tcx> {
1754
1754
inputs : Box < [ Operand < ' tcx > ] > ,
1755
1755
} ,
1756
1756
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
+ } ,
1761
1768
1762
1769
/// Mark one terminating point of a region scope (i.e. static region).
1763
1770
/// (The starting point(s) arise implicitly from borrows.)
@@ -1810,57 +1817,6 @@ pub enum FakeReadCause {
1810
1817
ForLet ,
1811
1818
}
1812
1819
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
-
1864
1820
impl < ' tcx > Debug for Statement < ' tcx > {
1865
1821
fn fmt ( & self , fmt : & mut Formatter < ' _ > ) -> fmt:: Result {
1866
1822
use self :: StatementKind :: * ;
@@ -1869,7 +1825,8 @@ impl<'tcx> Debug for Statement<'tcx> {
1869
1825
FakeRead ( ref cause, ref place) => write ! ( fmt, "FakeRead({:?}, {:?})" , cause, place) ,
1870
1826
// (reuse lifetime rendering policy from ppaux.)
1871
1827
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) ,
1873
1830
StorageLive ( ref place) => write ! ( fmt, "StorageLive({:?})" , place) ,
1874
1831
StorageDead ( ref place) => write ! ( fmt, "StorageDead({:?})" , place) ,
1875
1832
SetDiscriminant {
@@ -2944,7 +2901,6 @@ CloneTypeFoldableAndLiftImpls! {
2944
2901
SourceInfo ,
2945
2902
UpvarDecl ,
2946
2903
FakeReadCause ,
2947
- ValidationOp ,
2948
2904
SourceScope ,
2949
2905
SourceScopeData ,
2950
2906
SourceScopeLocalData ,
@@ -2997,12 +2953,6 @@ BraceStructTypeFoldableImpl! {
2997
2953
}
2998
2954
}
2999
2955
3000
- BraceStructTypeFoldableImpl ! {
3001
- impl <' tcx> TypeFoldable <' tcx> for ValidationOperand <' tcx, Place <' tcx>> {
3002
- place, ty, re, mutbl
3003
- }
3004
- }
3005
-
3006
2956
BraceStructTypeFoldableImpl ! {
3007
2957
impl <' tcx> TypeFoldable <' tcx> for Statement <' tcx> {
3008
2958
source_info, kind
@@ -3017,7 +2967,7 @@ EnumTypeFoldableImpl! {
3017
2967
( StatementKind :: StorageLive ) ( a) ,
3018
2968
( StatementKind :: StorageDead ) ( a) ,
3019
2969
( StatementKind :: InlineAsm ) { asm, outputs, inputs } ,
3020
- ( StatementKind :: Validate ) ( a , b ) ,
2970
+ ( StatementKind :: Retag ) { fn_entry , place } ,
3021
2971
( StatementKind :: EndRegion ) ( a) ,
3022
2972
( StatementKind :: AscribeUserType ) ( a, v, b) ,
3023
2973
( StatementKind :: Nop ) ,
0 commit comments