Rename the FIXMEs, remove a few that dont matter anymore

This commit is contained in:
Michael Goulet 2024-11-01 18:49:08 +00:00
parent 0b5ddf30eb
commit 6b96103bf3
47 changed files with 58 additions and 68 deletions

View File

@ -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 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 {
@ -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`).
@ -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,
@ -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.
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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
@ -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
}
@ -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,

View File

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

View File

@ -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(..)) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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")]
@ -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")]
@ -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"]

View File

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

View File

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

View File

@ -404,7 +404,7 @@ 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.
@ -412,7 +412,7 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>
return true;
}
// FIXME(effects) constness
// FIXME(const_trait_impl) constness
let obligation = Obligation::new(
tcx,
ObligationCause::dummy_with_span(body.span),

View File

@ -104,7 +104,7 @@ fn main() {}
struct D;
/* FIXME(effects)
/* FIXME(const_trait_impl)
impl const Drop for D {
fn drop(&mut self) {
todo!();
@ -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`

View File

@ -104,7 +104,7 @@ fn main() {}
struct D;
/* FIXME(effects)
/* FIXME(const_trait_impl)
impl const Drop for D {
fn drop(&mut self) {
todo!();
@ -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`

View File

@ -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"]

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
//@ known-bug: #110395
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(const_trait_impl)]
#[const_trait]

View File

@ -2,7 +2,7 @@
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(const_trait_impl)]

View File

@ -1,6 +1,6 @@
//@ compile-flags: -Znext-solver
//@ known-bug: #110395
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(const_trait_impl)]

View File

@ -2,7 +2,7 @@
//@ compile-flags: -Znext-solver
//@ known-bug: #110395
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(const_trait_impl)]

View File

@ -1,4 +1,4 @@
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
//@ compile-flags: -Znext-solver
#![feature(const_closures, const_trait_impl)]
#![allow(incomplete_features)]

View File

@ -20,7 +20,7 @@ impl A for NonTrivialDrop {}
const fn check<T: ~const Destruct>(_: T) {}
/* FIXME(effects)
/* FIXME(const_trait_impl)
struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {

View File

@ -1,7 +1,7 @@
//@ known-bug: #110395
//@ failure-status: 101
//@ dont-check-compiler-stderr
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
//@ compile-flags: -Znext-solver
#![crate_type = "lib"]

View File

@ -1,5 +1,5 @@
#![feature(const_trait_impl)]
// FIXME(effects) add effects
// FIXME(const_trait_impl) add effects
//@ edition: 2021
#[const_trait]

View File

@ -1,6 +1,6 @@
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
// FIXME(effects): check-pass
// FIXME(const_trait_impl): check-pass
#![feature(const_trait_impl, generic_const_exprs)]
#![allow(incomplete_features)]

View File

@ -1,5 +1,5 @@
//@ known-bug: #110395
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
#![feature(derive_const)]
#![feature(const_trait_impl)]

View File

@ -13,5 +13,5 @@ impl Foo for () {
fn main() {
(const || { (()).foo() })();
//~^ ERROR: cannot call non-const fn `<() as Foo>::foo` in constant functions
// FIXME(effects) this should probably say constant closures
// FIXME(const_trait_impl) this should probably say constant closures
}

View File

@ -3,7 +3,7 @@
//@ normalize-stderr-test: ".*note: .*\n\n" -> ""
//@ normalize-stderr-test: "thread 'rustc' panicked.*:\n.*\n" -> ""
//@ rustc-env:RUST_BACKTRACE=0
// FIXME(effects) check-pass
// FIXME(const_trait_impl) check-pass
//@ compile-flags: -Znext-solver
#![crate_type = "lib"]

View File

@ -1,7 +1,7 @@
// Tests that trait bounds on specializing trait impls must be `~const` if the
// same bound is present on the default impl and is `~const` there.
//@ known-bug: #110395
// FIXME(effects) ^ should error
// FIXME(const_trait_impl) ^ should error
#![feature(const_trait_impl)]
#![feature(rustc_attrs)]

View File

@ -22,7 +22,7 @@ impl<T: ~const Spec> const A for T {
impl<T: Spec + Sup> A for T {
//~^ ERROR: cannot specialize
//FIXME(effects) ~| ERROR: missing `~const` qualifier
//FIXME(const_trait_impl) ~| ERROR: missing `~const` qualifier
fn a() -> u32 {
3
}

View File

@ -4,8 +4,6 @@
#[const_trait]
trait Trait {
// FIXME(effects): `~const` bounds in trait associated types (excluding associated type bounds)
// don't look super useful. Should we forbid them again?
type Assoc<T: ~const Bound>;
}

View File

@ -24,10 +24,10 @@ fn main() {
struct Container<const N: u32>;
// FIXME(effects): Somehow emit `the trait bound `T: const Trait` is not satisfied` here instead
// and suggest changing `Trait` to `const Trait`.
// FIXME(const_trait_impl): Somehow emit `the trait bound `T: const Trait`
// is not satisfied` here instead and suggest changing `Trait` to `const Trait`.
fn accept0<T: Trait>(_: Container<{ T::make() }>) {}
// FIXME(effects): Instead of suggesting `+ const Trait`, suggest
// FIXME(const_trait_impl): Instead of suggesting `+ const Trait`, suggest
// changing `~const Trait` to `const Trait`.
const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {}