1
Fork 0

Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors

Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup

Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology.

Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense.

---

Old terminology (HIR, rustdoc):

```
`TypeBinding`: (associated) type binding
├── `Constraint`: associated type bound
└── `Equality`: (associated) equality constraint (?)
    ├── `Ty`: (associated) type binding
    └── `Const`: associated const equality (constraint)
```

Old terminology (AST, abbrev.):

```
`AssocConstraint`
├── `Bound`
└── `Equality`
    ├── `Ty`
    └── `Const`
```

New terminology (AST, HIR, rustdoc):

```
`AssocItemConstraint`: associated item constraint
├── `Bound`: associated type bound
└── `Equality`: associated item equality constraint OR associated item binding (for short)
    ├── `Ty`: associated type equality constraint OR associated type binding (for short)
    └── `Const`: associated const equality constraint OR associated const binding (for short)
```

r? compiler-errors
This commit is contained in:
Matthias Krüger 2024-05-31 08:50:22 +02:00 committed by GitHub
commit 379233242b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 878 additions and 818 deletions

View file

@ -925,7 +925,7 @@ impl<'hir> Map<'hir> {
.with_hi(seg.args.map_or_else(|| ident_span.hi(), |args| args.span_ext.hi()))
}
Node::Ty(ty) => ty.span,
Node::TypeBinding(tb) => tb.span,
Node::AssocItemConstraint(constraint) => constraint.span,
Node::TraitRef(tr) => tr.path.span,
Node::Pat(pat) => pat.span,
Node::PatField(field) => field.span,
@ -1190,7 +1190,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
Node::Stmt(_) => node_str("stmt"),
Node::PathSegment(_) => node_str("path segment"),
Node::Ty(_) => node_str("type"),
Node::TypeBinding(_) => node_str("type binding"),
Node::AssocItemConstraint(_) => node_str("assoc item constraint"),
Node::TraitRef(_) => node_str("trait ref"),
Node::Pat(_) => node_str("pat"),
Node::PatField(_) => node_str("pattern field"),