Allow self in const generics#157949
Conversation
| @@ -1535,7 +1535,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||
| } | |||
|
|
|||
| RibKind::ConstParamTy => { | |||
There was a problem hiding this comment.
IINM you're now accepting this code despite N depending on T which shouldn't be allowed w/o enabling GCPT.
impl<T> Wrap<T> {
fn f<const N: Self>() {}
}
struct Wrap<T>(T);There was a problem hiding this comment.
Is there a way to check if Self depends on generics?
There was a problem hiding this comment.
I'm not super well-versed in name resolution, so I don't know if there's a good way to do this in rustc_resolve that still nicely leverages the existing rib structure. Boxy probably has an idea.
Calling type_of here on the LocalDefId found in the SelfTyAlias is probably too prone to cycles or hangs; looking at hir_node corresp. to the LocalDefId might be an option but that might not integrate with the visitor.
Naively speaking, I would do it in HIR ty lowering by inspecting the type as returned by type_of and by reusing+generalizing check_assoc_const_binding_type but that's probably also not super ideal. I haven't read a lot of the new mGCA code in HIR ty lowering, maybe there's already a function for that (that's similar to check_assoc_const_binding_type?)?
Fixes #149203