diff options
16 files changed, 31 insertions, 96 deletions
diff --git a/compiler/rustc_hir_analysis/src/bounds.rs b/compiler/rustc_hir_analysis/src/bounds.rs index 0b03eeaced1..61b7dd8bb8c 100644 --- a/compiler/rustc_hir_analysis/src/bounds.rs +++ b/compiler/rustc_hir_analysis/src/bounds.rs @@ -72,7 +72,7 @@ impl<'tcx> Bounds<'tcx> { // For `T: ~const Tr` or `T: const Tr`, we need to add an additional bound on the // associated type of `<T as Tr>` and make sure that the effect is compatible. if let Some(compat_val) = match (tcx.def_kind(defining_def_id), constness) { - // TODO: do we need `T: const Trait` anymore? + // FIXME(effects): revisit the correctness of this (_, ty::BoundConstness::Const) => Some(tcx.consts.false_), // body owners that can have trait bounds (DefKind::Const | DefKind::Fn | DefKind::AssocFn, ty::BoundConstness::ConstIfConst) => { @@ -120,7 +120,7 @@ impl<'tcx> Bounds<'tcx> { // FIXME(effects) this is equality for now, which wouldn't be helpful for a non-const implementor // that uses a `Bar` that implements `Trait` with `Maybe` effects. (DefKind::AssocTy, ty::BoundConstness::ConstIfConst) => { - // TODO write the actual impl + // FIXME(effects): implement this return; } // probably illegal in this position. @@ -169,7 +169,7 @@ impl<'tcx> Bounds<'tcx> { pub fn clauses( &self, - // TODO remove tcx + // FIXME(effects): remove tcx _tcx: TyCtxt<'tcx>, ) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ { self.clauses.iter().cloned() diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index c8c82c711de..b32067ebd6a 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -134,13 +134,16 @@ pub(super) fn explicit_item_bounds_with_filter( if let ty::AssocItemContainer::TraitContainer = tcx.associated_item(def_id).container { // for traits, emit `type Effects: TyCompat<<(T1::Effects, ..) as Min>::Output>` - // TODO do the same for impls let tup = Ty::new(tcx, ty::Tuple(preds.effects_min_tys)); - // TODO span + // FIXME(effects) span let span = tcx.def_span(def_id); let assoc = tcx.require_lang_item(hir::LangItem::EffectsMinOutput, Some(span)); let proj = Ty::new_projection(tcx, assoc, [tup]); - let self_proj = Ty::new_projection(tcx, def_id.to_def_id(), ty::GenericArgs::identity_for_item(tcx, def_id)); + let self_proj = Ty::new_projection( + tcx, + def_id.to_def_id(), + ty::GenericArgs::identity_for_item(tcx, def_id), + ); let trait_ = tcx.require_lang_item(hir::LangItem::EffectsTyCompat, Some(span)); let trait_ref = ty::TraitRef::new(tcx, trait_, [self_proj, proj]); predicates.push((ty::Binder::dummy(trait_ref).upcast(tcx), span)); diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index cc3078f037a..1c3c1a79cfb 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -323,12 +323,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen let Some(assoc_def_id) = tcx.associated_type_for_effects(parent) else { bug!("associated_type_for_effects returned None when there is host effect in generics"); }; - let effects = Ty::new_projection(tcx, assoc_def_id, ty::GenericArgs::identity_for_item(tcx, parent)); + let effects = + Ty::new_projection(tcx, assoc_def_id, ty::GenericArgs::identity_for_item(tcx, parent)); let param = generics.param_at(host_effect_index, tcx); let span = tcx.def_span(param.def_id); let host = ty::Const::new_param(tcx, ty::ParamConst::for_def(param)); let compat = tcx.require_lang_item(LangItem::EffectsCompat, Some(span)); - let trait_ref = ty::TraitRef::new(tcx, compat, [ty::GenericArg::from(effects), host.into()]); + let trait_ref = + ty::TraitRef::new(tcx, compat, [ty::GenericArg::from(effects), host.into()]); predicates.push((ty::Binder::dummy(trait_ref).upcast(tcx), span)); } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 67046b5ac0e..e92c377f0ce 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -256,7 +256,7 @@ pub fn lower_generic_args<'tcx: 'a, 'a>( | GenericParamDefKind::Lifetime, _, ) => { - // TODO: this should be removed + // FIXME(effects): this should be removed // SPECIAL CASE FOR DESUGARED EFFECT PARAMS // This comes from the following example: // diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index dad909fc4e1..ff8899ae036 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -404,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("lookup_in_trait_adjusted: method_item={:?}", method_item); let mut obligations = vec![]; - // TODO there is something wrong here because now methods for binops may get `const host: bool` + // FIXME(effects): revisit when binops get `#[const_trait]` // Instantiate late-bound regions and instantiate the trait // parameters into the method type to get the actual method type. diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs index f75c30eda99..55c0440a537 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs @@ -873,7 +873,6 @@ where return Err(NoSolution); }; - let cx = ecx.cx(); let mut first_non_maybe = None; @@ -907,11 +906,11 @@ where let Some(kind) = ty::EffectKind::try_from_ty(cx, ty) else { return Err(NoSolution); }; - + let Some(result) = ty::EffectKind::min(min, kind) else { return Err(NoSolution); }; - + min = result; } diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 8c6e5eb5a4d..73ae1c4b113 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -731,11 +731,11 @@ where let Some(kind) = ty::EffectKind::try_from_ty(ecx.cx(), ty) else { return Err(NoSolution); }; - + let Some(result) = ty::EffectKind::min(min, kind) else { return Err(NoSolution); }; - + min = result; } } diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 681f089e84f..6a55e83786c 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -255,7 +255,7 @@ fn associated_type_for_effects(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<De return None; }; - // TODO span is bad + // FIXME(effects): span let span = tcx.def_ident_span(def_id).unwrap(); let impl_assoc_ty = tcx.at(span).create_def(def_id, kw::Empty, DefKind::AssocTy); @@ -291,7 +291,7 @@ fn associated_type_for_effects(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<De } else { tcx.require_lang_item(hir::LangItem::EffectsRuntime, Some(span)) }; - // TODO this is wrong + // FIXME(effects): make impls use `Min` for their effect types impl_assoc_ty.type_of(ty::EarlyBinder::bind(Ty::new_adt( tcx, tcx.adt_def(type_def_id), diff --git a/compiler/rustc_type_ir/src/effects.rs b/compiler/rustc_type_ir/src/effects.rs index 259072de6e7..39605936e30 100644 --- a/compiler/rustc_type_ir/src/effects.rs +++ b/compiler/rustc_type_ir/src/effects.rs @@ -1,6 +1,6 @@ -use crate::lang_items::TraitSolverLangItem::{EffectsMaybe, EffectsRuntime, EffectsNoRuntime}; -use crate::Interner; use crate::inherent::{AdtDef, IntoKind, Ty}; +use crate::lang_items::TraitSolverLangItem::{EffectsMaybe, EffectsNoRuntime, EffectsRuntime}; +use crate::Interner; #[derive(Clone, Copy, PartialEq, Eq)] pub enum EffectKind { @@ -53,4 +53,4 @@ impl EffectKind { (Runtime, NoRuntime) | (NoRuntime, Runtime) => None, } } -} \ No newline at end of file +} diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index b71bedaa194..042acbf20b1 100644 --- a/library/core/src/marker.rs +++ b/library/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; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.qualified.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.qualified.stderr deleted file mode 100644 index 1af0f481943..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.qualified.stderr +++ /dev/null @@ -1,27 +0,0 @@ -warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/assoc-type-const-bound-usage-0.rs:6:30 - | -LL | #![feature(const_trait_impl, effects)] - | ^^^^^^^ - | - = note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied - --> $DIR/assoc-type-const-bound-usage-0.rs:21:5 - | -LL | <T as /* FIXME: ~const */ Trait>::Assoc::func() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}` - | -note: required by a bound in `Trait::func` - --> $DIR/assoc-type-const-bound-usage-0.rs:8:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ required by this bound in `Trait::func` -... -LL | fn func() -> i32; - | ---- required by a bound in this associated function - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.unqualified.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.unqualified.stderr deleted file mode 100644 index 3d592834600..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.unqualified.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/assoc-type-const-bound-usage-0.rs:6:30 - | -LL | #![feature(const_trait_impl, effects)] - | ^^^^^^^ - | - = note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.rs index 5394c3f2d07..8a1bf75f87e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.rs @@ -1,6 +1,5 @@ -// FIXME(effects): Collapse the revisions into one once we support `<Ty as const Trait>::Proj`. -//@ revisions: unqualified qualified -//@known-bug: unknown +//@ known-bug: unknown +// FIXME(effects) #![feature(const_trait_impl, effects, generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.qualified.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.stderr index f8bab2d4c27..f8bab2d4c27 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.qualified.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.stderr diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.unqualified.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.unqualified.stderr deleted file mode 100644 index f8bab2d4c27..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.unqualified.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied - --> $DIR/assoc-type-const-bound-usage-1.rs:16:44 - | -LL | fn unqualified<T: const Trait>() -> Type<{ T::Assoc::func() }> { - | ^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}` - | -note: required by a bound in `Trait::func` - --> $DIR/assoc-type-const-bound-usage-1.rs:8:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ required by this bound in `Trait::func` -... -LL | fn func() -> i32; - | ---- required by a bound in this associated function - -error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied - --> $DIR/assoc-type-const-bound-usage-1.rs:20:42 - | -LL | fn qualified<T: const Trait>() -> Type<{ <T as Trait>::Assoc::func() }> { - | ^^^^^^^^^^^^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}` - | -note: required by a bound in `Trait::func` - --> $DIR/assoc-type-const-bound-usage-1.rs:8:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ required by this bound in `Trait::func` -... -LL | fn func() -> i32; - | ---- required by a bound in this associated function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs index b542ec4e5d0..348bf839b69 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs @@ -32,7 +32,8 @@ trait Foo { } impl const Foo for NonConstAdd { - type Bar = NonConstAdd; // FIXME(effects) ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied + type Bar = NonConstAdd; + // FIXME(effects) ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied } #[const_trait] |
