https://gcc.gnu.org/g:92323dd3bb16f21194891ce463fc865598c6980f
commit 92323dd3bb16f21194891ce463fc865598c6980f Author: Arthur Cohen <arthur.co...@embecosm.com> Date: Wed Apr 16 17:39:28 2025 +0200 backend: Remove checks on StructFieldIdentPattern gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Remove old invalid checks. Diff: --- gcc/rust/backend/rust-compile-pattern.cc | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index 94844fed2e84..671025ae8598 100644 --- a/gcc/rust/backend/rust-compile-pattern.cc +++ b/gcc/rust/backend/rust-compile-pattern.cc @@ -259,34 +259,16 @@ CompilePatternCheckExpr::visit (HIR::StructPattern &pattern) } break; - case HIR::StructPatternField::ItemType::IDENT_PAT: { - HIR::StructPatternFieldIdentPat &ident - = static_cast<HIR::StructPatternFieldIdentPat &> (*field.get ()); - - size_t offs = 0; - ok = variant->lookup_field (ident.get_identifier ().as_string (), - nullptr, &offs); - rust_assert (ok); - - // we may be offsetting by + 1 here since the first field in the - // record is always the discriminator - offs += adt->is_enum (); - tree field_expr - = Backend::struct_field_expression (match_scrutinee_expr, offs, - ident.get_locus ()); + case HIR::StructPatternField::ItemType::IDENT_PAT: + // we only support rebinding patterns at the moment, which always + // match - so do nothing - tree check_expr_sub - = CompilePatternCheckExpr::Compile (ident.get_pattern (), - field_expr, ctx); - check_expr = Backend::arithmetic_or_logical_expression ( - ArithmeticOrLogicalOperator::BITWISE_AND, check_expr, - check_expr_sub, ident.get_pattern ().get_locus ()); - } + // this needs to change once we actually check that the field + // matches a certain value, either a literal value or a const one break; - case HIR::StructPatternField::ItemType::IDENT: { - // ident pattern always matches - do nothing - } + case HIR::StructPatternField::ItemType::IDENT: + // ident pattern always matches - do nothing break; } }