summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-03-26 10:40:57 +0800
committerJohn Hodge <tpg@mutabah.net>2015-03-26 10:40:57 +0800
commit7634647e1fcb7b1b6bcefd992d65b6b25277dfcc (patch)
tree10139bc0066fb1ac38b13e780426b85c5a2f2300 /src/parse
parentc7fa1f97f7b5a9eb4cf984e52a007d4dc51effa7 (diff)
downloadmrust-7634647e1fcb7b1b6bcefd992d65b6b25277dfcc.tar.gz
Remove the ASSOCIATED type (now handled by the UFCS path type)
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/paths.cpp20
-rw-r--r--src/parse/root.cpp3
-rw-r--r--src/parse/types.cpp7
3 files changed, 25 insertions, 5 deletions
diff --git a/src/parse/paths.cpp b/src/parse/paths.cpp
index 3fb1d779..a8c6802d 100644
--- a/src/parse/paths.cpp
+++ b/src/parse/paths.cpp
@@ -17,10 +17,24 @@ AST::Path Parse_PathFrom(TokenStream& lex, AST::Path path, eParsePathGenericMo
AST::Path Parse_Path(TokenStream& lex, eParsePathGenericMode generic_mode)
{
Token tok;
- if( GET_TOK(tok, lex) == TOK_DOUBLE_COLON )
- return Parse_Path(lex, true, generic_mode);
- else
+ switch( GET_TOK(tok, lex) )
{
+ case TOK_DOUBLE_COLON:
+ return Parse_Path(lex, true, generic_mode);
+ case TOK_LT: {
+ TypeRef ty = Parse_Type(lex);
+ TypeRef trait;
+ if( GET_TOK(tok, lex) == TOK_RWORD_AS ) {
+ trait = Parse_Type(lex);
+ }
+ else
+ lex.putback(tok);
+ GET_CHECK_TOK(tok, lex, TOK_GT);
+ // TODO: Terminating the "path" here is sometimes valid
+ GET_CHECK_TOK(tok, lex, TOK_DOUBLE_COLON);
+ return Parse_PathFrom(lex, AST::Path(AST::Path::TagUfcs(), ty, trait), PATH_GENERIC_EXPR);
+ }
+ default:
lex.putback(tok);
return Parse_Path(lex, false, generic_mode);
}
diff --git a/src/parse/root.cpp b/src/parse/root.cpp
index 78ae4d2a..c7518422 100644
--- a/src/parse/root.cpp
+++ b/src/parse/root.cpp
@@ -457,7 +457,8 @@ AST::Trait Parse_TraitDef(TokenStream& lex, const AST::MetaItems& meta_items)
if( GET_TOK(tok, lex) == TOK_COLON )
{
// Bounded associated type
- TypeRef a_type = TypeRef(TypeRef::TagAssoc(), TypeRef(TypeRef::TagArg(), "Self"), TypeRef(), name);
+ TypeRef a_type = TypeRef( AST::Path(AST::Path::TagUfcs(), TypeRef(TypeRef::TagArg(), "Self"), TypeRef())+ name);
+ //TypeRef a_type = TypeRef(TypeRef::TagAssoc(), TypeRef(TypeRef::TagArg(), "Self"), TypeRef(), name);
Parse_TypeBound(lex, params, a_type);
GET_TOK(tok, lex);
}
diff --git a/src/parse/types.cpp b/src/parse/types.cpp
index bbbdd4f8..2070a0d2 100644
--- a/src/parse/types.cpp
+++ b/src/parse/types.cpp
@@ -63,7 +63,11 @@ TypeRef Parse_Type(TokenStream& lex)
case TOK_RWORD_FN:
return Parse_Type_Fn(lex, "");
// '<' - An associated type cast
- case TOK_LT: {
+ case TOK_LT:
+ lex.putback(tok);
+ return TypeRef(TypeRef::TagPath(), Parse_Path(lex, PATH_GENERIC_TYPE));
+ #if 0
+ {
DEBUG("Associated type");
// TODO: This should instead use the path code, not a special case in typing
// <Type as Trait>::Inner
@@ -77,6 +81,7 @@ TypeRef Parse_Type(TokenStream& lex)
::std::string inner_name = tok.str();
return TypeRef(TypeRef::TagAssoc(), ::std::move(base), ::std::move(trait), ::std::move(inner_name));
}
+ #endif
// <ident> - Either a primitive, or a path
case TOK_IDENT:
// or a primitive