@@ -51,7 +51,7 @@ use ast::{struct_variant_kind, subtract};
5151use ast:: { sty_box, sty_region, sty_static, sty_uniq, sty_value} ;
5252use ast:: { token_tree, trait_method, trait_ref, tt_delim, tt_seq, tt_tok} ;
5353use ast:: { tt_nonterminal, tuple_variant_kind, Ty , ty_, ty_bot, ty_box} ;
54- use ast:: { TypeField , ty_fixed_length_vec, ty_closure, ty_bare_fn} ;
54+ use ast:: { TypeField , ty_fixed_length_vec, ty_closure, ty_bare_fn, ty_typeof } ;
5555use ast:: { ty_infer, TypeMethod } ;
5656use ast:: { ty_nil, TyParam , TyParamBound , ty_path, ty_ptr, ty_rptr} ;
5757use ast:: { ty_tup, ty_u32, ty_uniq, ty_vec, uniq} ;
@@ -1136,6 +1136,13 @@ impl Parser {
11361136 let result = self . parse_ty_closure ( ast:: BorrowedSigil , None ) ;
11371137 self . obsolete ( * self . last_span , ObsoleteBareFnType ) ;
11381138 result
1139+ } else if self . eat_keyword ( keywords:: Typeof ) {
1140+ // TYPEOF
1141+ // In order to not be ambiguous, the type must be surrounded by parens.
1142+ self . expect ( & token:: LPAREN ) ;
1143+ let e = self . parse_expr ( ) ;
1144+ self . expect ( & token:: RPAREN ) ;
1145+ ty_typeof ( e)
11391146 } else if * self . token == token:: MOD_SEP
11401147 || is_ident_or_path ( self . token ) {
11411148 // NAMED TYPE
@@ -3610,6 +3617,19 @@ impl Parser {
36103617 self . bump ( ) ;
36113618 sty_value
36123619 }
3620+ token:: BINOP ( token:: STAR ) => {
3621+ // Possibly "*self" or "*mut self" -- not supported. Try to avoid
3622+ // emitting cryptic "unexpected token" errors.
3623+ self . bump ( ) ;
3624+ if self . token_is_mutability ( self . token ) {
3625+ self . bump ( ) ;
3626+ }
3627+ if self . is_self_ident ( ) {
3628+ self . span_err ( * self . span , "cannot pass self by unsafe pointer" ) ;
3629+ self . bump ( ) ;
3630+ }
3631+ sty_value
3632+ }
36133633 _ => {
36143634 sty_static
36153635 }
0 commit comments