-
Notifications
You must be signed in to change notification settings - Fork 546
update internal terminology: Substs -> GenericArgs #1769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,11 +200,11 @@ the function calls if one is available in some place (like during type checking) | |
If no inference context is available at all, then one can be created as described in | ||
[type-inference]. But this is only useful when the involved types (for example, if | ||
they came from a query like `tcx.type_of()`) are actually substituted with fresh | ||
inference variables using [`fresh_substs_for_item`]. This can be used to answer questions | ||
inference variables using [`fresh_args_for_item`]. This can be used to answer questions | ||
like "can `Vec<T>` for any `T` be unified with `Vec<u32>`?". | ||
|
||
[type-inference]: ./type-inference.md#creating-an-inference-context | ||
[`fresh_substs_for_item`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.fresh_substs_for_item | ||
[`fresh_args_for_item`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_infer/infer/struct.InferCtxt.html#method.fresh_args_for_item | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one has not changed
tshepang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## `ty::TyKind` Variants | ||
|
||
|
@@ -287,7 +287,7 @@ struct MyStruct<T> { x: u32, y: T } | |
The type `MyStruct<u32>` would be an instance of `TyKind::Adt`: | ||
|
||
```rust,ignore | ||
Adt(&'tcx AdtDef, SubstsRef<'tcx>) | ||
Adt(&'tcx AdtDef, GenericArgsRef<'tcx>) | ||
// ------------ --------------- | ||
// (1) (2) | ||
// | ||
|
@@ -301,12 +301,12 @@ There are two parts: | |
parameters. In our example, this is the `MyStruct` part *without* the argument `u32`. | ||
(Note that in the HIR, structs, enums and unions are represented differently, but in `ty::Ty`, | ||
they are all represented using `TyKind::Adt`.) | ||
- The [`SubstsRef`][substsref] is an interned list of values that are to be substituted for the | ||
generic parameters. In our example of `MyStruct<u32>`, we would end up with a list like `[u32]`. | ||
We’ll dig more into generics and substitutions in a little bit. | ||
- The [`GenericArgsRef`][GenericArgsRef] is an interned list of values that are to be substituted | ||
for the generic parameters. In our example of `MyStruct<u32>`, we would end up with a list like | ||
`[u32]`. We’ll dig more into generics and substitutions in a little bit. | ||
|
||
[adtdef]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.AdtDef.html | ||
[substsref]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/type.SubstsRef.html | ||
[GenericArgsRef]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/type.GenericArgsRef.html | ||
|
||
**`AdtDef` and `DefId`** | ||
|
||
|
@@ -363,13 +363,13 @@ delaying a redundant span bug. | |
|
||
## Question: Why not substitute “inside” the `AdtDef`? | ||
|
||
Recall that we represent a generic struct with `(AdtDef, substs)`. So why bother with this scheme? | ||
Recall that we represent a generic struct with `(AdtDef, args)`. So why bother with this scheme? | ||
|
||
Well, the alternate way we could have chosen to represent types would be to always create a new, | ||
fully-substituted form of the `AdtDef` where all the types are already substituted. This seems like | ||
less of a hassle. However, the `(AdtDef, substs)` scheme has some advantages over this. | ||
less of a hassle. However, the `(AdtDef, args)` scheme has some advantages over this. | ||
|
||
First, `(AdtDef, substs)` scheme has an efficiency win: | ||
First, `(AdtDef, args)` scheme has an efficiency win: | ||
|
||
```rust,ignore | ||
struct MyStruct<T> { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.