mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
general fixups and turn TODO
s into FIXME
s
This commit is contained in:
parent
373e906296
commit
0a2330630d
@ -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()
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
//
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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`.
|
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -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`.
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user