Skip to content

Commit 9b3a511

Browse files
committed
Auto merge of rust-lang#120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes rust-lang#119717 Fixes rust-lang#123664 Fixes rust-lang#124857 Fixes rust-lang#126148
2 parents 171f5db + 729a10a commit 9b3a511

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-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

+46
Original file line numberDiff line numberDiff line change
@@ -1024,3 +1024,49 @@ pub trait FnPtr: Copy + Clone {
10241024
pub macro SmartPointer($item:item) {
10251025
/* compiler built-in */
10261026
}
1027+
1028+
// Support traits and types for the desugaring of const traits and
1029+
// `~const` bounds. Not supposed to be used by anything other than
1030+
// the compiler.
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+
pub mod effects {
1040+
#[lang = "EffectsNoRuntime"]
1041+
pub struct NoRuntime;
1042+
#[lang = "EffectsMaybe"]
1043+
pub struct Maybe;
1044+
#[lang = "EffectsRuntime"]
1045+
pub struct Runtime;
1046+
1047+
#[lang = "EffectsCompat"]
1048+
pub trait Compat<#[rustc_runtime] const RUNTIME: bool> {}
1049+
1050+
impl Compat<false> for NoRuntime {}
1051+
impl Compat<true> for Runtime {}
1052+
impl<#[rustc_runtime] const RUNTIME: bool> Compat<RUNTIME> for Maybe {}
1053+
1054+
#[lang = "EffectsTyCompat"]
1055+
#[marker]
1056+
pub trait TyCompat<T: ?Sized> {}
1057+
1058+
impl<T: ?Sized> TyCompat<T> for T {}
1059+
impl<T: ?Sized> TyCompat<T> for Maybe {}
1060+
impl<T: ?Sized> TyCompat<Maybe> for T {}
1061+
1062+
#[lang = "EffectsIntersection"]
1063+
pub trait Intersection {
1064+
#[lang = "EffectsIntersectionOutput"]
1065+
type Output: ?Sized;
1066+
}
1067+
1068+
// FIXME(effects): remove this after next trait solver lands
1069+
impl Intersection for () {
1070+
type Output = Maybe;
1071+
}
1072+
}

0 commit comments

Comments
 (0)