Skip to content

Commit deac631

Browse files
committed
Use Arena inside hir::FnSig.
1 parent 41501a6 commit deac631

File tree

8 files changed

+21
-19
lines changed

8 files changed

+21
-19
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum FnKind<'a> {
4545
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
4646

4747
/// `fn foo(&self)`
48-
Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]),
48+
Method(Ident, &'a FnSig<'a>, Option<&'a Visibility>, &'a [Attribute]),
4949

5050
/// `|x, y| {}`
5151
Closure(&'a [Attribute]),

src/librustc/hir/lowering/item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
323323
)
324324
},
325325
);
326+
let decl = this.arena.alloc(decl.into_inner());
326327
let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
327328
hir::ItemKind::Fn(sig, generics, body_id)
328329
})
@@ -1253,7 +1254,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12531254
fn_def_id: DefId,
12541255
impl_trait_return_allow: bool,
12551256
is_async: Option<NodeId>,
1256-
) -> (hir::Generics, hir::FnSig) {
1257+
) -> (hir::Generics, hir::FnSig<'hir>) {
12571258
let header = self.lower_fn_header(sig.header);
12581259
let (generics, decl) = self.add_in_band_defs(
12591260
generics,
@@ -1268,6 +1269,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12681269
)
12691270
},
12701271
);
1272+
let decl = self.arena.alloc(decl.into_inner());
12711273
(generics, hir::FnSig { header, decl })
12721274
}
12731275

src/librustc/hir/map/blocks.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,31 @@ impl<'a> FnLikeNode<'a> {
151151
pub fn body(self) -> ast::BodyId {
152152
self.handle(
153153
|i: ItemFnParts<'a>| i.body,
154-
|_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
154+
|_, _, _: &'a ast::FnSig<'a>, _, body: ast::BodyId, _, _| body,
155155
|c: ClosureParts<'a>| c.body,
156156
)
157157
}
158158

159159
pub fn decl(self) -> &'a FnDecl {
160160
self.handle(
161161
|i: ItemFnParts<'a>| &*i.decl,
162-
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
162+
|_, _, sig: &'a ast::FnSig<'a>, _, _, _, _| &sig.decl,
163163
|c: ClosureParts<'a>| c.decl,
164164
)
165165
}
166166

167167
pub fn span(self) -> Span {
168168
self.handle(
169169
|i: ItemFnParts<'_>| i.span,
170-
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
170+
|_, _, _: &'a ast::FnSig<'a>, _, _, span, _| span,
171171
|c: ClosureParts<'_>| c.span,
172172
)
173173
}
174174

