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?)?
This comment has been minimized.
This comment has been minimized.
f087424 to
4b4635a
Compare
This comment has been minimized.
This comment has been minimized.
1e306d8 to
d655af4
Compare
This comment has been minimized.
This comment has been minimized.
d655af4 to
c17a818
Compare
|
@rustbot ready |
Fixes #149203