Skip to content

Commit

Permalink
Rename the FIXMEs, remove a few that dont matter anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Nov 3, 2024
1 parent 0b5ddf3 commit 6b96103
Show file tree
Hide file tree
Showing 47 changed files with 58 additions and 68 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ pub(crate) struct ConstBoundTraitObject {
pub span: Span,
}

// FIXME(effects): Consider making the note/reason the message of the diagnostic.
// FIXME(effects): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
// FIXME(const_trait_impl): Consider making the note/reason the message of the diagnostic.
// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
#[derive(Diagnostic)]
#[diag(ast_passes_tilde_const_disallowed)]
pub(crate) struct TildeConstDisallowed {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
// typeck ensures the conditions for calling a const trait method are met,
// so we only error if the trait isn't const. We try to resolve the trait
// into the concrete method, and uses that for const stability checks.
// FIXME(effects) we might consider moving const stability checks to typeck as well.
// FIXME(const_trait_impl) we might consider moving const stability checks
// to typeck as well.
if tcx.features().const_trait_impl() && trait_is_const {
// This skips the check below that ensures we only call `const fn`.
is_trait = true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
let implsrc = selcx.select(&obligation);

if let Ok(Some(ImplSource::UserDefined(data))) = implsrc {
// FIXME(effects) revisit this
// FIXME(const_trait_impl) revisit this
if !tcx.is_const_trait_impl(data.impl_def_id) {
let span = tcx.def_span(data.impl_def_id);
err.subdiagnostic(errors::NonConstImplNote { span });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Qualif for NeedsNonConstDrop {
return false;
}

// FIXME(effects): Reimplement const drop checking.
// FIXME(const_trait_impl): Reimplement const drop checking.
NeedsDrop::in_any_value_of_ty(cx, ty)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
// sensitive check here. But we can at least rule out functions that are not const at
// all. That said, we have to allow calling functions inside a trait marked with
// #[const_trait]. These *are* const-checked!
// FIXME(effects): why does `is_const_fn` not classify them as const?
// FIXME(const_trait_impl): why does `is_const_fn` not classify them as const?
if (!ecx.tcx.is_const_fn(def) && !ecx.tcx.is_const_default_method(def))
|| ecx.tcx.has_attr(def, sym::rustc_do_not_const_check)
{
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ fn compare_method_predicate_entailment<'tcx>(
trait_m_predicates.instantiate_own(tcx, trait_to_impl_args).map(|(predicate, _)| predicate),
);

// FIXME(effects): This should be replaced with a more dedicated method.
let is_conditionally_const = tcx.is_conditionally_const(impl_def_id);
if is_conditionally_const {
// Augment the hybrid param-env with the const conditions
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if let Err(guar) = ty.error_reported() {
return ty::Const::new_error(tcx, guar).into();
}
// FIXME(effects) see if we should special case effect params here
if !infer_args && has_default {
tcx.const_param_default(param.def_id)
.instantiate(tcx, preceding_args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ fn trait_predicates_eq<'tcx>(
predicate1: ty::Predicate<'tcx>,
predicate2: ty::Predicate<'tcx>,
) -> bool {
// FIXME(effects)
// FIXME(const_trait_impl)
predicate1 == predicate2
}

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
(fn_sig, Some(def_id))
}
// FIXME(effects): these arms should error because we can't enforce them
// FIXME(const_trait_impl): these arms should error because we can't enforce them
ty::FnPtr(sig_tys, hdr) => (sig_tys.with(hdr), None),
_ => {
for arg in arg_exprs {
Expand Down Expand Up @@ -843,7 +843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
callee_did: DefId,
callee_args: GenericArgsRef<'tcx>,
) {
// FIXME(effects): We should be enforcing these effects unconditionally.
// FIXME(const_trait_impl): We should be enforcing these effects unconditionally.
// This can be done as soon as we convert the standard library back to
// using const traits, since if we were to enforce these conditions now,
// we'd fail on basically every builtin trait call (i.e. `1 + 2`).
Expand All @@ -864,11 +864,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None => return,
};

// FIXME(effects): Should this be `is_const_fn_raw`? It depends on if we move
// FIXME(const_trait_impl): Should this be `is_const_fn_raw`? It depends on if we move
// const stability checking here too, I guess.
if self.tcx.is_conditionally_const(callee_did) {
let q = self.tcx.const_conditions(callee_did);
// FIXME(effects): Use this span with a better cause code.
// FIXME(const_trait_impl): Use this span with a better cause code.
for (cond, _) in q.instantiate(self.tcx, callee_args) {
self.register_predicate(Obligation::new(
self.tcx,
Expand All @@ -878,7 +878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
));
}
} else {
// FIXME(effects): This should eventually be caught here.
// FIXME(const_trait_impl): This should eventually be caught here.
// For now, though, we defer some const checking to MIR.
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3125,7 +3125,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

// FIXME(effects): Please remove this. It's a footgun.
/// Whether the trait impl is marked const. This does not consider stability or feature gates.
pub fn is_const_trait_impl(self, def_id: DefId) -> bool {
self.def_kind(def_id) == DefKind::Impl { of_trait: true }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
let cx = ecx.cx();
let mut candidates = vec![];

// FIXME(effects): We elaborate here because the implied const bounds
// FIXME(const_trait_impl): We elaborate here because the implied const bounds
// aren't necessarily elaborated. We probably should prefix this query
// with `explicit_`...
for clause in elaborate::elaborate(
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ where
return Err(NoSolution);
}

// FIXME(effects): Implement this when we get const working in the new solver

// `Destruct` is automatically implemented for every type in
// non-const environments.
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {

// `impl const Trait for Type` items forward their const stability to their
// immediate children.
// FIXME(effects): how is this supposed to interact with `#[rustc_const_stable_indirect]`?
// FIXME(const_trait_impl): how is this supposed to interact with `#[rustc_const_stable_indirect]`?
// Currently, once that is set, we do not inherit anything from the parent any more.
if const_stab.is_none() {
debug!("annotate: const_stab not found, parent = {:?}", self.parent_const_stab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}

ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
// FIXME(effects): We should recompute the predicate with `~const`
// FIXME(const_trait_impl): We should recompute the predicate with `~const`
// if it's `const`, and if it holds, explain that this bound only
// *conditionally* holds. If that fails, we should also do selection
// to drill this down to an impl or built-in source, so we can
Expand Down Expand Up @@ -2641,7 +2641,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
_span: Span,
) -> UnsatisfiedConst {
let unsatisfied_const = UnsatisfiedConst(false);
// FIXME(effects)
// FIXME(const_trait_impl)
unsatisfied_const
}

Expand Down Expand Up @@ -3052,7 +3052,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// Make a fresh inference variable so we can determine what the generic parameters
// of the trait are.
let var = self.next_ty_var(DUMMY_SP);
// FIXME(effects)
// FIXME(const_trait_impl)
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
let obligation = Obligation::new(
self.tcx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3751,7 +3751,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
trait_pred.skip_binder().self_ty(),
diagnostic_name,
),
// FIXME(effects, const_trait_impl) derive_const as suggestion?
// FIXME(const_trait_impl) derive_const as suggestion?
format!("#[derive({diagnostic_name})]\n"),
Applicability::MaybeIncorrect,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
| ty::PredicateKind::Coerce(_)
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::ConstEquate(..)
// FIXME(effects): We may need to do this using the higher-ranked
// FIXME(const_trait_impl): We may need to do this using the higher-ranked
// pred instead of just instantiating it with placeholders b/c of
// higher-ranked implied bound issues in the old solver.
| ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(..)) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
_obligation: &PolyTraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>,
) {
// FIXME(effects): Destruct is not const yet, and it is implemented
// by all types today in non-const setting.
candidates.vec.push(BuiltinCandidate { has_nested: false });
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ty_utils/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ fn resolve_instance_raw<'tcx>(
}
} else {
debug!(" => free item");
// FIXME(effects): we may want to erase the effect param if that is present on this item.
ty::InstanceKind::Item(def_id)
};

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_type_ir/src/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitPredicate<I> {

impl<I: Interner> fmt::Debug for TraitPredicate<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// FIXME(effects) printing?
write!(f, "TraitPredicate({:?}, polarity:{:?})", self.trait_ref, self.polarity)
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl CStr {
#[inline]
#[must_use]
const fn as_non_null_ptr(&self) -> NonNull<c_char> {
// FIXME(effects) replace with `NonNull::from`
// FIXME(const_trait_impl) replace with `NonNull::from`
// SAFETY: a reference is never null
unsafe { NonNull::new_unchecked(&self.inner as *const [c_char] as *mut [c_char]) }
.as_non_null_ptr()
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
/// [nomicon]: ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standard-library-and-its-unstable-may_dangle
#[lang = "drop"]
#[stable(feature = "rust1", since = "1.0.0")]
// FIXME(effects) #[const_trait]
// FIXME(const_trait_impl) #[const_trait]
pub trait Drop {
/// Executes the destructor for this type.
///
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/ops/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use crate::marker::Tuple;
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait]
// FIXME(const_trait_impl) #[const_trait]
pub trait Fn<Args: Tuple>: FnMut<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -159,7 +159,7 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait]
// FIXME(const_trait_impl) #[const_trait]
pub trait FnMut<Args: Tuple>: FnOnce<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -238,7 +238,7 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> {
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use = "closures are lazy and do nothing unless called"]
// FIXME(effects) #[const_trait]
// FIXME(const_trait_impl) #[const_trait]
pub trait FnOnce<Args: Tuple> {
/// The returned type after the call operator is used.
#[lang = "fn_once_output"]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/slice/sort/shared/smallsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<T: FreezeMarker> UnstableSmallSortTypeImpl for T {
}
}

/// FIXME(effects) use original ipnsort approach with choose_unstable_small_sort,
/// FIXME(const_trait_impl) use original ipnsort approach with choose_unstable_small_sort,
/// as found here <https://github.com/Voultapher/sort-research-rs/blob/438fad5d0495f65d4b72aa87f0b62fc96611dff3/ipnsort/src/smallsort.rs#L83C10-L83C36>.
pub(crate) trait UnstableSmallSortFreezeTypeImpl: Sized + FreezeMarker {
fn small_sort_threshold() -> usize;
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub(crate) fn clean_predicate<'tcx>(
ty::ClauseKind::ConstEvaluatable(..)
| ty::ClauseKind::WellFormed(..)
| ty::ClauseKind::ConstArgHasType(..)
// FIXME(effects): We can probably use this `HostEffect` pred to render `~const`.
// FIXME(const_trait_impl): We can probably use this `HostEffect` pred to render `~const`.
| ty::ClauseKind::HostEffect(_) => None,
}
}
Expand All @@ -379,7 +379,7 @@ fn clean_poly_trait_predicate<'tcx>(
cx: &mut DocContext<'tcx>,
) -> Option<WherePredicate> {
// `T: ~const Destruct` is hidden because `T: Destruct` is a no-op.
// FIXME(effects) check constness
// FIXME(const_trait_impl) check constness
if Some(pred.skip_binder().def_id()) == cx.tcx.lang_items().destruct_trait() {
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,15 @@ fn is_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
}

fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
// FIXME(effects, fee1-dead) revert to const destruct once it works again
// FIXME(const_trait_impl, fee1-dead) revert to const destruct once it works again
#[expect(unused)]
fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
// Avoid selecting for simple cases, such as builtin types.
if ty::util::is_trivially_const_drop(ty) {
return true;
}

// FIXME(effects) constness
// FIXME(const_trait_impl) constness
let obligation = Obligation::new(
tcx,
ObligationCause::dummy_with_span(body.span),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn main() {}

struct D;

/* FIXME(effects)
/* FIXME(const_trait_impl)
impl const Drop for D {
fn drop(&mut self) {
todo!();
Expand All @@ -113,7 +113,7 @@ impl const Drop for D {
*/

// Lint this, since it can be dropped in const contexts
// FIXME(effects)
// FIXME(const_trait_impl)
const fn d(this: D) {}
//~^ ERROR: this could be a `const fn`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn main() {}

struct D;

/* FIXME(effects)
/* FIXME(const_trait_impl)
impl const Drop for D {
fn drop(&mut self) {
todo!();
Expand All @@ -113,7 +113,7 @@ impl const Drop for D {
*/

// Lint this, since it can be dropped in const contexts
// FIXME(effects)
// FIXME(const_trait_impl)
fn d(this: D) {}
//~^ ERROR: this could be a `const fn`

Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc/rfc-2632-const-trait-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// stabilized when changing `@!has` to `@has`, and please do
// not remove this test.
//
// FIXME(effects) add `const_trait` to `Fn` so we use `~const`
// FIXME(effects) restore `const_trait` to `Destruct`
// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const`
// FIXME(const_trait_impl) restore `const_trait` to `Destruct`
#![feature(const_trait_impl)]
#![crate_name = "foo"]

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/consts/closure-in-foreign-crate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// FIXME(effects) aux-build:closure-in-foreign-crate.rs
// FIXME(const_trait_impl) aux-build:closure-in-foreign-crate.rs
//@ build-pass

// FIXME(effects) extern crate closure_in_foreign_crate;
// FIXME(const_trait_impl) extern crate closure_in_foreign_crate;

// FIXME(effects) const _: () = closure_in_foreign_crate::test();
// FIXME(const_trait_impl) const _: () = closure_in_foreign_crate::test();

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/consts/const_cmp_type_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ fn main() {
let _a = TypeId::of::<u8>() < TypeId::of::<u16>();
//~^ ERROR cannot call non-const operator in constants
// can't assert `_a` because it is not deterministic
// FIXME(effects) make it pass
// FIXME(const_trait_impl) make it pass
}
}
2 changes: 1 addition & 1 deletion tests/ui/traits/const-traits/call-const-closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Bar for () {
const FOO: () = {
(const || ().foo())();
//~^ ERROR the trait bound `(): ~const Bar` is not satisfied
// FIXME(effects): The constness environment for const closures is wrong.
// FIXME(const_trait_impl): The constness environment for const closures is wrong.
};

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/traits/const-traits/call-generic-in-impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ known-bug: #110395
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(const_trait_impl)]

#[const_trait]
Expand Down
Loading

0 comments on commit 6b96103

Please sign in to comment.