@@ -192,6 +192,10 @@ impl<'a> LoweringContext<'a> {
192192 }
193193 }
194194
195+ fn lower_opt_sp_ident ( & mut self , o_id : Option < Spanned < Ident > > ) -> Option < Spanned < Name > > {
196+ o_id. map ( |sp_ident| respan ( sp_ident. span , self . lower_ident ( sp_ident. node ) ) )
197+ }
198+
195199 fn lower_attrs ( & mut self , attrs : & Vec < Attribute > ) -> hir:: HirVec < Attribute > {
196200 attrs. clone ( ) . into ( )
197201 }
@@ -269,7 +273,7 @@ impl<'a> LoweringContext<'a> {
269273 P ( hir:: Ty {
270274 id : t. id ,
271275 node : match t. node {
272- Infer => hir:: TyInfer ,
276+ Infer | ImplicitSelf => hir:: TyInfer ,
273277 Vec ( ref ty) => hir:: TyVec ( self . lower_ty ( ty) ) ,
274278 Ptr ( ref mt) => hir:: TyPtr ( self . lower_mt ( mt) ) ,
275279 Rptr ( ref region, ref mt) => {
@@ -787,23 +791,24 @@ impl<'a> LoweringContext<'a> {
787791 }
788792
789793 fn lower_method_sig ( & mut self , sig : & MethodSig ) -> hir:: MethodSig {
790- // Check for `self: _` and `self: &_`
791- if let SelfKind :: Explicit ( ref ty, _) = sig. explicit_self . node {
792- match sig. decl . inputs . get ( 0 ) . and_then ( Arg :: to_self) . map ( |eself| eself. node ) {
793- Some ( SelfKind :: Value ( ..) ) | Some ( SelfKind :: Region ( ..) ) => {
794- self . id_assigner . diagnostic ( ) . span_err ( ty. span ,
795- "the type placeholder `_` is not allowed within types on item signatures" ) ;
796- }
797- _ => { }
798- }
799- }
800- hir:: MethodSig {
794+ let hir_sig = hir:: MethodSig {
801795 generics : self . lower_generics ( & sig. generics ) ,
802796 abi : sig. abi ,
803797 unsafety : self . lower_unsafety ( sig. unsafety ) ,
804798 constness : self . lower_constness ( sig. constness ) ,
805799 decl : self . lower_fn_decl ( & sig. decl ) ,
800+ } ;
801+ // Check for `self: _` and `self: &_`
802+ if let Some ( SelfKind :: Explicit ( ..) ) = sig. decl . get_self ( ) . map ( |eself| eself. node ) {
803+ match hir_sig. decl . get_self ( ) . map ( |eself| eself. node ) {
804+ Some ( hir:: SelfKind :: Value ( ..) ) | Some ( hir:: SelfKind :: Region ( ..) ) => {
805+ self . id_assigner . diagnostic ( ) . span_err ( sig. decl . inputs [ 0 ] . ty . span ,
806+ "the type placeholder `_` is not allowed within types on item signatures" ) ;
807+ }
808+ _ => { }
809+ }
806810 }
811+ hir_sig
807812 }
808813
809814 fn lower_unsafety ( & mut self , u : Unsafety ) -> hir:: Unsafety {
@@ -872,10 +877,10 @@ impl<'a> LoweringContext<'a> {
872877 } )
873878 }
874879 PatKind :: Lit ( ref e) => hir:: PatKind :: Lit ( self . lower_expr ( e) ) ,
875- PatKind :: TupleStruct ( ref pth, ref pats) => {
880+ PatKind :: TupleStruct ( ref pth, ref pats, ddpos ) => {
876881 hir:: PatKind :: TupleStruct ( self . lower_path ( pth) ,
877- pats. as_ref ( )
878- . map ( |pats| pats . iter ( ) . map ( |x| self . lower_pat ( x ) ) . collect ( ) ) )
882+ pats. iter ( ) . map ( |x| self . lower_pat ( x ) ) . collect ( ) ,
883+ ddpos )
879884 }
880885 PatKind :: Path ( ref pth) => {
881886 hir:: PatKind :: Path ( self . lower_path ( pth) )
@@ -903,8 +908,8 @@ impl<'a> LoweringContext<'a> {
903908 . collect ( ) ;
904909 hir:: PatKind :: Struct ( pth, fs, etc)
905910 }
906- PatKind :: Tup ( ref elts) => {
907- hir:: PatKind :: Tup ( elts. iter ( ) . map ( |x| self . lower_pat ( x) ) . collect ( ) )
911+ PatKind :: Tuple ( ref elts, ddpos ) => {
912+ hir:: PatKind :: Tuple ( elts. iter ( ) . map ( |x| self . lower_pat ( x) ) . collect ( ) , ddpos )
908913 }
909914 PatKind :: Box ( ref inner) => hir:: PatKind :: Box ( self . lower_pat ( inner) ) ,
910915 PatKind :: Ref ( ref inner, mutbl) => {
@@ -1122,11 +1127,10 @@ impl<'a> LoweringContext<'a> {
11221127 }
11231128 ExprKind :: While ( ref cond, ref body, opt_ident) => {
11241129 hir:: ExprWhile ( self . lower_expr ( cond) , self . lower_block ( body) ,
1125- opt_ident . map ( |ident| self . lower_ident ( ident ) ) )
1130+ self . lower_opt_sp_ident ( opt_ident ) )
11261131 }
11271132 ExprKind :: Loop ( ref body, opt_ident) => {
1128- hir:: ExprLoop ( self . lower_block ( body) ,
1129- opt_ident. map ( |ident| self . lower_ident ( ident) ) )
1133+ hir:: ExprLoop ( self . lower_block ( body) , self . lower_opt_sp_ident ( opt_ident) )
11301134 }
11311135 ExprKind :: Match ( ref expr, ref arms) => {
11321136 hir:: ExprMatch ( self . lower_expr ( expr) ,
@@ -1243,12 +1247,8 @@ impl<'a> LoweringContext<'a> {
12431247 } ;
12441248 hir:: ExprPath ( hir_qself, self . lower_path_full ( path, rename) )
12451249 }
1246- ExprKind :: Break ( opt_ident) => hir:: ExprBreak ( opt_ident. map ( |sp_ident| {
1247- respan ( sp_ident. span , self . lower_ident ( sp_ident. node ) )
1248- } ) ) ,
1249- ExprKind :: Again ( opt_ident) => hir:: ExprAgain ( opt_ident. map ( |sp_ident| {
1250- respan ( sp_ident. span , self . lower_ident ( sp_ident. node ) )
1251- } ) ) ,
1250+ ExprKind :: Break ( opt_ident) => hir:: ExprBreak ( self . lower_opt_sp_ident ( opt_ident) ) ,
1251+ ExprKind :: Again ( opt_ident) => hir:: ExprAgain ( self . lower_opt_sp_ident ( opt_ident) ) ,
12521252 ExprKind :: Ret ( ref e) => hir:: ExprRet ( e. as_ref ( ) . map ( |x| self . lower_expr ( x) ) ) ,
12531253 ExprKind :: InlineAsm ( InlineAsm {
12541254 ref inputs,
@@ -1422,8 +1422,7 @@ impl<'a> LoweringContext<'a> {
14221422
14231423 // `[opt_ident]: loop { ... }`
14241424 let loop_block = self . block_expr ( match_expr) ;
1425- let loop_expr = hir:: ExprLoop ( loop_block,
1426- opt_ident. map ( |ident| self . lower_ident ( ident) ) ) ;
1425+ let loop_expr = hir:: ExprLoop ( loop_block, self . lower_opt_sp_ident ( opt_ident) ) ;
14271426 // add attributes to the outer returned expr node
14281427 let attrs = e. attrs . clone ( ) ;
14291428 return P ( hir:: Expr { id : e. id , node : loop_expr, span : e. span , attrs : attrs } ) ;
@@ -1503,8 +1502,7 @@ impl<'a> LoweringContext<'a> {
15031502
15041503 // `[opt_ident]: loop { ... }`
15051504 let loop_block = self . block_expr ( match_expr) ;
1506- let loop_expr = hir:: ExprLoop ( loop_block,
1507- opt_ident. map ( |ident| self . lower_ident ( ident) ) ) ;
1505+ let loop_expr = hir:: ExprLoop ( loop_block, self . lower_opt_sp_ident ( opt_ident) ) ;
15081506 let loop_expr =
15091507 P ( hir:: Expr { id : e. id , node : loop_expr, span : e. span , attrs : None } ) ;
15101508
@@ -1857,7 +1855,7 @@ impl<'a> LoweringContext<'a> {
18571855 let pt = if subpats. is_empty ( ) {
18581856 hir:: PatKind :: Path ( path)
18591857 } else {
1860- hir:: PatKind :: TupleStruct ( path, Some ( subpats) )
1858+ hir:: PatKind :: TupleStruct ( path, subpats, None )
18611859 } ;
18621860 let pat = self . pat ( span, pt) ;
18631861 self . resolver . record_resolution ( pat. id , def) ;
0 commit comments