Clean up THIR patterns.
`thir::Pat::kind` is a `Box<PatKind>`, which doesn't follow the usual pattern in AST/HIR/THIR which is that the "kind" enum for a node is stored inline within the parent struct. This commit makes the `PatKind` directly inline within the `Pat`. This requires using `Box<Pat>` in all the types that hold a `Pat. Ideally, `Pat` would be stored in `Thir` like `Expr` and `Stmt` and referred to with a `PatId` rather than `Box<Pat>`. But this is hard to do because lots of `Pat`s get created after the destruction of the `Cx` that does normal THIR building. But this does get us a step closer to `PatId`, because all the `Box<Pat>` occurrences would be replaced with `PatId` if `PatId` ever happened. At 128 bytes, `Pat` is large. Subsequent commits will shrink it.
This commit is contained in:
parent
9af618b62e
commit
053874eecc
15 changed files with 123 additions and 121 deletions
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
return true;
|
||||
}
|
||||
|
||||
match pat.kind.as_ref() {
|
||||
match pat.kind {
|
||||
thir::PatKind::Constant { value } => value.has_param_types_or_consts(),
|
||||
thir::PatKind::Range(thir::PatRange { lo, hi, .. }) => {
|
||||
lo.has_param_types_or_consts() || hi.has_param_types_or_consts()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue