fn lower_method_sig(
&mut self,
generics: &Generics,
- sig: &MethodSig,
+ sig: &FnSig,
fn_def_id: DefId,
impl_trait_return_allow: bool,
is_async: Option<NodeId>,
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
let def_data = match ii.kind {
- ImplItemKind::Method(MethodSig {
+ ImplItemKind::Method(FnSig {
ref header,
ref decl,
}, ref body) if header.asyncness.node.is_async() => {
fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
let is_const = match i.kind {
ast::TraitItemKind::Const(..) => true,
- ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
+ ast::TraitItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) =>
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
_ => false,
};
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
let is_const = match i.kind {
ast::ImplItemKind::Const(..) => true,
- ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
+ ast::ImplItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) =>
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
_ => false,
};
fn process_method(
&mut self,
- sig: &'l ast::MethodSig,
+ sig: &'l ast::FnSig,
body: Option<&'l ast::Block>,
id: ast::NodeId,
ident: ast::Ident,
id: NodeId,
ident: ast::Ident,
generics: &ast::Generics,
- m: &ast::MethodSig,
+ m: &ast::FnSig,
scx: &SaveContext<'_, '_>,
) -> Option<Signature> {
if !scx.config.signatures {
id: NodeId,
ident: ast::Ident,
generics: &ast::Generics,
- m: &ast::MethodSig,
+ m: &ast::FnSig,
scx: &SaveContext<'_, '_>,
) -> Result {
// FIXME code dup with function signature
pub mutbl: Mutability,
}
-/// Represents a method's signature in a trait declaration,
-/// or in an implementation.
+/// Represents a function's signature in a trait declaration,
+/// trait implementation, or free function.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
-pub struct MethodSig {
+pub struct FnSig {
pub header: FnHeader,
pub decl: P<FnDecl>,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitItemKind {
Const(P<Ty>, Option<P<Expr>>),
- Method(MethodSig, Option<P<Block>>),
+ Method(FnSig, Option<P<Block>>),
Type(GenericBounds, Option<P<Ty>>),
Macro(Mac),
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ImplItemKind {
Const(P<Ty>, P<Expr>),
- Method(MethodSig, P<Block>),
+ Method(FnSig, P<Block>),
TyAlias(P<Ty>),
OpaqueTy(GenericBounds),
Macro(Mac),
}
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
-pub fn visit_method_sig<T: MutVisitor>(MethodSig { header, decl }: &mut MethodSig, vis: &mut T) {
+pub fn visit_method_sig<T: MutVisitor>(FnSig { header, decl }: &mut FnSig, vis: &mut T) {
vis.visit_fn_header(header);
vis.visit_fn_decl(decl);
}
use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness};
use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
-use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param};
+use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param};
use crate::parse::token;
use crate::tokenstream::{TokenTree, TokenStream};
use crate::symbol::{kw, sym};
fn parse_method_sig(
&mut self,
is_name_required: fn(&token::Token) -> bool,
- ) -> PResult<'a, (Ident, MethodSig, Generics)> {
+ ) -> PResult<'a, (Ident, FnSig, Generics)> {
let header = self.parse_fn_front_matter()?;
let (ident, decl, generics) = self.parse_fn_sig(ParamCfg {
is_self_allowed: true,
allow_c_variadic: false,
is_name_required,
})?;
- Ok((ident, MethodSig { header, decl }, generics))
+ Ok((ident, FnSig { header, decl }, generics))
}
/// Parses all the "front matter" for a `fn` declaration, up to
crate fn print_method_sig(&mut self,
ident: ast::Ident,
generics: &ast::Generics,
- m: &ast::MethodSig,
+ m: &ast::FnSig,
vis: &ast::Visibility)
{
self.print_fn(&m.decl,
ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block),
/// E.g., `fn foo(&self)`.
- Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a Block),
+ Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a Block),
/// E.g., `|x, y| body`.
Closure(&'a Expr),
let trait_lo_sp = trait_.span.shrink_to_lo();
- let sig = ast::MethodSig {
+ let sig = ast::FnSig {
header: ast::FnHeader {
unsafety,
abi: Abi::new(abi, trait_lo_sp),