diff options
author | Jakub Dupak <dev@jakubdupak.com> | 2023-12-03 12:25:23 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-12-27 19:03:10 +0000 |
commit | 77db7e8fb9525620c52dbda12b78d46144542854 (patch) | |
tree | 2437af496f33f6294f1cc3b2f32cf1511221fbb4 /gcc/rust/parse | |
parent | e557052930b968899e5a16f01c8361c86739f712 (diff) | |
download | gcc-77db7e8fb9525620c52dbda12b78d46144542854.zip gcc-77db7e8fb9525620c52dbda12b78d46144542854.tar.gz gcc-77db7e8fb9525620c52dbda12b78d46144542854.tar.bz2 |
ast: Unify explicitly and implicitly elided lifettimes
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 <dev@jakubdupak.com>
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 2d83567..0b53e57 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -3470,8 +3470,6 @@ Parser<ManagedTokenSource>::parse_lifetime_param () return AST::LifetimeParam::create_error (); } lexer.skip_token (); - /* TODO: does this always create a named lifetime? or can a different type - * be made? */ AST::Lifetime lifetime (AST::Lifetime::NAMED, lifetime_tok->get_str (), lifetime_tok->get_locus ()); @@ -4141,10 +4139,9 @@ AST::Lifetime Parser<ManagedTokenSource>::parse_lifetime () { const_TokenPtr lifetime_tok = lexer.peek_token (); - // create error lifetime if doesn't exist if (lifetime_tok->get_id () != LIFETIME) { - return AST::Lifetime::error (); + return AST::Lifetime::elided (); } lexer.skip_token (); @@ -4164,6 +4161,7 @@ Parser<ManagedTokenSource>::lifetime_from_token (const_TokenPtr tok) } else if (lifetime_ident == "_") { + // Explicitly and implicitly elided lifetimes follow the same rules. return AST::Lifetime (AST::Lifetime::WILDCARD, "", locus); } else @@ -7177,7 +7175,7 @@ tl::expected<std::unique_ptr<AST::Param>, ParseSelfError> Parser<ManagedTokenSource>::parse_self_param () { bool has_reference = false; - AST::Lifetime lifetime = AST::Lifetime::error (); + AST::Lifetime lifetime = AST::Lifetime::elided (); location_t locus = lexer.peek_token ()->get_locus (); @@ -9837,7 +9835,7 @@ std::unique_ptr<AST::ReferenceType> Parser<ManagedTokenSource>::parse_reference_type_inner (location_t locus) { // parse optional lifetime - AST::Lifetime lifetime = AST::Lifetime::error (); + AST::Lifetime lifetime = AST::Lifetime::elided (); if (lexer.peek_token ()->get_id () == LIFETIME) { lifetime = parse_lifetime (); |