1
Fork 0

Rollup merge of #136284 - oli-obk:push-zsxuwnzmonnl, r=lcnr

Allow using named consts in pattern types

This required a refactoring first: I had to stop using `hir::Pat`in `hir::TyKind::Pat` and instead create a separate `TyPat` that has `ConstArg` for range ends instead of `PatExpr`. Within the type system we should be using `ConstArg` for all constants, as otherwise we'd be maintaining two separate const systems that could diverge. The big advantage of this PR is that we now inherit all the rules from const generics and don't have a separate system. While this makes things harder for users (const generic rules wrt what is allowed in those consts), it also means we don't accidentally allow some things like referring to assoc consts or doing math on generic consts.
This commit is contained in:
Matthias Krüger 2025-02-04 18:49:37 +01:00 committed by GitHub
commit b07fa7696b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 475 additions and 202 deletions

View file

@ -937,6 +937,7 @@ impl<'hir> Map<'hir> {
Node::TraitRef(tr) => tr.path.span,
Node::OpaqueTy(op) => op.span,
Node::Pat(pat) => pat.span,
Node::TyPat(pat) => pat.span,
Node::PatField(field) => field.span,
Node::PatExpr(lit) => lit.span,
Node::Arm(arm) => arm.span,
@ -1212,6 +1213,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
Node::TraitRef(_) => node_str("trait ref"),
Node::OpaqueTy(_) => node_str("opaque type"),
Node::Pat(_) => node_str("pat"),
Node::TyPat(_) => node_str("pat ty"),
Node::PatField(_) => node_str("pattern field"),
Node::PatExpr(_) => node_str("pattern literal"),
Node::Param(_) => node_str("param"),