hir::MethodSig -> hir::FnSig

This commit is contained in:
Mazdak Farrokhzad 2019-11-07 13:06:52 +01:00
parent 30d7279628
commit 27511b22df
10 changed files with 26 additions and 25 deletions

View File

@ -45,7 +45,7 @@ pub enum FnKind<'a> {
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
/// `fn foo(&self)`
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]),
/// `|x, y| {}`
Closure(&'a [Attribute]),

View File

@ -328,7 +328,7 @@ impl LoweringContext<'_> {
header.asyncness.node.opt_return_id()
),
);
let sig = hir::MethodSig { decl, header: this.lower_fn_header(header) };
let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
hir::ItemKind::Fn(sig, generics, body_id)
})
}
@ -1259,7 +1259,7 @@ impl LoweringContext<'_> {
fn_def_id: DefId,
impl_trait_return_allow: bool,
is_async: Option<NodeId>,
) -> (hir::Generics, hir::MethodSig) {
) -> (hir::Generics, hir::FnSig) {
let header = self.lower_fn_header(sig.header);
let (generics, decl) = self.add_in_band_defs(
generics,
@ -1272,7 +1272,7 @@ impl LoweringContext<'_> {
is_async,
),
);
(generics, hir::MethodSig { header, decl })
(generics, hir::FnSig { header, decl })
}
fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto {

View File

@ -158,25 +158,25 @@ impl<'a> FnLikeNode<'a> {
pub fn body(self) -> ast::BodyId {
self.handle(|i: ItemFnParts<'a>| i.body,
|_, _, _: &'a ast::MethodSig, _, body: ast::BodyId, _, _| body,
|_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
|c: ClosureParts<'a>| c.body)
}
pub fn decl(self) -> &'a FnDecl {
self.handle(|i: ItemFnParts<'a>| &*i.decl,
|_, _, sig: &'a ast::MethodSig, _, _, _, _| &sig.decl,
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
|c: ClosureParts<'a>| c.decl)
}
pub fn span(self) -> Span {
self.handle(|i: ItemFnParts<'_>| i.span,
|_, _, _: &'a ast::MethodSig, _, _, span, _| span,
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
|c: ClosureParts<'_>| c.span)
}
pub fn id(self) -> ast::HirId {
self.handle(|i: ItemFnParts<'_>| i.id,
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
|c: ClosureParts<'_>| c.id)
}
@ -199,7 +199,7 @@ impl<'a> FnLikeNode<'a> {
let closure = |c: ClosureParts<'a>| {
FnKind::Closure(c.attrs)
};
let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _, attrs| {
let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| {
FnKind::Method(ident, sig, vis, attrs)
};
self.handle(item, method, closure)
@ -209,7 +209,7 @@ impl<'a> FnLikeNode<'a> {
I: FnOnce(ItemFnParts<'a>) -> A,
M: FnOnce(ast::HirId,
Ident,
&'a ast::MethodSig,
&'a ast::FnSig,
Option<&'a ast::Visibility>,
ast::BodyId,
Span,

View File

@ -1876,9 +1876,10 @@ pub struct MutTy {
pub mutbl: Mutability,
}
/// Represents a method's signature in a trait declaration or implementation.
/// Represents a function's signature in a trait declaration,
/// trait implementation, or a free function.
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct MethodSig {
pub struct FnSig {
pub header: FnHeader,
pub decl: P<FnDecl>,
}
@ -1921,7 +1922,7 @@ pub enum TraitItemKind {
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
Const(P<Ty>, Option<BodyId>),
/// A method with an optional body.
Method(MethodSig, TraitMethod),
Method(FnSig, TraitMethod),
/// An associated type with (possibly empty) bounds and optional concrete
/// type.
Type(GenericBounds, Option<P<Ty>>),
@ -1955,7 +1956,7 @@ pub enum ImplItemKind {
/// of the expression.
Const(P<Ty>, BodyId),
/// A method implementation with the given signature and body.
Method(MethodSig, BodyId),
Method(FnSig, BodyId),
/// An associated type.
TyAlias(P<Ty>),
/// An associated `type = impl Trait`.
@ -2534,7 +2535,7 @@ pub enum ItemKind {
/// A `const` item.
Const(P<Ty>, BodyId),
/// A function declaration.
Fn(MethodSig, Generics, BodyId),
Fn(FnSig, Generics, BodyId),
/// A module.
Mod(Mod),
/// An external module, e.g. `extern { .. }`.

View File

@ -835,7 +835,7 @@ impl<'a> State<'a> {
}
pub fn print_method_sig(&mut self,
ident: ast::Ident,
m: &hir::MethodSig,
m: &hir::FnSig,
generics: &hir::Generics,
vis: &hir::Visibility,
arg_names: &[ast::Ident],

View File

@ -32,20 +32,20 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
| Node::Item(
hir::Item {
kind: hir::ItemKind::Fn(hir::MethodSig { decl, .. }, _, body_id),
kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
..
}
)
| Node::ImplItem(
hir::ImplItem {
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
kind: hir::ImplItemKind::Method(hir::FnSig { decl, .. }, body_id),
..
}
)
| Node::TraitItem(
hir::TraitItem {
kind: hir::TraitItemKind::Method(
hir::MethodSig { decl, .. },
hir::FnSig { decl, .. },
hir::TraitMethod::Provided(body_id),
),
..

View File

@ -1071,7 +1071,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
match ii.kind {
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
hir::ImplItemKind::Method(hir::FnSig { .. }, _) => {
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
self.push_if_root(def_id);
}

View File

@ -190,7 +190,7 @@ fn check_associated_item(
tcx: TyCtxt<'_>,
item_id: hir::HirId,
span: Span,
sig_if_method: Option<&hir::MethodSig>,
sig_if_method: Option<&hir::FnSig>,
) {
debug!("check_associated_item: {:?}", item_id);
@ -783,7 +783,7 @@ const HELP_FOR_SELF_TYPE: &str =
fn check_method_receiver<'fcx, 'tcx>(
fcx: &FnCtxt<'fcx, 'tcx>,
method_sig: &hir::MethodSig,
fn_sig: &hir::FnSig,
method: &ty::AssocItem,
self_ty: Ty<'tcx>,
) {
@ -794,7 +794,7 @@ fn check_method_receiver<'fcx, 'tcx>(
return;
}
let span = method_sig.decl.inputs[0].span;
let span = fn_sig.decl.inputs[0].span;
let sig = fcx.tcx.fn_sig(method.def_id);
let sig = fcx.normalize_associated_types_in(span, &sig);

View File

@ -1809,7 +1809,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
},
TraitItem(hir::TraitItem {
kind: TraitItemKind::Method(MethodSig { header, decl }, _),
kind: TraitItemKind::Method(FnSig { header, decl }, _),
..
}) => {
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)

View File

@ -1984,7 +1984,7 @@ pub struct Method {
pub ret_types: Vec<Type>,
}
impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId,
impl<'a> Clean<Method> for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId,
Option<hir::Defaultness>) {
fn clean(&self, cx: &DocContext<'_>) -> Method {
let (generics, decl) = enter_impl_trait(cx, || {