From cc4a0293697ca5dce8a518f6d5aa0036a1bd94d1 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 14 Jun 2024 12:16:15 +0000 Subject: [PATCH] implement new effects desugaring --- core/src/lib.rs | 1 + core/src/marker.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/core/src/lib.rs b/core/src/lib.rs index d1692729a31b4..cfadfb0233ea7 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -231,6 +231,7 @@ #![feature(let_chains)] #![feature(link_llvm_intrinsics)] #![feature(macro_metavar_expr)] +#![feature(marker_trait_attr)] #![feature(min_exhaustive_patterns)] #![feature(min_specialization)] #![feature(multiple_supertrait_upcastable)] diff --git a/core/src/marker.rs b/core/src/marker.rs index 0fedb8835d1ae..b3f3cc021261f 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -1027,3 +1027,41 @@ pub trait FnPtr: Copy + Clone { pub macro SmartPointer($item:item) { /* compiler built-in */ } + +#[doc(hidden)] +#[unstable( + feature = "effect_types", + issue = "none", + reason = "internal module for implementing effects" +)] +#[allow(missing_debug_implementations)] // these unit structs don't need `Debug` impls. +#[cfg(not(bootstrap))] +// TODO docs +pub mod effects { + #[lang = "EffectsNoRuntime"] + pub struct NoRuntime; + #[lang = "EffectsMaybe"] + pub struct Maybe; + #[lang = "EffectsRuntime"] + pub struct Runtime; + + #[lang = "EffectsCompat"] + pub trait Compat<#[rustc_runtime] const RUNTIME: bool> {} + + impl Compat for NoRuntime {} + impl Compat for Runtime {} + impl<#[rustc_runtime] const RUNTIME: bool> Compat for Maybe {} + + #[lang = "EffectsTyCompat"] + #[marker] + pub trait TyCompat {} + + impl TyCompat for T {} + impl TyCompat for Maybe {} + + #[lang = "EffectsMin"] + pub trait Min { + #[lang = "EffectsMinOutput"] + type Output; + } +}