1
Fork 0

Rollup merge of #136646 - oli-obk:pattern-types-ast, r=BoxyUwU

Add a TyPat in the AST to reuse the generic arg lowering logic

This simplifies ast lowering significantly with little cost to the pattern types parser.

Also fixes any problems we've had with generic args (well, pushes any problems onto the `generic_const_exprs` feature gate)

follow-up to https://github.com/rust-lang/rust/pull/136284#discussion_r1939292367

r? ``@BoxyUwU``
This commit is contained in:
Matthias Krüger 2025-02-12 06:07:37 +01:00 committed by GitHub
commit 516dd06a25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 241 additions and 264 deletions

View file

@ -923,6 +923,21 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
self.diag_metadata.current_trait_object = prev;
self.diag_metadata.current_type_path = prev_ty;
}
fn visit_ty_pat(&mut self, t: &'ast TyPat) -> Self::Result {
match &t.kind {
TyPatKind::Range(start, end, _) => {
if let Some(start) = start {
self.resolve_anon_const(start, AnonConstKind::ConstArg(IsRepeatExpr::No));
}
if let Some(end) = end {
self.resolve_anon_const(end, AnonConstKind::ConstArg(IsRepeatExpr::No));
}
}
TyPatKind::Err(_) => {}
}
}
fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef) {
let span = tref.span.shrink_to_lo().to(tref.trait_ref.path.span.shrink_to_lo());
self.with_generic_param_rib(