From f5819ef88927734bcc36769b50d1b69de377b5db Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 31 Mar 2015 10:14:08 +0800 Subject: Fully convert trait name in 'impl' to be a AST:Path --- src/parse/root.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/parse/root.cpp') diff --git a/src/parse/root.cpp b/src/parse/root.cpp index eefe0d52..2beac535 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -651,13 +651,13 @@ AST::Impl Parse_Impl(TokenStream& lex, bool is_unsafe/*=false*/) } // 2. Either a trait name (with type params), or the type to impl - TypeRef trait_type; + AST::Path trait_path; TypeRef impl_type; // - Handle negative impls, which must be a trait // "impl !Trait for Type {}" if( GET_TOK(tok, lex) == TOK_EXCLAM ) { - trait_type = Parse_Type(lex); + trait_path = Parse_Path(lex, PATH_GENERIC_TYPE); GET_CHECK_TOK(tok, lex, TOK_RWORD_FOR); impl_type = Parse_Type(lex); @@ -671,7 +671,7 @@ AST::Impl Parse_Impl(TokenStream& lex, bool is_unsafe/*=false*/) GET_CHECK_TOK(tok, lex, TOK_BRACE_CLOSE); return AST::Impl(AST::Impl::TagNegative(), ::std::move(params), - ::std::move(impl_type), ::std::move(trait_type) + ::std::move(impl_type), ::std::move(trait_path) ); } else @@ -684,7 +684,9 @@ AST::Impl Parse_Impl(TokenStream& lex, bool is_unsafe/*=false*/) if( GET_TOK(tok, lex) == TOK_RWORD_FOR ) { - trait_type = impl_type; + if( !impl_type.is_path() ) + throw ParseError::Generic(lex, "Trait was not a path"); + trait_path = impl_type.path(); // Implementing a trait for another type, get the target type if( GET_TOK(tok, lex) == TOK_DOUBLE_DOT ) { @@ -712,7 +714,7 @@ AST::Impl Parse_Impl(TokenStream& lex, bool is_unsafe/*=false*/) } GET_CHECK_TOK(tok, lex, TOK_BRACE_OPEN); - AST::Impl impl( ::std::move(params), ::std::move(impl_type), ::std::move(trait_type) ); + AST::Impl impl( ::std::move(params), ::std::move(impl_type), ::std::move(trait_path) ); // A sequence of method implementations while( GET_TOK(tok, lex) != TOK_BRACE_CLOSE ) -- cgit v1.2.3