]> git.lizzy.rs Git - rust.git/commit
Auto merge of #55274 - pnkfelix:issue-54570-proj-path-into-pats-with-type-take-2...
authorbors <bors@rust-lang.org>
Sat, 27 Oct 2018 00:39:11 +0000 (00:39 +0000)
committerbors <bors@rust-lang.org>
Sat, 27 Oct 2018 00:39:11 +0000 (00:39 +0000)
commit10f42cbde015c44a019e8b6dceca472a1532f36a
treef3be514f7f0d9d31f457bf1643683dc9f5b20c2b
parentfa45602b71c59c6315fdb07e925dec61f5827ad9
parent639a3ffadcfec5165d434cbbf320678f69b01a5b
Auto merge of #55274 - pnkfelix:issue-54570-proj-path-into-pats-with-type-take-2, r=nikomatsakis

Handle bindings in substructure of patterns with type ascriptions

This attempts to follow the outline described by @nikomatsakis [here](https://github.com/rust-lang/rust/issues/47184#issuecomment-420041056). Its a bit more complicated than expected for two reasons:

 1. In general it handles sets of type ascriptions, because such ascriptions can be nested within patterns
 2.  It has a separate types in the HAIR, `PatternTypeProjections` and `PatternTypeProjection`, which are analogues to the corresponding types in the MIR.

The main reason I added the new HAIR types was because I am worried that the current implementation is inefficent, and asymptotically so: It makes copies of vectors as it descends the patterns, even when those accumulated vectors are never used.

Longer term, I would like to used a linked tree structure for the `PatternTypeProjections` and `PatternTypeProjection`, and save the construction of standalone vectors for the MIR types. I didn't want to block landing this on that hypoethetical revision; but I figured I could at least make the future change easier by differentiating between the two types now.

Oh, one more thing: This doesn't attempt to handle `ref x` (in terms of ensuring that any necessary types are ascribed to `x` in that scenario as well). We should open an issue to investigate supporting that as well. But I didn't want to block this PR on that future work.

Fix #54570