-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
extend+improve HIR types documentation #34521
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 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 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 |
---|---|---|
|
@@ -836,7 +836,7 @@ pub enum Expr_ { | |
ExprVec(HirVec<P<Expr>>), | ||
/// A function call | ||
/// | ||
/// The first field resolves to the function itself, | ||
/// The first field resolves to the function itself (usually an `ExprPath`), | ||
/// and the second field is the list of arguments | ||
ExprCall(P<Expr>, HirVec<P<Expr>>), | ||
/// A method call (`x.foo::<Bar, Baz>(a, b, c, d)`) | ||
|
@@ -845,9 +845,9 @@ pub enum Expr_ { | |
/// The vector of `Ty`s are the ascripted type parameters for the method | ||
/// (within the angle brackets). | ||
/// | ||
/// The first element of the vector of `Expr`s is the expression that evaluates | ||
/// to the object on which the method is being called on (the receiver), | ||
/// and the remaining elements are the rest of the arguments. | ||
/// The first element of the vector of `Expr`s is the expression that | ||
/// evaluates to the object on which the method is being called on (the | ||
/// receiver), and the remaining elements are the rest of the arguments. | ||
/// | ||
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as | ||
/// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`. | ||
|
@@ -919,13 +919,13 @@ pub enum Expr_ { | |
/// Inline assembly (from `asm!`), with its outputs and inputs. | ||
ExprInlineAsm(InlineAsm, Vec<P<Expr>>, Vec<P<Expr>>), | ||
|
||
/// A struct literal expression. | ||
/// A struct or enum variant literal expression. | ||
/// | ||
/// For example, `Foo {x: 1, y: 2}`, or | ||
/// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`. | ||
ExprStruct(Path, HirVec<Field>, Option<P<Expr>>), | ||
|
||
/// A vector literal constructed from one repeated element. | ||
/// An array literal constructed from one repeated element. | ||
/// | ||
/// For example, `[1; 5]`. The first expression is the element | ||
/// to be repeated; the second is the number of times to repeat it. | ||
|
@@ -950,14 +950,21 @@ pub struct QSelf { | |
pub position: usize, | ||
} | ||
|
||
/// Hints at the original code for a `match _ { .. }` | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] | ||
pub enum MatchSource { | ||
/// A `match _ { .. }` | ||
Normal, | ||
/// An `if let _ = _ { .. }` (optionally with `else { .. }` | ||
IfLetDesugar { | ||
contains_else_clause: bool, | ||
}, | ||
/// A `while let _ = _ { .. }` (which was desugared to a | ||
/// `loop { match _ { .. } }` | ||
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. Paren isn't closed. |
||
WhileLetDesugar, | ||
/// A desugared `for _ in _ { .. }` loop | ||
ForLoopDesugar, | ||
/// A desugared `?` operator | ||
TryDesugar, | ||
} | ||
|
||
|
@@ -975,8 +982,7 @@ pub struct MutTy { | |
pub mutbl: Mutability, | ||
} | ||
|
||
/// Represents a method's signature in a trait declaration, | ||
/// or in an implementation. | ||
/// Represents a method's signature in a trait declaration or implementation. | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub struct MethodSig { | ||
pub unsafety: Unsafety, | ||
|
@@ -999,13 +1005,20 @@ pub struct TraitItem { | |
pub span: Span, | ||
} | ||
|
||
/// Represents a trait method or associated constant or type | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub enum TraitItem_ { | ||
/// An associated constant with an optional value (otherwise `impl`s | ||
/// must contain a value) | ||
ConstTraitItem(P<Ty>, Option<P<Expr>>), | ||
/// A method with an optional body | ||
MethodTraitItem(MethodSig, Option<P<Block>>), | ||
/// An associated type with (possibly empty) bounds and optional concrete | ||
/// type | ||
TypeTraitItem(TyParamBounds, Option<P<Ty>>), | ||
} | ||
|
||
/// Represents anything within an `impl` block | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub struct ImplItem { | ||
pub id: NodeId, | ||
|
@@ -1017,10 +1030,15 @@ pub struct ImplItem { | |
pub span: Span, | ||
} | ||
|
||
/// Represents different contents within `impl`s | ||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] | ||
pub enum ImplItemKind { | ||
/// An associated constant of the given type, set to the constant result | ||
/// of the expression | ||
Const(P<Ty>, P<Expr>), | ||
/// A method implementation with the given signature and body | ||
Method(MethodSig, P<Block>), | ||
/// An associated type | ||
Type(P<Ty>), | ||
} | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "struct-like variant" is the correct term here.