diff options
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/root.cpp | 2 | ||||
-rw-r--r-- | src/parse/types.cpp | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 2b027bf9..0fcbe63a 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -374,7 +374,7 @@ AST::Function Parse_FunctionDef(TokenStream& lex, ::std::string abi, bool allow_ GET_TOK(tok, lex); } CHECK_TOK(tok, TOK_RWORD_SELF); - args.push_back( ::std::make_pair( AST::Pattern(AST::Pattern::TagBind(), "self"), TypeRef(TypeRef::TagReference(), ty_sp, is_mut, TypeRef(ty_sp, "Self", 0xFFFF))) ); + args.push_back( ::std::make_pair( AST::Pattern(AST::Pattern::TagBind(), "self"), TypeRef(TypeRef::TagReference(), ty_sp, ::std::move(lifetime), is_mut, TypeRef(ty_sp, "Self", 0xFFFF))) ); if( allow_self == false ) throw ParseError::Generic(lex, "Self binding not expected"); diff --git a/src/parse/types.cpp b/src/parse/types.cpp index b0b43426..53c79d3b 100644 --- a/src/parse/types.cpp +++ b/src/parse/types.cpp @@ -109,23 +109,21 @@ TypeRef Parse_Type_Int(TokenStream& lex, bool allow_trait_list) lex.putback(Token(TOK_AMP)); // '&' - Reference type case TOK_AMP: { - ::std::string lifetime; + AST::LifetimeRef lifetime; // Reference tok = lex.getToken(); if( tok.type() == TOK_LIFETIME ) { - lifetime = tok.str(); + lifetime = AST::LifetimeRef(/*lex.point_span(), */lex.get_ident(::std::move(tok))); tok = lex.getToken(); } + bool is_mut = false; if( tok.type() == TOK_RWORD_MUT ) { - // Mutable reference - return TypeRef(TypeRef::TagReference(), lex.end_span(ps), true, Parse_Type(lex, false)); + is_mut = true; } else { PUTBACK(tok, lex); - // Immutable reference - return TypeRef(TypeRef::TagReference(), lex.end_span(ps), false, Parse_Type(lex, false)); } - throw ParseError::BugCheck("Reached end of Parse_Type:AMP"); + return TypeRef(TypeRef::TagReference(), lex.end_span(ps), ::std::move(lifetime), is_mut, Parse_Type(lex, false)); } // '*' - Raw pointer case TOK_STAR: |