-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Const functions' effect parameter is early-bound, leading to them only satisfying const Fn
bounds
#119718
Comments
Fn
bounds
(*) When we instantiate the path Unfortunately, checking rust/compiler/rustc_hir_analysis/src/collect/predicates_of.rs Lines 41 to 61 in 75c68cf
This causes our previously constrained It turns out that I'm not certain how we expect to reconcile the early-boundness of host parameters with the conceptual late-boundness of the constness effect being enforced at call sites. This doesn't seem concordant either with the fact that the host parameter is observable at monomorphization time via |
Notably, this bug prevents me from turning the implementation of pub fn const_eval_select<ARG: Tuple, F, G, RET>(
arg: ARG,
called_in_const: F,
called_at_rt: G,
) -> RET
where
F: const FnOnce<ARG, Output = RET>,
G: FnOnce<ARG, Output = RET>; which accurately reflects the type checking of calling such an intrinsic. Fixing this would also allow me to remove the gross manual logic of faea6ad, which manually registers the correct |
Fn
boundsFn
bounds
Fn
boundsconst Fn
bounds
Rollup merge of rust-lang#119721 - compiler-errors:constness-implication, r=fee1-dead `~const` trait and projection bounds do not imply their non-const counterparts This PR removes the hack where we install a non-const trait and projection bound for every `const_trait` and `~const` projection bound we have in the AST. It ends up messing up more things than it fixes, see words below. Fixes rust-lang#119718 cc `@fmease` `@fee1-dead` `@oli-obk` r? fee1-dead or one of y'all i don't care --- My understanding is that this hack was added to support the following code: ```rust pub trait Owo<X = <Self as Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` Which is concretely lifted from in the `FromResidual` and `Try` traits. Since within the param-env of `trait Uwu`, we only know that `Self: ~const Uwu` and not `Self: Uwu`, the projection `<Self as Uwu>::T` is not satsifyable. This causes problems such as rust-lang#119718, since instantiations of `FnDef` types coming from `const fn` really do **only** implement one of `FnOnce` or `const FnOnce`! --- In the long-term, I believe that such code should really look something more like: ```rust #[const_trait] pub trait Owo<X = <Self as ~const Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` ... and that we should introduce some sort of `<T as ~const Foo>::Bar` bound syntax, since due to the fact that `~const` bounds can be present in item bounds, e.g. ```rust #[const_trait] trait Foo { type Bar: ~const Destruct; } ``` It's easy to see that `<T as Foo>::Bar` and `<T as ~const Foo>::Bar` (or `<T as const Foo>::Bar`) can be distinct types with distinct item bounds! **Admission**: I know I've said before that I don't like `~const` projection syntax, I do at this point believe they're necessary to fully express bounds and types in a maybe-const world.
I tried this code:
The text was updated successfully, but these errors were encountered: