ast::MethodSig -> ast::FnSig
This commit is contained in:
parent
27511b22df
commit
2cd48e8a3b
@ -1255,7 +1255,7 @@ impl LoweringContext<'_> {
|
|||||||
fn lower_method_sig(
|
fn lower_method_sig(
|
||||||
&mut self,
|
&mut self,
|
||||||
generics: &Generics,
|
generics: &Generics,
|
||||||
sig: &MethodSig,
|
sig: &FnSig,
|
||||||
fn_def_id: DefId,
|
fn_def_id: DefId,
|
||||||
impl_trait_return_allow: bool,
|
impl_trait_return_allow: bool,
|
||||||
is_async: Option<NodeId>,
|
is_async: Option<NodeId>,
|
||||||
|
@ -228,7 +228,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||||||
|
|
||||||
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
||||||
let def_data = match ii.kind {
|
let def_data = match ii.kind {
|
||||||
ImplItemKind::Method(MethodSig {
|
ImplItemKind::Method(FnSig {
|
||||||
ref header,
|
ref header,
|
||||||
ref decl,
|
ref decl,
|
||||||
}, ref body) if header.asyncness.node.is_async() => {
|
}, ref body) if header.asyncness.node.is_async() => {
|
||||||
|
@ -802,7 +802,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||||||
fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
|
fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
|
||||||
let is_const = match i.kind {
|
let is_const = match i.kind {
|
||||||
ast::TraitItemKind::Const(..) => true,
|
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),
|
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
@ -812,7 +812,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||||||
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
||||||
let is_const = match i.kind {
|
let is_const = match i.kind {
|
||||||
ast::ImplItemKind::Const(..) => true,
|
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),
|
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
@ -272,7 +272,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||||||
|
|
||||||
fn process_method(
|
fn process_method(
|
||||||
&mut self,
|
&mut self,
|
||||||
sig: &'l ast::MethodSig,
|
sig: &'l ast::FnSig,
|
||||||
body: Option<&'l ast::Block>,
|
body: Option<&'l ast::Block>,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
|
@ -72,7 +72,7 @@ pub fn method_signature(
|
|||||||
id: NodeId,
|
id: NodeId,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
m: &ast::MethodSig,
|
m: &ast::FnSig,
|
||||||
scx: &SaveContext<'_, '_>,
|
scx: &SaveContext<'_, '_>,
|
||||||
) -> Option<Signature> {
|
) -> Option<Signature> {
|
||||||
if !scx.config.signatures {
|
if !scx.config.signatures {
|
||||||
@ -932,7 +932,7 @@ fn make_method_signature(
|
|||||||
id: NodeId,
|
id: NodeId,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
m: &ast::MethodSig,
|
m: &ast::FnSig,
|
||||||
scx: &SaveContext<'_, '_>,
|
scx: &SaveContext<'_, '_>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
// FIXME code dup with function signature
|
// FIXME code dup with function signature
|
||||||
|
@ -1501,10 +1501,10 @@ pub struct MutTy {
|
|||||||
pub mutbl: Mutability,
|
pub mutbl: Mutability,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a method's signature in a trait declaration,
|
/// Represents a function's signature in a trait declaration,
|
||||||
/// or in an implementation.
|
/// trait implementation, or free function.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct MethodSig {
|
pub struct FnSig {
|
||||||
pub header: FnHeader,
|
pub header: FnHeader,
|
||||||
pub decl: P<FnDecl>,
|
pub decl: P<FnDecl>,
|
||||||
}
|
}
|
||||||
@ -1528,7 +1528,7 @@ pub struct TraitItem {
|
|||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub enum TraitItemKind {
|
pub enum TraitItemKind {
|
||||||
Const(P<Ty>, Option<P<Expr>>),
|
Const(P<Ty>, Option<P<Expr>>),
|
||||||
Method(MethodSig, Option<P<Block>>),
|
Method(FnSig, Option<P<Block>>),
|
||||||
Type(GenericBounds, Option<P<Ty>>),
|
Type(GenericBounds, Option<P<Ty>>),
|
||||||
Macro(Mac),
|
Macro(Mac),
|
||||||
}
|
}
|
||||||
@ -1552,7 +1552,7 @@ pub struct ImplItem {
|
|||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub enum ImplItemKind {
|
pub enum ImplItemKind {
|
||||||
Const(P<Ty>, P<Expr>),
|
Const(P<Ty>, P<Expr>),
|
||||||
Method(MethodSig, P<Block>),
|
Method(FnSig, P<Block>),
|
||||||
TyAlias(P<Ty>),
|
TyAlias(P<Ty>),
|
||||||
OpaqueTy(GenericBounds),
|
OpaqueTy(GenericBounds),
|
||||||
Macro(Mac),
|
Macro(Mac),
|
||||||
|
@ -357,7 +357,7 @@ pub fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
// 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_header(header);
|
||||||
vis.visit_fn_decl(decl);
|
vis.visit_fn_decl(decl);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use crate::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, Use
|
|||||||
use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness};
|
use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness};
|
||||||
use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
|
use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
|
||||||
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
|
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::parse::token;
|
||||||
use crate::tokenstream::{TokenTree, TokenStream};
|
use crate::tokenstream::{TokenTree, TokenStream};
|
||||||
use crate::symbol::{kw, sym};
|
use crate::symbol::{kw, sym};
|
||||||
@ -1897,14 +1897,14 @@ impl<'a> Parser<'a> {
|
|||||||
fn parse_method_sig(
|
fn parse_method_sig(
|
||||||
&mut self,
|
&mut self,
|
||||||
is_name_required: fn(&token::Token) -> bool,
|
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 header = self.parse_fn_front_matter()?;
|
||||||
let (ident, decl, generics) = self.parse_fn_sig(ParamCfg {
|
let (ident, decl, generics) = self.parse_fn_sig(ParamCfg {
|
||||||
is_self_allowed: true,
|
is_self_allowed: true,
|
||||||
allow_c_variadic: false,
|
allow_c_variadic: false,
|
||||||
is_name_required,
|
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
|
/// Parses all the "front matter" for a `fn` declaration, up to
|
||||||
|
@ -1541,7 +1541,7 @@ impl<'a> State<'a> {
|
|||||||
crate fn print_method_sig(&mut self,
|
crate fn print_method_sig(&mut self,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
m: &ast::MethodSig,
|
m: &ast::FnSig,
|
||||||
vis: &ast::Visibility)
|
vis: &ast::Visibility)
|
||||||
{
|
{
|
||||||
self.print_fn(&m.decl,
|
self.print_fn(&m.decl,
|
||||||
|
@ -25,7 +25,7 @@ pub enum FnKind<'a> {
|
|||||||
ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block),
|
ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block),
|
||||||
|
|
||||||
/// E.g., `fn foo(&self)`.
|
/// 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`.
|
/// E.g., `|x, y| body`.
|
||||||
Closure(&'a Expr),
|
Closure(&'a Expr),
|
||||||
|
@ -950,7 +950,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
|
|
||||||
let trait_lo_sp = trait_.span.shrink_to_lo();
|
let trait_lo_sp = trait_.span.shrink_to_lo();
|
||||||
|
|
||||||
let sig = ast::MethodSig {
|
let sig = ast::FnSig {
|
||||||
header: ast::FnHeader {
|
header: ast::FnHeader {
|
||||||
unsafety,
|
unsafety,
|
||||||
abi: Abi::new(abi, trait_lo_sp),
|
abi: Abi::new(abi, trait_lo_sp),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user