about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-30 15:20:35 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-12-27 19:20:27 +0100
commitdeac631d7ff93db4d1d61ae9717444f60767003e (patch)
tree698f5ccc1edc229206e51f4679c552603c72f1df
parent41501a6b03a8f10d8c29dfcb37dbd5ff84b33f34 (diff)
downloadrust-deac631d7ff93db4d1d61ae9717444f60767003e.tar.gz
rust-deac631d7ff93db4d1d61ae9717444f60767003e.zip
Use Arena inside hir::FnSig.
-rw-r--r--src/librustc/hir/intravisit.rs2
-rw-r--r--src/librustc/hir/lowering/item.rs4
-rw-r--r--src/librustc/hir/map/blocks.rs12
-rw-r--r--src/librustc/hir/map/mod.rs4
-rw-r--r--src/librustc/hir/mod.rs10
-rw-r--r--src/librustc/hir/print.rs2
-rw-r--r--src/librustc_typeck/check/wfcheck.rs4
-rw-r--r--src/librustdoc/clean/mod.rs2
8 files changed, 21 insertions, 19 deletions
diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs
index 659bfc4e63c..519c1fe4cc8 100644
--- a/src/librustc/hir/intravisit.rs
+++ b/src/librustc/hir/intravisit.rs
@@ -45,7 +45,7 @@ pub enum FnKind<'a> {
     ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
 
     /// `fn foo(&self)`
-    Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]),
+    Method(Ident, &'a FnSig<'a>, Option<&'a Visibility>, &'a [Attribute]),
 
     /// `|x, y| {}`
     Closure(&'a [Attribute]),
diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs
index 0157e89c96b..4f1769dfd24 100644
--- a/src/librustc/hir/lowering/item.rs
+++ b/src/librustc/hir/lowering/item.rs
@@ -323,6 +323,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
                             )
                         },
                     );
+                    let decl = this.arena.alloc(decl.into_inner());
                     let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
                     hir::ItemKind::Fn(sig, generics, body_id)
                 })
@@ -1253,7 +1254,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         fn_def_id: DefId,
         impl_trait_return_allow: bool,
         is_async: Option<NodeId>,
-    ) -> (hir::Generics, hir::FnSig) {
+    ) -> (hir::Generics, hir::FnSig<'hir>) {
         let header = self.lower_fn_header(sig.header);
         let (generics, decl) = self.add_in_band_defs(
             generics,
@@ -1268,6 +1269,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
                 )
             },
         );
+        let decl = self.arena.alloc(decl.into_inner());
         (generics, hir::FnSig { header, decl })
     }
 
diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs
index 7701c33f916..6d8fd9d2f01 100644
--- a/src/librustc/hir/map/blocks.rs
+++ b/src/librustc/hir/map/blocks.rs
@@ -151,7 +151,7 @@ impl<'a> FnLikeNode<'a> {
     pub fn body(self) -> ast::BodyId {
         self.handle(
             |i: ItemFnParts<'a>| i.body,
-            |_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
+            |_, _, _: &'a ast::FnSig<'a>, _, body: ast::BodyId, _, _| body,
             |c: ClosureParts<'a>| c.body,
         )
     }
@@ -159,7 +159,7 @@ impl<'a> FnLikeNode<'a> {
     pub fn decl(self) -> &'a FnDecl {
         self.handle(
             |i: ItemFnParts<'a>| &*i.decl,
-            |_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
+            |_, _, sig: &'a ast::FnSig<'a>, _, _, _, _| &sig.decl,
             |c: ClosureParts<'a>| c.decl,
         )
     }
@@ -167,7 +167,7 @@ impl<'a> FnLikeNode<'a> {
     pub fn span(self) -> Span {
         self.handle(
             |i: ItemFnParts<'_>| i.span,
-            |_, _, _: &'a ast::FnSig, _, _, span, _| span,
+            |_, _, _: &'a ast::FnSig<'a>, _, _, span, _| span,
             |c: ClosureParts<'_>| c.span,
         )
     }
@@ -175,7 +175,7 @@ impl<'a> FnLikeNode<'a> {
     pub fn id(self) -> ast::HirId {
         self.handle(
             |i: ItemFnParts<'_>| i.id,
-            |id, _, _: &'a ast::FnSig, _, _, _, _| id,
+            |id, _, _: &'a ast::FnSig<'a>, _, _, _, _| id,
             |c: ClosureParts<'_>| c.id,
         )
     }
@@ -197,7 +197,7 @@ impl<'a> FnLikeNode<'a> {
             FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
         };
         let closure = |c: ClosureParts<'a>| FnKind::Closure(c.attrs);
-        let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| {
+        let method = |_, ident: Ident, sig: &'a ast::FnSig<'a>, vis, _, _, attrs| {
             FnKind::Method(ident, sig, vis, attrs)
         };
         self.handle(item, method, closure)
@@ -209,7 +209,7 @@ impl<'a> FnLikeNode<'a> {
         M: FnOnce(
             ast::HirId,
             Ident,
-            &'a ast::FnSig,
+            &'a ast::FnSig<'a>,
             Option<&'a ast::Visibility>,
             ast::BodyId,
             Span,
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index cc5cb58173f..d933f1e49e4 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -69,7 +69,7 @@ impl<'hir> Entry<'hir> {
         }
     }
 
-    fn fn_sig(&self) -> Option<&'hir FnSig> {
+    fn fn_sig(&self) -> Option<&'hir FnSig<'hir>> {
         match &self.node {
             Node::Item(item) => match &item.kind {
                 ItemKind::Fn(sig, _, _) => Some(sig),
@@ -437,7 +437,7 @@ impl<'hir> Map<'hir> {
         }
     }
 
-    pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig> {
+    pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
         if let Some(entry) = self.find_entry(hir_id) {
             entry.fn_sig()
         } else {
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 8a450cf167a..f54bc51baf1 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -1917,9 +1917,9 @@ pub struct MutTy {
 /// Represents a function's signature in a trait declaration,
 /// trait implementation, or a free function.
 #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
-pub struct FnSig {
+pub struct FnSig<'hir> {
     pub header: FnHeader,
-    pub decl: P<FnDecl>,
+    pub decl: &'hir FnDecl,
 }
 
 // The bodies for items are stored "out of line", in a separate
@@ -1960,7 +1960,7 @@ pub enum TraitItemKind<'hir> {
     /// An associated constant with an optional value (otherwise `impl`s must contain a value).
     Const(&'hir Ty, Option<BodyId>),
     /// A method with an optional body.
-    Method(FnSig, TraitMethod),
+    Method(FnSig<'hir>, TraitMethod),
     /// An associated type with (possibly empty) bounds and optional concrete
     /// type.
     Type(GenericBounds, Option<&'hir Ty>),
@@ -1994,7 +1994,7 @@ pub enum ImplItemKind<'hir> {
     /// of the expression.
     Const(&'hir Ty, BodyId),
     /// A method implementation with the given signature and body.
-    Method(FnSig, BodyId),
+    Method(FnSig<'hir>, BodyId),
     /// An associated type.
     TyAlias(&'hir Ty),
     /// An associated `type = impl Trait`.
@@ -2528,7 +2528,7 @@ pub enum ItemKind<'hir> {
     /// A `const` item.
     Const(&'hir Ty, BodyId),
     /// A function declaration.
-    Fn(FnSig, Generics, BodyId),
+    Fn(FnSig<'hir>, Generics, BodyId),
     /// A module.
     Mod(Mod<'hir>),
     /// An external module, e.g. `extern { .. }`.
diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs
index 11a596a8317..9e2702a0ff2 100644
--- a/src/librustc/hir/print.rs
+++ b/src/librustc/hir/print.rs
@@ -822,7 +822,7 @@ impl<'a> State<'a> {
     pub fn print_method_sig(
         &mut self,
         ident: ast::Ident,
-        m: &hir::FnSig,
+        m: &hir::FnSig<'_>,
         generics: &hir::Generics,
         vis: &hir::Visibility,
         arg_names: &[ast::Ident],
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index 4c349a27c21..1c8278480aa 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -194,7 +194,7 @@ fn check_associated_item(
     tcx: TyCtxt<'_>,
     item_id: hir::HirId,
     span: Span,
-    sig_if_method: Option<&hir::FnSig>,
+    sig_if_method: Option<&hir::FnSig<'_>>,
 ) {
     debug!("check_associated_item: {:?}", item_id);
 
@@ -774,7 +774,7 @@ const HELP_FOR_SELF_TYPE: &str = "consider changing to `self`, `&self`, `&mut se
 
 fn check_method_receiver<'fcx, 'tcx>(
     fcx: &FnCtxt<'fcx, 'tcx>,
-    fn_sig: &hir::FnSig,
+    fn_sig: &hir::FnSig<'_>,
     method: &ty::AssocItem,
     self_ty: Ty<'tcx>,
 ) {
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index e5c0a6aadce..bf0e3872995 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -892,7 +892,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
 }
 
 impl<'a> Clean<Method>
-    for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId, Option<hir::Defaultness>)
+    for (&'a hir::FnSig<'a>, &'a hir::Generics, hir::BodyId, Option<hir::Defaultness>)
 {
     fn clean(&self, cx: &DocContext<'_>) -> Method {
         let (generics, decl) =