]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_parse/parser/item.rs
ast: move Generics into AssocItemKinds
[rust.git] / src / librustc_parse / parser / item.rs
index 500aaaf43b92a3ddc669bb75c005f145bf9cc14e..96b3cf797208eb0431ee1a4951c10f9b03ec0e45 100644 (file)
@@ -665,11 +665,11 @@ fn parse_assoc_item_(
         let vis = self.parse_visibility(FollowedByType::No)?;
         let defaultness = self.parse_defaultness();
 
-        let (ident, kind, generics) = if self.eat_keyword(kw::Type) {
+        let (ident, kind) = if self.eat_keyword(kw::Type) {
             self.parse_assoc_ty()?
         } else if self.check_fn_front_matter() {
             let (ident, sig, generics, body) = self.parse_fn(at_end, &mut attrs, req_name)?;
-            (ident, AssocItemKind::Fn(sig, body), generics)
+            (ident, AssocItemKind::Fn(sig, generics, body))
         } else if self.check_keyword(kw::Const) {
             self.parse_assoc_const()?
         } else if self.isnt_macro_invocation() {
@@ -677,7 +677,7 @@ fn parse_assoc_item_(
         } else if self.token.is_path_start() {
             let mac = self.parse_item_macro(&vis)?;
             *at_end = true;
-            (Ident::invalid(), AssocItemKind::Macro(mac), Generics::default())
+            (Ident::invalid(), AssocItemKind::Macro(mac))
         } else {
             self.recover_attrs_no_item(&attrs)?;
             self.unexpected()?
@@ -685,26 +685,26 @@ fn parse_assoc_item_(
 
         let span = lo.to(self.prev_span);
         let id = DUMMY_NODE_ID;
-        Ok(AssocItem { id, span, ident, attrs, vis, defaultness, generics, kind, tokens: None })
+        Ok(AssocItem { id, span, ident, attrs, vis, defaultness, kind, tokens: None })
     }
 
     /// This parses the grammar:
     ///
     ///     AssocConst = "const" Ident ":" Ty "=" Expr ";"
-    fn parse_assoc_const(&mut self) -> PResult<'a, (Ident, AssocItemKind, Generics)> {
+    fn parse_assoc_const(&mut self) -> PResult<'a, (Ident, AssocItemKind)> {
         self.expect_keyword(kw::Const)?;
         let ident = self.parse_ident()?;
         self.expect(&token::Colon)?;
         let ty = self.parse_ty()?;
         let expr = if self.eat(&token::Eq) { Some(self.parse_expr()?) } else { None };
         self.expect_semi()?;
-        Ok((ident, AssocItemKind::Const(ty, expr), Generics::default()))
+        Ok((ident, AssocItemKind::Const(ty, expr)))
     }
 
     /// Parses the following grammar:
     ///
     ///     AssocTy = Ident ["<"...">"] [":" [GenericBounds]] ["where" ...] ["=" Ty]
-    fn parse_assoc_ty(&mut self) -> PResult<'a, (Ident, AssocItemKind, Generics)> {
+    fn parse_assoc_ty(&mut self) -> PResult<'a, (Ident, AssocItemKind)> {
         let ident = self.parse_ident()?;
         let mut generics = self.parse_generics()?;
 
@@ -716,7 +716,7 @@ fn parse_assoc_ty(&mut self) -> PResult<'a, (Ident, AssocItemKind, Generics)> {
         let default = if self.eat(&token::Eq) { Some(self.parse_ty()?) } else { None };
         self.expect_semi()?;
 
-        Ok((ident, AssocItemKind::TyAlias(bounds, default), generics))
+        Ok((ident, AssocItemKind::TyAlias(generics, bounds, default)))
     }
 
     /// Parses a `UseTree`.