]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #36002 - eddyb:abstract-kindness, r=nikomatsakis
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 27 Aug 2016 04:01:14 +0000 (09:31 +0530)
committerGitHub <noreply@github.com>
Sat, 27 Aug 2016 04:01:14 +0000 (09:31 +0530)
commit7a2a381e0e8d127c44702d79dd697e15685454e2
treee9dee807716e8c81208fab2bc4b22d2e2edd9eb6
parent1385feb5eecd50c31d97229ffe3d751050d89733
parent7a8d4822d8eb922f0cd50e92f420b5f1938db64d
Rollup merge of #36002 - eddyb:abstract-kindness, r=nikomatsakis

Combine types and regions in Substs into one interleaved list.

Previously, `Substs` would contain types and regions, in two separate vectors, for example:
```rust
<X as Trait<'a, 'b, A, B>>::method::<'p, 'q, T, U>
/* corresponds to */
Substs { regions: ['a, 'b, 'p, 'q], types: [X, A, B, T, U] }
```

This PR continues the work started in #35605 by further removing the distinction.
A new abstraction over types and regions is introduced in the compiler, `Kind`.
Each `Kind` is a pointer (`&TyS` or `&Region`), with the lowest two bits used as a tag.
Two bits were used instead of just one (type = `0`, region = `1`) to allow adding more kinds.

`Substs` contain only a `Vec<Kind>`, with `Self` first, followed by regions and types (in the definition order):
```rust
Substs { params: [X, 'a, 'b, A, B, 'p, 'q, T, U] }
```
The resulting interleaved list has the property of being the concatenation of parameters for the (potentially) nested generic items it describes, and can be sliced back into those components:
```rust
params[0..5] = [X, 'a, 'b, A, B] // <X as Trait<'a, 'b, A, B>>
params[5..9] = ['p, 'q, T, U] // <_>::method::<'p, 'q, T, U>
```

r? @nikomatsakis
src/librustc_trans/debuginfo/mod.rs