175175
pub fn id(self) -> ast::HirId {
176176
self.handle(
177177
|i: ItemFnParts<'_>| i.id,
178-
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
178+
|id, _, _: &'a ast::FnSig<'a>, _, _, _, _| id,
179179
|c: ClosureParts<'_>| c.id,
180180
)
181181
}
@@ -197,7 +197,7 @@ impl<'a> FnLikeNode<'a> {
197197
FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
198198
};
199199
let closure = |c: ClosureParts<'a>| FnKind::Closure(c.attrs);
200-
let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| {
200+
let method = |_, ident: Ident, sig: &'a ast::FnSig<'a>, vis, _, _, attrs| {
201201
FnKind::Method(ident, sig, vis, attrs)
202202
};
203203
self.handle(item, method, closure)
@@ -209,7 +209,7 @@ impl<'a> FnLikeNode<'a> {
209209
M: FnOnce(
210210
ast::HirId,
211211
Ident,
212-
&'a ast::FnSig,
212+
&'a ast::FnSig<'a>,
213213
Option<&'a ast::Visibility>,
214214
ast::BodyId,
215215
Span,

src/librustc/hir/map/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'hir> Entry<'hir> {
6969
}
7070
}
7171

72-
fn fn_sig(&self) -> Option<&'hir FnSig> {
72+
fn fn_sig(&self) -> Option<&'hir FnSig<'hir>> {
7373
match &self.node {
7474
Node::Item(item) => match &item.kind {
7575
ItemKind::Fn(sig, _, _) => Some(sig),
@@ -437,7 +437,7 @@ impl<'hir> Map<'hir> {
437437
}
438438
}
439439

440-
pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig> {
440+
pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
441441
if let Some(entry) = self.find_entry(hir_id) {
442442
entry.fn_sig()
443443
} else {

src/librustc/hir/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,9 +1917,9 @@ pub struct MutTy {
19171917
/// Represents a function's signature in a trait declaration,
19181918
/// trait implementation, or a free function.
19191919
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
1920-
pub struct FnSig {
1920+
pub struct FnSig<'hir> {
19211921
pub header: FnHeader,
1922-
pub decl: P<FnDecl>,
1922+
pub decl: &'hir FnDecl,
19231923
}
19241924

19251925
// The bodies for items are stored "out of line", in a separate
@@ -1960,7 +1960,7 @@ pub enum TraitItemKind<'hir> {
19601960
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
19611961
Const(&'hir Ty, Option<BodyId>),
19621962
/// A method with an optional body.
1963-
Method(FnSig, TraitMethod),
1963+
Method(FnSig<'hir>, TraitMethod),
19641964
/// An associated type with (possibly empty) bounds and optional concrete
19651965
/// type.
19661966
Type(GenericBounds, Option<&'hir Ty>),
@@ -1994,7 +1994,7 @@ pub enum ImplItemKind<'hir> {
19941994
/// of the expression.
19951995
Const(&'hir Ty, BodyId),
19961996
/// A method implementation with the given signature and body.
1997-
Method(FnSig, BodyId),
1997+
Method(FnSig<'hir>, BodyId),
19981998
/// An associated type.
19991999
TyAlias(&'hir Ty),
20002000
/// An associated `type = impl Trait`.
@@ -2528,7 +2528,7 @@ pub enum ItemKind<'hir> {
25282528
/// A `const` item.
25292529
Const(&'hir Ty, BodyId),
25302530
/// A function declaration.
2531-
Fn(FnSig, Generics, BodyId),
2531+
Fn(FnSig<'hir>, Generics, BodyId),
25322532
/// A module.
25332533
Mod(Mod<'hir>),
25342534
/// An external module, e.g. `extern { .. }`.

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ impl<'a> State<'a> {
822822
pub fn print_method_sig(
823823
&mut self,
824824
ident: ast::Ident,
825-
m: &hir::FnSig,
825+
m: &hir::FnSig<'_>,
826826
generics: &hir::Generics,
827827
vis: &hir::Visibility,
828828
arg_names: &[ast::Ident],

src/librustc_typeck/check/wfcheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn check_associated_item(
194194
tcx: TyCtxt<'_>,
195195
item_id: hir::HirId,
196196
span: Span,
197-
sig_if_method: Option<&hir::FnSig>,
197+
sig_if_method: Option<&hir::FnSig<'_>>,
198198
) {
199199
debug!("check_associated_item: {:?}", item_id);
200200

@@ -774,7 +774,7 @@ const HELP_FOR_SELF_TYPE: &str = "consider changing to `self`, `&self`, `&mut se
774774

775775
fn check_method_receiver<'fcx, 'tcx>(
776776
fcx: &FnCtxt<'fcx, 'tcx>,
777-
fn_sig: &hir::FnSig,
777+
fn_sig: &hir::FnSig<'_>,
778778
method: &ty::AssocItem,
779779
self_ty: Ty<'tcx>,
780780
) {

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
892892
}
893893

894894
impl<'a> Clean<Method>
895-
for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId, Option<hir::Defaultness>)
895+
for (&'a hir::FnSig<'a>, &'a hir::Generics, hir::BodyId, Option<hir::Defaultness>)
896896
{
897897
fn clean(&self, cx: &DocContext<'_>) -> Method {
898898
let (generics, decl) =

0 commit comments

Comments
 (0)