-
Notifications
You must be signed in to change notification settings - Fork 165
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
Borrowck ast lifetimes #2771
Borrowck ast lifetimes #2771
Conversation
5377af2
to
b82aa74
Compare
There was a mismatch whether lifetime 'static is parsed as "static" or "'static". gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::lifetime_from_token): Fix matched pattern. Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog: * ast/rust-ast.h: Elided lifetime static constructor * ast/rust-type.h: Default lifetime to elided. * parse/rust-parse-impl.h (Parser::parse_lifetime_param): Use elided lifetime. (Parser::parse_lifetime): Use elided lifetime/ (Parser::lifetime_from_token): Use elided lifetime. (Parser::parse_self_param): Use elided lifetime. (Parser::parse_reference_type_inner): Use elided lifetime. Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_param): Lifetime elision control. (Parser::parse_lifetime_where_clause_item): Lifetime elision control. (Parser::parse_type_param_bound): Lifetime elision control. (Parser::parse_lifetime_bounds): Lifetime elision control. (Parser::parse_lifetime): Lifetime elision control. (Parser::parse_path_generic_args): Lifetime elision control. (Parser::parse_self_param): Lifetime elision control. (Parser::parse_break_expr): Lifetime elision control. (Parser::parse_continue_expr): Lifetime elision control. (Parser::parse_reference_type_inner): Lifetime elision control. * parse/rust-parse.h: Lifetime elision control. Signed-off-by: Jakub Dupak <[email protected]>
(probably incomplete propagation) gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Propagate static requirement. * hir/rust-ast-lower-base.h: Propagate static requirement. * hir/rust-ast-lower-implitem.h: Propagate static requirement. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Propagate static requirement. * hir/rust-ast-lower-type.cc (ASTLoweringType::translate): Propagate static requirement. (ASTLoweringType::visit): Propagate static requirement. * hir/rust-ast-lower-type.h: Propagate static requirement. Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): For lifetimes. Signed-off-by: Jakub Dupak <[email protected]>
b82aa74
to
71f7686
Compare
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.
looks good :) thanks for all the work ❤️
if (lifetime_type == AST::Lifetime::WILDCARD && default_to_static_lifetime) | ||
{ | ||
// If compiling in a static context. | ||
lifetime_type = AST::Lifetime::STATIC; | ||
} |
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.
if (lifetime_type == AST::Lifetime::WILDCARD && default_to_static_lifetime) | |
{ | |
// If compiling in a static context. | |
lifetime_type = AST::Lifetime::STATIC; | |
} | |
// If compiling in a static context. | |
if (lifetime_type == AST::Lifetime::WILDCARD && default_to_static_lifetime) | |
lifetime_type = AST::Lifetime::STATIC; |
GNU style nit, sorry
{} | ||
|
||
/** Used when compiling const and static items. */ | ||
bool default_to_static_lifetime; |
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 don't get how this flag is used or set. If we are lowering an AST::ConstantItem
or AST::StaticItem
, we know we are doing so and can pass an explicit true
flag to ASTLoweringType
(or even better, a LifetimeDefault::Static
enum variant which is clearer). and we could have a default value to the bool argument to the ASTLoweringType
argument?
does that make sense? or is it important that we keep it this way for future pull-requests?
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.
This flag is used to get the state across the visitor API and propagate further ASTLoweringType::translate
calls since the visitor API does not allow more parameters. I think it makes sense. Does it make sense now?
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.
ah, yeah I see what you mean. so we really can't do without a default parameter then?
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.
Do you mean the member variable or the parameter? We need the member variable, the parameter is useful because we don't need to change it everywhere.
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 meant the parameter - but I'm fine with keeping it this way, your explanation makes sense. I'll merge this now
Depends on #2770
Fixes #2756