Drop support for named tuple fields (#886)

Rationale: Based on the status of #478 and #505, Carbon won't have this feature for a while, and it will be simpler not to support it on spec in the meantime.
This commit is contained in:
Geoff Romer
2021-10-15 13:19:57 -07:00
committed by GitHub
parent c7c653adba
commit bb28d37eed
22 changed files with 175 additions and 469 deletions
+6 -16
View File
@@ -114,30 +114,20 @@ class BindingPattern : public Pattern {
// A pattern that matches a tuple value field-wise.
class TuplePattern : public Pattern {
public:
// Represents a portion of a tuple pattern corresponding to a single field.
struct Field {
Field(std::string name, Nonnull<Pattern*> pattern)
: name(std::move(name)), pattern(pattern) {}
// The field name. Cannot be empty
std::string name;
// The pattern the field must match.
Nonnull<Pattern*> pattern;
};
TuplePattern(SourceLocation source_loc, std::vector<Field> fields)
TuplePattern(SourceLocation source_loc, std::vector<Nonnull<Pattern*>> fields)
: Pattern(Kind::TuplePattern, source_loc), fields(std::move(fields)) {}
static auto classof(const Pattern* pattern) -> bool {
return pattern->kind() == Kind::TuplePattern;
}
auto Fields() const -> llvm::ArrayRef<Field> { return fields; }
auto Fields() -> llvm::MutableArrayRef<Field> { return fields; }
auto Fields() const -> llvm::ArrayRef<Nonnull<const Pattern*>> {
return fields;
}
auto Fields() -> llvm::ArrayRef<Nonnull<Pattern*>> { return fields; }
private:
std::vector<Field> fields;
std::vector<Nonnull<Pattern*>> fields;
};
// Converts paren_contents to a Pattern, interpreting the parentheses as