From cc4a0293697ca5dce8a518f6d5aa0036a1bd94d1 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 14 Jun 2024 12:16:15 +0000 Subject: [PATCH 1/4] 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; + } +} From 47492c9ec941a1698125185372a6bfb82d364bad Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Mon, 24 Jun 2024 16:25:17 +0000 Subject: [PATCH 2/4] Implement `Min` trait in new solver --- core/src/marker.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/marker.rs b/core/src/marker.rs index b3f3cc021261f..b71bedaa1948f 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -1054,14 +1054,15 @@ pub mod effects { #[lang = "EffectsTyCompat"] #[marker] - pub trait TyCompat {} + pub trait TyCompat {} - impl TyCompat for T {} - impl TyCompat for Maybe {} + impl TyCompat for T {} + impl TyCompat for Maybe {} + impl TyCompat for T {} #[lang = "EffectsMin"] pub trait Min { #[lang = "EffectsMinOutput"] - type Output; + type Output: ?Sized; } } From db228b821dda3240d1e1f7e8e2dc75eb2c484d52 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Tue, 25 Jun 2024 09:57:31 +0000 Subject: [PATCH 3/4] general fixups and turn `TODO`s into `FIXME`s --- core/src/marker.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/marker.rs b/core/src/marker.rs index b71bedaa1948f..042acbf20b1a0 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -1028,6 +1028,9 @@ pub macro SmartPointer($item:item) { /* compiler built-in */ } +// Support traits and types for the desugaring of const traits and +// `~const` bounds. Not supposed to be used by anything other than +// the compiler. #[doc(hidden)] #[unstable( feature = "effect_types", @@ -1036,7 +1039,6 @@ pub macro SmartPointer($item:item) { )] #[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; From 729a10a00b8311b6cdb4e46c59b9033692a0976b Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 26 Jun 2024 16:36:42 +0000 Subject: [PATCH 4/4] address review comments --- core/src/marker.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/marker.rs b/core/src/marker.rs index 042acbf20b1a0..9f5818f675d86 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -1062,9 +1062,14 @@ pub mod effects { impl TyCompat for Maybe {} impl TyCompat for T {} - #[lang = "EffectsMin"] - pub trait Min { - #[lang = "EffectsMinOutput"] + #[lang = "EffectsIntersection"] + pub trait Intersection { + #[lang = "EffectsIntersectionOutput"] type Output: ?Sized; } + + // FIXME(effects): remove this after next trait solver lands + impl Intersection for () { + type Output = Maybe; + } }