Skip to content

Commit cc4a029

Browse files
committed
implement new effects desugaring
1 parent 8c3c7dc commit cc4a029

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
#![feature(let_chains)]
232232
#![feature(link_llvm_intrinsics)]
233233
#![feature(macro_metavar_expr)]
234+
#![feature(marker_trait_attr)]
234235
#![feature(min_exhaustive_patterns)]
235236
#![feature(min_specialization)]
236237
#![feature(multiple_supertrait_upcastable)]

core/src/marker.rs

+38
Original file line numberDiff line numberDiff line change
@@ -1027,3 +1027,41 @@ pub trait FnPtr: Copy + Clone {
10271027
pub macro SmartPointer($item:item) {
10281028
/* compiler built-in */
10291029
}
1030+
1031+
#[doc(hidden)]
1032+
#[unstable(
1033+
feature = "effect_types",
1034+
issue = "none",
1035+
reason = "internal module for implementing effects"
1036+
)]
1037+
#[allow(missing_debug_implementations)] // these unit structs don't need `Debug` impls.
1038+
#[cfg(not(bootstrap))]
1039+
// TODO docs
1040+
pub mod effects {
1041+
#[lang = "EffectsNoRuntime"]
1042+
pub struct NoRuntime;
1043+
#[lang = "EffectsMaybe"]
1044+
pub struct Maybe;
1045+
#[lang = "EffectsRuntime"]
1046+
pub struct Runtime;
1047+
1048+
#[lang = "EffectsCompat"]
1049+
pub trait Compat<#[rustc_runtime] const RUNTIME: bool> {}
1050+
1051+
impl Compat<false> for NoRuntime {}
1052+
impl Compat<true> for Runtime {}
1053+
impl<#[rustc_runtime] const RUNTIME: bool> Compat<RUNTIME> for Maybe {}
1054+
1055+
#[lang = "EffectsTyCompat"]
1056+
#[marker]
1057+
pub trait TyCompat<T> {}
1058+
1059+
impl<T> TyCompat<T> for T {}
1060+
impl<T> TyCompat<T> for Maybe {}
1061+
1062+
#[lang = "EffectsMin"]
1063+
pub trait Min {
1064+
#[lang = "EffectsMinOutput"]
1065+
type Output;
1066+
}
1067+
}

0 commit comments

Comments
 (0)