Merge branch 'rust-lang:master' into master
This commit is contained in:
commit
fc47bce9f7
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
> N.B. [`rustc_ast`], [`rustc_expand`], and [`rustc_builtin_macros`] are all
|
|
||||||
> undergoing refactoring, so some of the links in this chapter may be broken.
|
|
||||||
|
|
||||||
Rust has a very powerful macro system. In the previous chapter, we saw how
|
Rust has a very powerful macro system. In the previous chapter, we saw how
|
||||||
the parser sets aside macros to be expanded (using temporary [placeholders]).
|
the parser sets aside macros to be expanded (using temporary [placeholders]).
|
||||||
This chapter is about the process of expanding those macros iteratively until
|
This chapter is about the process of expanding those macros iteratively until
|
||||||
|
|
|
||||||
|
|
@ -32,21 +32,21 @@ Built-in implementations are provided for:
|
||||||
|
|
||||||
## Structural implementations
|
## Structural implementations
|
||||||
|
|
||||||
There are two implementations of `Unsize` which can be thought of as
|
There is one implementation of `Unsize` which can be thought of as
|
||||||
structural:
|
structural:
|
||||||
* `(A1, A2, .., An): Unsize<(A1, A2, .., U)>` given `An: Unsize<U>`, which
|
|
||||||
allows the tail field of a tuple to be unsized. This is gated behind the
|
|
||||||
[`unsized_tuple_coercion`] feature.
|
|
||||||
* `Struct<.., Pi, .., Pj, ..>: Unsize<Struct<.., Ui, .., Uj, ..>>` given
|
* `Struct<.., Pi, .., Pj, ..>: Unsize<Struct<.., Ui, .., Uj, ..>>` given
|
||||||
`TailField<Pi, .., Pj>: Unsize<Ui, .. Uj>`, which allows the tail field of a
|
`TailField<Pi, .., Pj>: Unsize<Ui, .. Uj>`, which allows the tail field of a
|
||||||
struct to be unsized if it is the only field that mentions generic parameters
|
struct to be unsized if it is the only field that mentions generic parameters
|
||||||
`Pi`, .., `Pj` (which don't need to be contiguous).
|
`Pi`, .., `Pj` (which don't need to be contiguous).
|
||||||
|
|
||||||
The rules for the latter implementation are slightly complicated, since they
|
The rules for struct unsizing are slightly complicated, since they
|
||||||
may allow more than one parameter to be changed (not necessarily unsized) and
|
may allow more than one parameter to be changed (not necessarily unsized) and
|
||||||
are best stated in terms of the tail field of the struct.
|
are best stated in terms of the tail field of the struct.
|
||||||
|
|
||||||
[`unsized_tuple_coercion`]: https://doc.rust-lang.org/beta/unstable-book/language-features/unsized-tuple-coercion.html
|
(Tuple unsizing was previously implemented behind the feature gate
|
||||||
|
`unsized_tuple_coercion`, but the implementation was removed by [#137728].)
|
||||||
|
|
||||||
|
[#137728]: https://github.com/rust-lang/rust/pull/137728
|
||||||
|
|
||||||
## Upcasting implementations
|
## Upcasting implementations
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue