Implement unused pattern bindings, continued (#6518)

Implementation of unused pattern bindings #2022, continued.

Whereas previous PR #6460 took care of parsing, and PR #6479 prepared
the stage by using _ in some test cases, this PR has the the actual
implementation, using a simple dataflow analysis.

---------

Co-authored-by: Burak Emir <bqe@google.com>
Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
Burak Emir
2026-02-19 23:33:36 +00:00
committed by GitHub
co-authored by Burak Emir jonmeow
parent bea24a8bee
commit fdb188ccfd
366 changed files with 8453 additions and 7996 deletions
+5 -2
View File
@@ -37,13 +37,16 @@ struct BindingPatternInfo {
// Creates a binding pattern. Returns the binding pattern and the bind name
// instruction.
// - `pattern_kind` specifies the kind of instruction to create.
// - `is_template` indicates whether this is a template binding.
// - `is_unused` indicates whether the binding was explicitly marked `unused`.
// TODO: remove is_template once we have a separate InstKind for template
// bindings.
auto AddBindingPattern(Context& context, SemIR::LocId name_loc,
SemIR::NameId name_id, SemIR::TypeId type_id,
SemIR::ExprRegionId type_region_id,
SemIR::InstKind pattern_kind, bool is_template)
-> BindingPatternInfo;
SemIR::InstKind pattern_kind, bool is_template,
bool is_unused) -> BindingPatternInfo;
// Creates storage for `var` patterns nested within the given pattern at the
// current location in the output SemIR. For a `returned var`, this