Use Arena inside hir::FnSig.
This commit is contained in:
parent
41501a6b03
commit
deac631d7f
8 changed files with 21 additions and 19 deletions
|
|
@ -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]),
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 { .. }`.
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue