Skip to content

Commit

Permalink
Auto merge of rust-lang#120639 - fee1-dead-contrib:new-effects-desuga…
Browse files Browse the repository at this point in the history
…ring, 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
  • Loading branch information
bors committed Jun 29, 2024
2 parents 171f5db + 729a10a commit 9b3a511
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
46 changes: 46 additions & 0 deletions core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,3 +1024,49 @@ pub trait FnPtr: Copy + Clone {
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",
issue = "none",
reason = "internal module for implementing effects"
)]
#[allow(missing_debug_implementations)] // these unit structs don't need `Debug` impls.
#[cfg(not(bootstrap))]
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<false> for NoRuntime {}
impl Compat<true> for Runtime {}
impl<#[rustc_runtime] const RUNTIME: bool> Compat<RUNTIME> for Maybe {}

#[lang = "EffectsTyCompat"]
#[marker]
pub trait TyCompat<T: ?Sized> {}

impl<T: ?Sized> TyCompat<T> for T {}
impl<T: ?Sized> TyCompat<T> for Maybe {}
impl<T: ?Sized> TyCompat<Maybe> for T {}

#[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;
}
}

0 comments on commit 9b3a511

Please sign in to comment.