1
Fork 0

general fixups and turn TODOs into FIXMEs

This commit is contained in:
Deadbeef 2024-06-25 09:57:31 +00:00
parent 373e906296
commit 0a2330630d
16 changed files with 31 additions and 96 deletions

View file

@ -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()

View file

@ -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));

View file

@ -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));
}

View file

@ -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:
//