-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a ghost! block for ghost code with ownership
- Loading branch information
1 parent
45aede3
commit 256e9a3
Showing
12 changed files
with
302 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::*; | ||
|
||
// FIXME: better doc | ||
/// Any item that implements `Ghost` must **not** be able to break the ownership rules, | ||
/// be it in ghost or runtime code. | ||
/// | ||
/// Additionnaly, it should be zero-sized, so that it's not possible to extract | ||
/// information from a ghost bloc and use it in normal code. | ||
#[rustc_diagnostic_item = "ghost_trait"] | ||
#[trusted] | ||
pub trait Ghost {} | ||
|
||
macro_rules! impl_ghost_tuple { | ||
($($ty_param:ident),*) => { | ||
impl_ghost_tuple!{ @inner $($ty_param,)* || []; } | ||
}; | ||
(@inner $ty_param:ident, $($rest:ident,)* || $( [ $($done:ident,)* ] ;)*) => { | ||
impl_ghost_tuple! { | ||
@inner $($rest,)* || | ||
[] ; $( [ $ty_param, $($done,)* ] ;)* | ||
} | ||
}; | ||
(@inner || $( [ $($done:ident,)* ] ;)*) => { | ||
$( | ||
impl<$($done : Ghost),*> Ghost for ($($done,)*) {} | ||
)* | ||
}; | ||
} | ||
|
||
impl_ghost_tuple! { T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 } | ||
|
||
impl<T> Ghost for Snapshot<T> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.