mGCA: Add associated const type check#152146
Conversation
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
|
||
| for projection in data.projection_bounds() { | ||
| let pred_binder = projection | ||
| .with_self_ty(tcx, tcx.types.trait_object_dummy_self) |
There was a problem hiding this comment.
| .with_self_ty(tcx, tcx.types.trait_object_dummy_self) | |
| .with_self_ty(tcx, t) |
I expect using trait_object_dummy_self might lead to code on the error-path crashing so we should use the "actual" self type. It also might just lead to weird diagnostics, such as Infer(FreshTy(0)) appearing in user facing text which we don't want.
Though eventually we'll also support assocaited constants such as const ASSOC: <Self as Other>::Assoc at which point Self will need to be a real type that implements Trait so that we can figure out the type of Assoc.
What's going on here is that we have the type dyn Trait<T, ASSOC = 10> (for example), and we want to construct [dyn Trait<T, ASSOC = 10>, T] as a list of generic arguments to <T as Trait<U>>::ASSOC for when we look at the type of ASSOC.
There was a problem hiding this comment.
Oh I really missed we have the type in scope and can use it -_-, then it will be perfect here
|
|
||
| trait Trait { #[type_const] const CT: bool; } | ||
|
|
||
| // FIXME: this should yield a type mismatch (`bool` v `i32`) |
There was a problem hiding this comment.
This will get fixed once you add wf checks for T: Trait<ASSOC = N> where clauses.
You can do this by adding fairly similar logic to what you've already done, but in rustc_hir_analysis/src/check/wfcheck.rs in the check_where_clause function
You should be able to similarly iterate over all of the predicates and filter to only those that are associated const bindings
|
very nice :) |
#151642
r? BoxyUwU
I didn't bless tests just yet as it only fixes the dyn arm