forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#36002 - eddyb:abstract-kindness, r=nikomats…
…akis 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 rust-lang#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
- Loading branch information
Showing
117 changed files
with
1,416 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.