Skip to content

Commit 0a23306

Browse files
committed
general fixups and turn TODOs into FIXMEs
1 parent 373e906 commit 0a23306

File tree

16 files changed

+31
-96
lines changed

16 files changed

+31
-96
lines changed

compiler/rustc_hir_analysis/src/bounds.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> Bounds<'tcx> {
7272
// For `T: ~const Tr` or `T: const Tr`, we need to add an additional bound on the
7373
// associated type of `<T as Tr>` and make sure that the effect is compatible.
7474
if let Some(compat_val) = match (tcx.def_kind(defining_def_id), constness) {
75-
// TODO: do we need `T: const Trait` anymore?
75+
// FIXME(effects): revisit the correctness of this
7676
(_, ty::BoundConstness::Const) => Some(tcx.consts.false_),
7777
// body owners that can have trait bounds
7878
(DefKind::Const | DefKind::Fn | DefKind::AssocFn, ty::BoundConstness::ConstIfConst) => {
@@ -120,7 +120,7 @@ impl<'tcx> Bounds<'tcx> {
120120
// FIXME(effects) this is equality for now, which wouldn't be helpful for a non-const implementor
121121
// that uses a `Bar` that implements `Trait` with `Maybe` effects.
122122
(DefKind::AssocTy, ty::BoundConstness::ConstIfConst) => {
123-
// TODO write the actual impl
123+
// FIXME(effects): implement this
124124
return;
125125
}
126126
// probably illegal in this position.
@@ -169,7 +169,7 @@ impl<'tcx> Bounds<'tcx> {
169169

170170
pub fn clauses(
171171
&self,
172-
// TODO remove tcx
172+
// FIXME(effects): remove tcx
173173
_tcx: TyCtxt<'tcx>,
174174
) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
175175
self.clauses.iter().cloned()

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,16 @@ pub(super) fn explicit_item_bounds_with_filter(
134134

135135
if let ty::AssocItemContainer::TraitContainer = tcx.associated_item(def_id).container {
136136
// for traits, emit `type Effects: TyCompat<<(T1::Effects, ..) as Min>::Output>`
137-
// TODO do the same for impls
138137
let tup = Ty::new(tcx, ty::Tuple(preds.effects_min_tys));
139-
// TODO span
138+
// FIXME(effects) span
140139
let span = tcx.def_span(def_id);
141140
let assoc = tcx.require_lang_item(hir::LangItem::EffectsMinOutput, Some(span));
142141
let proj = Ty::new_projection(tcx, assoc, [tup]);
143-
let self_proj = Ty::new_projection(tcx, def_id.to_def_id(), ty::GenericArgs::identity_for_item(tcx, def_id));
142+
let self_proj = Ty::new_projection(
143+
tcx,
144+
def_id.to_def_id(),
145+
ty::GenericArgs::identity_for_item(tcx, def_id),
146+
);
144147
let trait_ = tcx.require_lang_item(hir::LangItem::EffectsTyCompat, Some(span));
145148
let trait_ref = ty::TraitRef::new(tcx, trait_, [self_proj, proj]);
146149
predicates.push((ty::Binder::dummy(trait_ref).upcast(tcx), span));

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
323323
let Some(assoc_def_id) = tcx.associated_type_for_effects(parent) else {
324324
bug!("associated_type_for_effects returned None when there is host effect in generics");
325325
};
326-
let effects = Ty::new_projection(tcx, assoc_def_id, ty::GenericArgs::identity_for_item(tcx, parent));
326+
let effects =
327+
Ty::new_projection(tcx, assoc_def_id, ty::GenericArgs::identity_for_item(tcx, parent));
327328
let param = generics.param_at(host_effect_index, tcx);
328329
let span = tcx.def_span(param.def_id);
329330
let host = ty::Const::new_param(tcx, ty::ParamConst::for_def(param));
330331
let compat = tcx.require_lang_item(LangItem::EffectsCompat, Some(span));
331-
let trait_ref = ty::TraitRef::new(tcx, compat, [ty::GenericArg::from(effects), host.into()]);
332+
let trait_ref =
333+
ty::TraitRef::new(tcx, compat, [ty::GenericArg::from(effects), host.into()]);
332334
predicates.push((ty::Binder::dummy(trait_ref).upcast(tcx), span));
333335
}
334336

compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub fn lower_generic_args<'tcx: 'a, 'a>(
256256
| GenericParamDefKind::Lifetime,
257257
_,
258258
) => {
259-
// TODO: this should be removed
259+
// FIXME(effects): this should be removed
260260
// SPECIAL CASE FOR DESUGARED EFFECT PARAMS
261261
// This comes from the following example:
262262
//

compiler/rustc_hir_typeck/src/method/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
404404
debug!("lookup_in_trait_adjusted: method_item={:?}", method_item);
405405
let mut obligations = vec![];
406406

407-
// TODO there is something wrong here because now methods for binops may get `const host: bool`
407+
// FIXME(effects): revisit when binops get `#[const_trait]`
408408

409409
// Instantiate late-bound regions and instantiate the trait
410410
// parameters into the method type to get the actual method type.

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,6 @@ where
873873
return Err(NoSolution);
874874
};
875875

876-
877876
let cx = ecx.cx();
878877

879878
let mut first_non_maybe = None;
@@ -907,11 +906,11 @@ where
907906
let Some(kind) = ty::EffectKind::try_from_ty(cx, ty) else {
908907
return Err(NoSolution);
909908
};
910-
909+
911910
let Some(result) = ty::EffectKind::min(min, kind) else {
912911
return Err(NoSolution);
913912
};
914-
913+
915914
min = result;
916915
}
917916

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,11 @@ where
731731
let Some(kind) = ty::EffectKind::try_from_ty(ecx.cx(), ty) else {
732732
return Err(NoSolution);
733733
};
734-
734+
735735
let Some(result) = ty::EffectKind::min(min, kind) else {
736736
return Err(NoSolution);
737737
};
738-
738+
739739
min = result;
740740
}
741741
}

compiler/rustc_ty_utils/src/assoc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn associated_type_for_effects(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<De
255255
return None;
256256
};
257257

258-
// TODO span is bad
258+
// FIXME(effects): span
259259
let span = tcx.def_ident_span(def_id).unwrap();
260260

261261
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
291291
} else {
292292
tcx.require_lang_item(hir::LangItem::EffectsRuntime, Some(span))
293293
};
294-
// TODO this is wrong
294+
// FIXME(effects): make impls use `Min` for their effect types
295295
impl_assoc_ty.type_of(ty::EarlyBinder::bind(Ty::new_adt(
296296
tcx,
297297
tcx.adt_def(type_def_id),

compiler/rustc_type_ir/src/effects.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::lang_items::TraitSolverLangItem::{EffectsMaybe, EffectsRuntime, EffectsNoRuntime};
2-
use crate::Interner;
31
use crate::inherent::{AdtDef, IntoKind, Ty};
2+
use crate::lang_items::TraitSolverLangItem::{EffectsMaybe, EffectsNoRuntime, EffectsRuntime};
3+
use crate::Interner;
44

55
#[derive(Clone, Copy, PartialEq, Eq)]
66
pub enum EffectKind {
@@ -53,4 +53,4 @@ impl EffectKind {
5353
(Runtime, NoRuntime) | (NoRuntime, Runtime) => None,
5454
}
5555
}
56-
}
56+
}

library/core/src/marker.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,9 @@ pub macro SmartPointer($item:item) {
10281028
/* compiler built-in */
10291029
}
10301030

1031+
// Support traits and types for the desugaring of const traits and
1032+
// `~const` bounds. Not supposed to be used by anything other than
1033+
// the compiler.
10311034
#[doc(hidden)]
10321035
#[unstable(
10331036
feature = "effect_types",
@@ -1036,7 +1039,6 @@ pub macro SmartPointer($item:item) {
10361039
)]
10371040
#[allow(missing_debug_implementations)] // these unit structs don't need `Debug` impls.
10381041
#[cfg(not(bootstrap))]
1039-
// TODO docs
10401042
pub mod effects {
10411043
#[lang = "EffectsNoRuntime"]
10421044
pub struct NoRuntime;

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.qualified.stderr

-27
This file was deleted.

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-0.unqualified.stderr

-11
This file was deleted.

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// FIXME(effects): Collapse the revisions into one once we support `<Ty as const Trait>::Proj`.
2-
//@ revisions: unqualified qualified
3-
//@known-bug: unknown
1+
//@ known-bug: unknown
2+
// FIXME(effects)
43

54
#![feature(const_trait_impl, effects, generic_const_exprs)]
65
#![allow(incomplete_features)]

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.unqualified.stderr

-33
This file was deleted.

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ trait Foo {
3232
}
3333

3434
impl const Foo for NonConstAdd {
35-
type Bar = NonConstAdd; // FIXME(effects) ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied
35+
type Bar = NonConstAdd;
36+
// FIXME(effects) ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied
3637
}
3738

3839
#[const_trait]

0 commit comments

Comments
 (0)